
// developement of 8-speaker output - notes, sketches...


// use it in a synth def
SynthDef(\testOcto, {
	arg x= 0, y = 0, fact;

	var son = WhiteNoise.ar(1) ;

	y = SinOsc.kr(0.1).range(0,1);
	//x = SinOsc.kr(0.4).range(0,1);

	Out.ar(0,~octoPanOut.value(son, x, y, fact));
	//Out.ar(1,son);
}).add;
)



x = Synth(\testOcto, [\fact, 100]);
x.free

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// pseudo-UGen proposition by 'elgiano'
// https://scsynth.org/t/simple-spatialisation-function-synthdef-pseudo-ugen-or-ugen/1783/5

OctoPan : MultiOutUGen {

    classvar <>speakers = #[
	[0,0],[0,360],[0,720],[0,1080],[650,1260],[650,900],[650,540],[650,180]
    ];

    *ar { arg in,x=0,y=0,speakers;
        ^this.multiNew('audio', in,x,y);
    }

    *new1 { arg rate,in,x,y;
        var amps = this.speakers.collect{|coords|
	    var dist = coords - [x,y];
	    1/(1+dist[0].hypot(dist[1]))
	};
	^in*amps;
    }
	
}
	