DoubleOscer

Back and forth bouncing between buffered waveforms.

( s = Server.local; b = Buffer.alloc(s, 4096, 1); c = Buffer.alloc(s, 4096, 1); )

( SynthDef("Oscer1", {argnextTime = 0.5, bufnum = 0, freq = 80, envLev = 1.0; var env, osc, sum, out; env = EnvGen.kr(Env.new([0, 1, 1, 0], [0.1, 0.98, 0.1]), levelScale: envLev, timeScale: nextTime*0.98, doneAction: 2); osc = Osc.ar(b.bufnum, [freq, freq+(freq*0.0025)], 0, 0.5);//[freq, freq+(freq*0.0025)] sum = (env*osc); Out.ar(0, sum); }).send(s);

SynthDef("Oscer2", {argnextTime = 0.5, bufnum = 0, freq = 80, envLev = 1.0;	varenv, osc, sum, out;	env = EnvGen.kr(Env.new([0, 1, 1, 0], [0.1, 0.98, 0.1]), levelScale: envLev, timeScale: nextTime*0.98, doneAction: 2);	osc = Osc.ar(c.bufnum, [freq, freq+(freq*0.0025)], 0, 0.5);	sum = (env*osc);	Out.ar(0, sum); }).store; )

( t = TempoClock(110/60); u = t.beatDur/4;

Routine({argnextTime;	OSCSched.global.tdeltaTillNext(4.0).wait;	loop({ nextTime = u;		s.sendBundle(nil, [			\s_new, \Oscer1, 1001, 1, 0, 			\freq, 26.midicps, 			\envLev, rrand(0.6, 0.8), 			\nextTime, nextTime		]); (nextTime*2).wait; }); }).play;

Routine({argnextTime;	varn = 7;	OSCSched.global.tdeltaTillNext(4.0).wait;	loop({ nextTime = u;		(nextTime*1.5).wait; b.sine1(Array.rand(n, 0, 1).cubed, true, true, true); (nextTime*0.5).wait; }); }).play;

Routine({argnextTime;	OSCSched.global.tdeltaTillNext(4.0).wait;	loop({ nextTime = u;		nextTime.wait; s.sendBundle(nil, [			\s_new, \Oscer2, 1002, 1, 0, 			\freq, 38.midicps, 			\envLev, rrand(0.5, 0.8), 			\nextTime, nextTime		]); nextTime.wait; }); }).play;

Routine({argnextTime;	varn = 7;	OSCSched.global.tdeltaTillNext(4.0).wait;	loop({ nextTime = u;		(nextTime*0.5).wait; c.sine1(Array.rand(n, 0, 1).cubed, true, true, true); (nextTime*1.5).wait; }); }).play;

) /* authors so far: Jonathan Segel

(Back to Code Pool)