( s = Server.local; s.status; s.boot; ) ( var dur, times, times2, pitches; var kickBut, kick, snareBut, snare; var hihat, hatBut, left, leftBut, right, rightBut; s.sendMsg("/b_allocRead", 0, "sounds/a11wlk01.wav"); //replace with your sounds - if you want SynthDef("columbia", { arg gate = 1, rate = 1, bufnum = 0, startPos=0.0, time=1.0, envLev=1.0, panPos=0.0, loopLength=1, trig=1; var out,eg, triggerer; triggerer = Impulse.kr(BufSampleRate.kr(bufnum)/loopLength); eg = EnvGen.kr(Env.linen(0.1, 0.98, 0.1, 1), gate, timeScale: time, levelScale: envLev, doneAction: 2); out = Pan2.ar(PlayBuf.ar(1, bufnum, rate, triggerer, startPos, loop: 1), panPos); Out.ar(0, out*eg); }).load(s); SynthDef("columbiaPerc", { arg gate = 1, rate = 1, bufnum = 0, startPos=0.0, time=1.0, envLev=1.0, panPos=0.0, loopLength=1, trig=1; var out,eg, triggerer; triggerer = Impulse.kr(BufSampleRate.kr(bufnum)/loopLength); eg = EnvGen.kr(Env.perc(0.01, 1, 1, -4), gate, timeScale: time, levelScale: envLev, doneAction: 2); out = Pan2.ar(PlayBuf.ar(1, bufnum, rate, triggerer, startPos, loop: 1), panPos); Out.ar(0, out*eg); }).load(s); w = SCWindow("ColumbiaTrap", Rect(35, 580, 420, 65)).front; w.view.background_(rgb(10,75,195)); kickBut = SCButton(w, Rect(10, 23,80, 20 )) .states_([ ["Kick", Color.black, Color.green], ["Stop kick", Color.white, Color.red] ]) .action = { if (kickBut.value == 1, { kick.reset; SystemClock.play(kick); }, { kick.stop; }); }; snareBut = SCButton(w, Rect(90, 23, 80, 20)) .states_([ ["Snare", Color.black, Color.green], ["Stop Snare", Color.white, Color.red] ]) .action = { if (snareBut.value == 1, { snare.reset; SystemClock.play(snare); }, { snare.stop; }); }; hatBut = SCButton(w, Rect(170, 23, 80, 20 )) .states_([ ["hihat", Color.black, Color.green], ["Stop hat", Color.white, Color.red] ]) .action = { if (hatBut.value == 1, { hihat.reset; SystemClock.play(hihat); }, { hihat.stop; }); }; leftBut = SCButton(w, Rect(250, 23, 80, 20)) .states_([ ["Left", Color.black, Color.green], ["Stop Left", Color.white, Color.red] ]) .action = { if (leftBut.value == 1, { left.reset; SystemClock.play(left); }, { left.stop; }); }; rightBut = SCButton(w, Rect(330, 23, 80, 20)) .states_([ ["Right", Color.black, Color.green], ["Stop Right", Color.white, Color.red] ]) .action = { if (rightBut.value == 1, { right.reset; SystemClock.play(right); }, { right.stop; }); }; a=Pseq([0.75, 0.25]); b=Pseq([0.75, 0.125,0.125]); c=Pseq([0.5, 0.5]); d=Pseq([0.125,0.125,0.75]); e=Pseq([0.5,0.125,0.125,0.25]); f=Pseq([0.125,0.125,0.125,0.125,0.25,0.25]); g=Pseq([0,1], inf).asStream; times=Pswitch([a,b,c,d,e,f], Prand([0,1,2,3,4,5],inf)).asStream; times2=Pswitch([e,f], Prand([0,1], inf)).asStream; pitches=Prand([0.875, 1.0, 1.2], inf).asStream; //just m7, 1, m3rd Tempo.bpm = 120; dur = Tempo.beats2secs(2); //whole left=Routine({ arg nextTime; //left chan thing OSCSched.global.tdeltaTillNext(4.0).wait; //starts on next bar loop({ nextTime= dur*times.next ; s.sendMsg(\s_new, \columbia, -1, 1, 0, \gate, 1, \time, dur*0.12, \startPos, (15.rand*150).abs.asInteger, \rate, pitches.next*4, \loopLength,(44.1e3.rand).abs.asInteger, \envLev,0.2, \panPos, (1.0.rand)-1 ); nextTime.wait; }); }); right=Routine({ arg nextTime; // right chan thing OSCSched.global.tdeltaTillNext(4.0).wait; loop({ nextTime= dur*times2.next ; s.sendMsg(\s_new, \columbia, -1, 1, 0, \gate, 1, \time, dur*0.1, \startPos, (15.rand*100).abs.asInteger, \rate, pitches.next*8, \loopLength,(5.512e3.rand).abs.asInteger, \envLev,0.3, \panPos, 1.0.rand ); nextTime.wait; }); }); hihat=Routine({ arg nextTime; //hihat OSCSched.global.tdeltaTillNext(4.0).wait; loop({ nextTime= dur*0.125 ; s.sendMsg(\s_new, \columbiaPerc, -1, 1, 0, \gate, 1, \time, dur*0.1, \startPos, 100, \rate, 25, \loopLength,5512, \envLev,times.next*0.4, \panPos, 0.25.rand2 ); nextTime.wait; }); }); kick=Routine({ arg nextTime; //kick OSCSched.global.tdeltaTillNext(4.0).wait; loop({ nextTime= dur; s.sendMsg(\s_new, \columbiaPerc, -1, 1, 0, \gate, 1, \time, dur*0.3, \startPos, 100, \rate, 0.125, \loopLength,5512, \envLev,1.0, \panPos, 0.0 ); nextTime.wait; }); }); snare=Routine({ arg nextTime; //snare OSCSched.global.tdeltaTillNext(4.0).wait; loop({ nextTime= dur*0.5; s.sendMsg(\s_new, \columbiaPerc, -1, 1, 0, \gate, 1, \time, dur*0.35, \startPos, 100, \rate, 4, \loopLength,22.5e3, \envLev,g.next, \panPos, 0.1.rand2 ); nextTime.wait; }); }); )/* authors so far: jonathan segel */ |