( // a function to position sound in space ~octoPanOut = { arg in, in_x, in_y, fact; var s1_x=0, s1_y=0, s1_amp, s2_x=0, s2_y=360, s2_amp, s3_x=0, s3_y=720, s3_amp, s4_x=0, s4_y=1080, s4_amp, s5_x=650, s5_y=1260, s5_amp, s6_x=650, s6_y=900, s6_amp, s7_x=650, s7_y=540, s7_amp, s8_x=650, s8_y=180, s8_amp ; var factor = (1 / (5000000 * fact)); // exponential curve of amplification calculated from distance? log???? //var distance = {|x1,y1,x2,y2| ((x2-x1).squared + (y2-y1).squared).sqrt}; var distance = {|x1,y1,x2,y2| (x2-x1) hypot: (y2-y1) }; // hypothenuse var amp = 1 / (1 + (distance.cubed * factor)); //in_x = (in_x + 1) * 0.5 * 650; in_x = in_x * 650; //in_y = (in_y + 1) * 0.5 * 1260; in_y = in_y * 1260; s1_amp = amp.value(in_x,in_y,s1_x,s1_y); s2_amp = amp.value(in_x,in_y,s2_x,s2_y); s3_amp = amp.value(in_x,in_y,s3_x,s3_y); s4_amp = amp.value(in_x,in_y,s4_x,s4_y); s5_amp = amp.value(in_x,in_y,s5_x,s5_y); s6_amp = amp.value(in_x,in_y,s6_x,s6_y); s7_amp = amp.value(in_x,in_y,s7_x,s7_y); s8_amp = amp.value(in_x,in_y,s8_x,s8_y); [in * s1_amp, in * s2_amp, in * s3_amp, in * s4_amp, in * s5_amp, in * s6_amp, in * s7_amp, in * s8_amp] }; SynthDef("octoPanner", { arg inBus, x=0, y=0.14, radius=1; var snd = In.ar(inBus,1); snd = ~octoPanOut.value(snd, x, y, radius); Out.ar(0, snd); }).add; ) ////////////////////////////////////////////////////////////////////////////////////////////////////////// // 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; } } */