// by Les Hall // global variables second/6.0 => dur interval; // note time quantization 0.5 => float alpha; // averaging time constant // instantiate classes SPACEY spacey; spacey.output => dac; PHASER phaser; phaser.output => dac; // space music class class SPACEY { // variables 2 => int zeroes; // number of bins to zero out // our patch IFFT ifft; 1024 => ifft.size; Windowing.hamming(ifft.size()/2) => ifft.window; // // band pass filters 16 => int n; LPF lpf[n]; Gain sum; for (int i; i lpf[i] => sum; Math.rand2f(20, 2000) => lpf[i].freq; } 0.1 / n => sum.gain; sum => Gain output; // // pitshift delay thang sum => PitShift ps1 => Gain boost => output; ps1 => DelayA delay1 => ps1; 1.0 => ps1.mix; 1.0 => ps1.shift; 0.5 => ps1.gain; second => delay1.max; 10::ms => delay1.delay; 2.0 => boost.gain; // use this to hold contents complex s[ifft.size()/2]; fun void timeLoop() { while( true ) { // select a random frequency Math.rand2(1, ifft.size()/2-1) => int freqBin; // randomly set the frequency Math.rand2f(0.0, 0.5 / Math.pow(freqBin + 1, 0.33) ) $ complex => s[freqBin]; // repeat zero-out for (int i; i freqBin; // zero out the frequency 0 $ complex => s[freqBin]; } // select a random filter Math.rand2(0, n - 1) => int filter; // randomly walk the filter lpf[filter].freq() + Math.rand2(-1, 1) * Math.rand2f(0.0, 0.1) * lpf[filter].freq() => float freq; if (freq < 100.0) { 1000.0 => freq; } else if (freq > 2000) { 1000 => freq; } freq => lpf[filter].freq; // take ifft ifft.transform(s); // advance time (ifft.size()/2)::samp => now; } } spork ~ timeLoop(); } // phaser from Kassen Oud, modified by Les Hall class PHASER { SubNoise s => Gain output; 0 => s.gain; // spork blaster() to fire phaser once fun void blast() { 0.05 => s.gain; 0 => int n; while (n<500) { n++ => s.rate; 10::ms=>now; } 0 => s.gain; } } // number of the device to open (see: chuck --probe) 0 => int device; // get command line if( me.args() ) me.arg(0) => Std.atoi => device; // the midi event MidiIn min; // the message for retrieving data MidiMsg msg; // open the device if( !min.open( device ) ) me.exit(); // print out device that was opened <<< "MIDI device:", min.num(), " -> ", min.name() >>>; // infinite time-loop while( true ) { // wait on the event 'min' min => now; while(min.recv(msg) ) { // get the message(s) msg.data1 => int mgg1; msg.data2 => int channel; msg.data3 => int data; // do something with the message(s) if (channel == 0) // pitch { (data / 127.0) + 0.5 => spacey.ps1.shift; } else if (channel == 1) // roll { } else if (channel == 2) // yaw { (data / 127.0) * 100::ms => spacey.delay1.delay; } else if (channel == 3) // accel { } else if (channel == 10) // a button { } else if (channel == 11) // b button { spork ~ phaser.blast(); } else if (channel == 12) // down button { } else if (channel == 14) // left button { } else if (channel == 17) // right button { } else if (channel == 18) // up button { } else if (channel == 32) // pitch { ( (1.0 - data / 127.0) * 10.0) $ int => spacey.zeroes; } else if (channel == 33) // roll { } else if (channel == 34) // yaw { } else if (channel == 35) // accel { } else if (channel == 42) // a button { } else if (channel == 48) // b button { spork ~ phaser.blast(); } else if (channel == 44) // down button { } else if (channel == 46) // left button { } else if (channel == 49) // right button { } else if (channel == 50) // up button { } } }