http://music.z0id.net/doku.php/wiki/tenori-on_playing_supercollider
//Tenori on as a Drummachine: ( MIDIPort.init; MIDIIn.connect; MIDIResponder.removeAll ) // ================= MidiResponder ======================== ( // ============= 16-SOLO - Primitive NoteOnResponder({ |src, chan, num, vel| "04-SCORE.primitive".postln; vel.postln; // Synth("Bouncer",[\note,num, \vel, vel]); }, nil, // any source [15], // midi channels nil, //any note nil); //any vel // ============= 14-BOUNCE - Bouncer NoteOnResponder({ |src, chan, num, vel| "14-BOUNCE.bouncer".postln; Synth("Bouncer",[\note,num]); }, nil, // any source [13], // midi channels nil, //any note nil); //any vel // ============= 12-DRAW - Primitive NoteOnResponder({ |src, chan, num, vel| "04-SCORE.primitive".postln; vel.postln; // Synth("Bouncer",[\note,num, \vel, vel]); }, nil, // any source [11], // midi channels nil, //any note nil); //any vel // ============= O8-RANDOM - Primitive NoteOnResponder({ |src, chan, num, vel| "04-SCORE.primitive".postln; vel.postln; // Synth("Bouncer",[\note,num, \vel, vel]); }, nil, // any source [7], // midi channels nil, //any note nil); //any vel // ============= O4-SCORE - Primitive NoteOnResponder({ |src, chan, num, vel| "04-SCORE.primitive".postln; vel.postln; // Synth("Primitive",[\note,num, \vel, vel]); }, nil, // any source [3], // midi channels nil, //any note nil); //any vel // ============= O3-SCORE - VOCALS NoteOnResponder({ |src, chan, num, vel| "vocals".postln; // Synth("speakR",[\num,num]) if (num == 60, { "SuperCollider".speak; "supercollider".postln},{ if (num == 62, { "rocks".speak;},{ if (num == 64, { "thank you for listening".speak;},{} ) } ) } ) }, nil, // any source [2], // midi channels nil, //any note nil); //any vel // ============= O1-SCORE DRUM MACHINE //Line1 NoteOnResponder({Synth("kick1";"kick".postln)}, nil, // any source [0], // first layer (60), // first line nil); //any vel //Line2 NoteOnResponder({ Synth("edlx_drum.wav"; "edlx_drum.wav".postln)}, nil, [0], (62), nil); //Line3 NoteOnResponder({Synth("clap";"clap".postln)}, nil, [0], (64), //any note nil); //any vel //Line4 NoteOnResponder( { Synth("snare";"snare".postln) }, nil, [0], (65),nil); //Line5 NoteOnResponder( { Synth("snare2";"snare2".postln) }, nil, [0], (67), nil); //Line6 NoteOnResponder( { Synth("snare3";"snare3".postln) }, nil,[0],(69),nil); //Line7 NoteOnResponder({ Synth("edlx_noise.wav"; "edlx_noise.wav".postln)}, nil, [0], (71), nil); //open: 72,74,76,77,79,81,83,84,86 ) //end of noteresponders // ================= SYNTHDEFS ========================= ( //beginning SynthDef("Primitive", { arg note = 62,out,vel=100; out = SinOsc.ar(note.midicps, mul:0.3 ); // convert midi note to frequency Out.ar([0,1], out *EnvGen.kr(Env.perc(0, 1), doneAction:2)); // has an percussive envelope, so the sound will fade to silence, then the doneAction will kill the Synth } ).load(s); //Env.perc(0, 1).plot; //Env.perc(0, 12).plot; SynthDef("Bouncer", { arg note = 62,out; "bouncer".postln; out = SinOsc.ar(note.midicps, mul:0.4 ); // convert midi note to frequency Out.ar([0,1], out *EnvGen.kr(Env.perc(0.05, 1, 1, -4), doneAction:2)); } ).load(s); //Env.cutoff(1, 1, 4).plot; //Env.perc(0.05, 1, 1, -4).plot; SynthDef("kick1", { |basefreq = 50, envratio = 3, freqdecay = 0.02, ampdecay = 0.5| var fenv = EnvGen.kr(Env([envratio, 1], [freqdecay], \exp), 1) * basefreq, aenv = EnvGen.kr(Env.perc(0.005, ampdecay), 1, doneAction:2), out; out = SinOsc.ar(fenv.dup, 0.5pi, aenv); Out.ar([0,1] ,out); }).load(s); SynthDef(\snare, { |freq=100, sustain=5, amp=0.1| var mod, sound, env, saw, filter; //mod = XLine.kr(freq*1,freq,sustain); von freq nach freq env = EnvGen.ar(Env.perc(0.04, sustain,amp*10,-60),doneAction:2); //amp*10 statt 1 saw = WhiteNoise.ar(0.06 * [1,1]) * Saw.ar(10 * [1,1]).sum; //sum? filter = BPF.ar(saw, LFNoise1.kr(0.1).exprange(5000, 20000), 0.9); //sound = SinOsc.ar(mod,0,amp.dup); keine amp Out.ar(0, filter * env); }; ).load(s); SynthDef(\snare2, { |sustain=3, amp=0.5, freq=20, hard=0| var sound, env, env2; env = EnvGen.ar(Env.perc(0.025, sustain*(1-hard), 1, -12)); env2 = EnvGen.ar(Env.perc(0.05, sustain*1.5), doneAction: 2); sound = Decay.ar(Impulse.ar(0), 0.00072, WhiteNoise.ar(amp.dup)) + WhiteNoise.ar(0.1).dup; sound = sound * env; sound = CombL.ar(sound, freq.reciprocal, freq.reciprocal, sustain); Out.ar(0, sound * env2); }; ).load(s); SynthDef(\snare3, { |sustain=3, amp=0.5, freq=20, hard=0| var sound, env, env2; env = EnvGen.ar(Env.perc(0, sustain*(1-hard), 1, -12)); env2 = EnvGen.ar(Env.perc(0, sustain*1.5), doneAction: 2); sound = Decay.ar(Impulse.ar(0), sustain * 0.1, GrayNoise.ar([1, 1] * 0.3), WhiteNoise.ar(0.1.dup) + 0.3); sound = sound * (LFSaw.ar(Rand(5, 10)).max(0) + 1) * (env * amp); Out.ar(0, sound * env2); }; ).load(s); //Clap SynthDef(\clap, { |freq=100, sustain=5, amp=0.1| var mod, sound, env, saw, filter; mod = XLine.kr(freq*1,freq,sustain); env = EnvGen.ar(Env.perc(0.02, sustain,1,-200),doneAction:2); saw = LFPulse.kr(0.6,0,0.5) * WhiteNoise.ar(0.07 * [1,1]) * Saw.ar(1000 * [1,1]).sum; filter = BPF.ar(saw, LFNoise1.kr(0.1).exprange(10000, 20000), 0.9); sound = SinOsc.ar(mod,0,amp.dup); Out.ar(0, filter * env); }; ).load(s); )//end of synthdefs //============== CONCRETE SOUNDS ============================== ( //beginning of concrete sounds b = Buffer.read(s,"/Users/meatz/tmp/edlx_drum.wav"); SynthDef("edlx_drum.wav", { arg out=0,bufnum= 0; //b.bufnum; Out.ar(out, PlayBuf.ar(2, bufnum, BufRateScale.kr(bufnum), doneAction:2) ) }).load(s); c = Buffer.read(s,"/Users/meatz/tmp/edlx_noise.wav"); SynthDef("edlx_noise.wav", { arg out=0,bufnum= 1; //c.bufnum; Out.ar(out, 0.5 * PlayBuf.ar(2, bufnum, BufRateScale.kr(bufnum), doneAction:2) //0.5* == 50% volume ) }).load(s); )//end of concrete sounds //====================EXPERIMENTAL - PUSH - only one sound ============= SynthDef("Push", { arg note = 62,out,vel=100; out = SinOsc.ar(note.midicps, mul:0.3 ); // convert midi note to frequency Out.ar([0,1], out); } ).load(s); ( NoteOnResponder({ |src, chan, num, vel | "PUSH-NoteOn".postln; p = Synth("Push",[\note,num]); }, nil, // any source [14], // midi channel 1 nil, //any node nil); ) NoteOffResponder({ |src, chan, num, vel| "PUSH-NoteOff".postln; p.free; }, nil, // any source [14], // midi channel 1 nil, //any node nil);