Array of buses in superCollider -


i have synth generated do:

( synthdef(\siny, { arg freq, outbus=0; out.ar( outbus, sinosc.ar(freq!2,0,0.2) ) } ).send(s); synthdef(\filter, { arg cfreq,q=0.8, inbus; out.ar( 0, bpf.ar(in.ar(inbus), cfreq!2, 1/q ) ) } ).send(s);  )  ( ~sourceout = bus.audio(s); ~sine_group = pargroup.new; z = [100,500,1000,1500,250];  { z.do({ arg val; synth.head(~sine_group, \siny, [\freq: val, \outbus: ~sourceout]) }); z.do({ arg val; synth.after(~sine_group, \filter, [\inbus: ~sourceout, \cfreq: 200] ) });  }.play; ) 

right now, understanding that, output of multiple instances of synth \siny mixed in bus ~sourceout, , goes input synth \filter

what want have one-to-one connection between multiple instances of \siny , \filter.. use array of busses connect them? if so, how do that?

yes can. here i've modified code minimally. first made ~sourceout array of busses rather single bus. second, inside do loops made use of fact main iteration functions in supercollider can provide second index argument each item itself. thirdly use index argument select desired bus:

( z = [100,500,1000,1500,250]; ~sourceout = z.collect{ bus.audio(s) }; ~sine_group = pargroup.new;  { z.do({ arg val, index; synth.head(~sine_group, \siny, [\freq: val, \outbus: ~sourceout[index]]) }); z.do({ arg val, index; synth.after(~sine_group, \filter, [\inbus: ~sourceout[index], \cfreq: 200] ) });  }.play; ) 

depending on needs, might @ nodeproxy useful prototyping , live coding, , provides tricks plugging synths' output each other.


Comments