// title: Pushing air // author: coreyker // description: // code for disquiet 0050 project: http://disquiet.com/2012/12/13/disquiet0050-morsebeat/ // listen here: http://soundcloud.com/inlet/pushing-air-disquiet0050 // code: /* 0050 "pushing air" => ".--. ..- ... .... .. -. --. / .- .. .-." */ ~morsestr = ".--. ..- ... .... .. -. --. / .- .. .-. / "; ~ctlbus1 = Bus.control(s); MIDIIn.connectAll; ( SynthDef(\perc, {|freq=280| var ampEnv, snd, attack, release, sat, mod; release = 3; attack = ~ctlbus1.kr; sat = -2; mod = SinOsc.ar(4, 0, 2); ampEnv = EnvGen.ar(Env.perc(attack, release, 1), doneAction:2); snd = ampEnv * SinOsc.ar([freq, (1.005*freq)+mod], [Rand(0,3.14),Rand(0,3.14)]); snd = 2/(1 + (sat*snd).exp) - 1; Out.ar(0,snd); }).add; ) ~t = TempoClock.new; ~t.tempo = 3; Tdef(\morse).play(~t); ( MIDIdef.cc(\attackTime, {|val, num, chan, src| var attackTime; attackTime = val.linlin(0,127,0,2); ~ctlbus1.set(attackTime); ("attackTime: " ++ attackTime).postln; },2); MIDIdef.cc(\tempo, {|val, num, chan, src| var index; var tempoArray = [3,6,12]; index = val.linlin(0,127,0,2); ~t.tempo = val.linlin(0,127,1,12);//tempoArray[index]; val.linlin(0,127,1,12).postln;//tempoArray[index].postln; },14); ) ( Tdef(\morse, { inf.do{ |i| var f0 = 180 * (2**(0/12)); var freq = 2**(([-7,-3,0,2,5,9,12].choose)/12) * f0; var char = ~morsestr.wrapAt(i).asString; switch(char, ".", { ".".post; //x = Synth(\default); x = Synth(\perc, [\freq, freq]); 1.wait; //x.release; }, "-", { "-".post; //x = Synth(\default); x = Synth(\perc, [\freq, freq]); 3.wait; //x.release; }, " ", { " ".post; 1.wait; }, "/", { "/".post; 3.wait; }, {}); }; }) ) Tdef(\morse).reset; Tdef(\morse).pause; Tdef(\morse).stop;