Connecting multiple stages of parallel synths, with array of buses, in superCollider -


when have 2 stages of multiple parallel synths, able connect array of buses. (thanks dan s answer previous question). when there 3 stage, doesn't seem work.

( 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, outbus=0; out.ar( outbus, bpf.ar(in.ar(inbus), cfreq!2, 1/q ) ) } ).send(s); )  ( var z = [100,500,1000,1500,200]; ~sourceout = z.collect{ bus.audio(s) }; ~sineout = z.collect{ bus.audio(s) }; ~sine_group = pargroup.new; ~mygroup    = pargroup.new;  { z.do({ arg val, index; synth( \siny, [\freq: val, \outbus: ~sourceout[index]], ~sine_group ) }); z.do({ arg val, index; synth.after(~sine_group, \filter, [\inbus: ~sourceout[index], \outbus: ~sineout[index],\cfreq: 200, \q: 20 ], ~mygroup) }); z.do({ arg val, index; synth.after(~mygroup, \filter, [\inbus: ~sineout[index], \cfreq: 200, \q: 20]) });  }.play; ) 

another harm doing here is, everytime stop , run synth, new instances of busses created , run out of audio buses. how can solve this?

there number of issues code (some irrelevant question):

a. send(s) reminiscent of past, these days add preferable - may consult documentation differences.

b. it's not practice mix local variables var environmental ones (such ~sourceout) unless there reason.

c. .collect(func) (or directly collect{/*function body here*/}) when send array results array each element result of func respective element of original array passed argument. here:

var z = [100,500,1000,1500,200]; ~sourceout = z.collect{ bus.audio(s) }; ~sineout = z.collect{ bus.audio(s) }; 

you don't use original numbers anywhere, create 2 arrays containing 5 audio buses each. directly doing less confusing , more explicit:

~sourceout = array.fill(5,{bus.audio(s)}); ~sineout = array.fill(5,{bus.audio(s)}); 

d. there's no point in calling z.do 3 times.. can call once , put rest in same function.

e. check routings... have 2 parallel groups , you're merely saying want these synths on group , these others after other group.. want want these synths after synths on group.

f. don't free buses or synths when done... memory leak :)

g. call play on function want evaluate really... should call value instead.

this code produces sound , cleans when don, note result pretty boring because you've filtered higher-end.

s.waitforboot({ // routine      var frequencies = [100,500,1000,1500,200];     var sources = array.fill(frequencies.size,{bus.audio(s)});     var filters = array.fill(frequencies.size,{bus.audio(s)});     var pargroups = array.fill(2,{pargroup.new});     var sinesynths;     var firstorderfilters;     var secondorderfilters;      synthdef(\siny, {         arg freq, outbus=0;         out.ar( outbus, sinosc.ar(freq!2,0,0.2));     }).add;     synthdef(\filter, {         arg cfreq,q=0.8, inbus, outbus=0;         out.ar( outbus, bpf.ar(in.ar(inbus), cfreq!2, 1/q ) )     }).add;     s.sync; // wait synthdefs load      frequencies.do{ arg freq, index;         sinesynths = sinesynths.add( synth(\siny, [\freq: freq.postln, \outbus: sources[index]],             pargroups[0])); // create synths , add them in sinesynths array         firstorderfilters = firstorderfilters.add(             synth.after(sinesynths[index], \filter, [\inbus: sources[index],                 \outbus: filters[index], \cfreq: 200, \q: 20 ], pargroups[1]));         secondorderfilters = secondorderfilters.add(             synth.after(firstorderfilters[index], \filter, [\inbus: filters[index],                 \outbus: 0, \cfreq: 200, \q: 20 ], pargroups[1]));     };      10.wait; // wait 10 seconds;      // clean     sinesynths.do{arg i; i.free};     firstorderfilters.do{arg i; i.free};     secondorderfilters.do{arg i; i.free};     sources.do{arg i; i.free};     filters.do{arg i; i.free}; }); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -