«SuperSimpleSequencer» by rukano
on 19 Jun'12 02:00 inJust for fun and a demonstration of gui/2Darrays/synths/tasks in less than 30 lines.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
SynthDef(\peep,{|freq=100| var snd = SinOsc.ar(freq); snd = snd * EnvGen.ar(Env.perc(0.001,0.25), doneAction:2); Out.ar(0, snd ! 2); }).add; w = Window("sequencer", Rect(0, 0, 400, 200)).front; a = 0!16!8; a.do{ |rows, i| rows.do{ |cell, j| Button(w, Rect(j*25, i*25, 25, 25)) .states_([ ["-", Color.black, Color.white], ["O", Color.white, Color.black], ]) .action_{ |v| a[i][j] = v.value; }; }; }; Ppar(a.collect({|c, r| Pbind( \instrument, \peep, \freq, Pif(Pseq(a[r], inf).coin, 100+(a.size-100*r), \rest), \dur, 0.25 )}), inf).play;
reception
Thanks! that's a good one!
Hey !
Thanks you for this code ! I have tried to modified this for my own code but i have not realy understand the collect and Ppar function.
My code but doesn't work: (if you have any idea for correct this your welcome :D):
w = Window("sequencer", Rect(0, 0, 400, 200)).front;
a = 16; a.do{| freq, i| NumberBox(w, Rect(i*25, 0, 25, 25)) .action_{ |v| a[i] = v.value; }; };
b = 16; b.do{| gate, i | Button(w, Rect(i*25, 25, 25, 25)) .states_([ ["0", Color.black, Color.white], ["1", Color.white, Color.black], ]) .action_{ |v| b[i] = v.value; }; };
Ppar([ a.collect({|c, r| Pbind( \instrument, \peep, \freq, Pseq(a[r], inf), \dur, 0.25 ) }), b.collect({|c, r| Pbind( \instrument, \peep, \freq, Pif(Pseq(b[r], inf).coin, 1, 0), \dur, 0.25 ) })] , inf).play;