128x-fall-2008
Contents
SLOrk 2009
Lights and Levitation
- Andy, Mikael, David
Networking
- Craig, Isak, David
Platform
- Craig, Mikael(--)
Notation
- Leah, Rob, Jieun
Dancer
- Visda
Live Coding
Pieces
Feel free to submit introductory tutorials or suggestions regarding performance for any of the pieces currently in the Slork repertoire. Not only could many of last year's members use a refresher in the control-systems and subtleties of each very different piece, but to new members struggling with putting all the pieces together, these basic comments can get the ball rolling.
Take it for Granite
by Perry Cook
To start, open a terminal window and type: "granite". A simple GUI with three horizontal sliders and a single button will open and you will hear a crackling sound (you will also hear a few percussive beats but that's a bug, isn't it? ) Move the sliders to the right and you'll hear changes in amplitude of the crackling sound (top slider), pitch of the crackling sound (middle slider), and density of the drum-like percussive beats (bottom slider). Pressing the button labled "Sync Pattern" will output a strong pulse, grounding the rhythmic pattern temporarily to your beat.
======
// get input to which channel to send sound me.arg(0) => Std.atoi => int channel; 2 => int device; MidiIn min; MidiMsg msg; if( !min.open(device) ) me.exit(); <<< "MIDI device:", min.num(), " -> ", min.name() >>>;
// open keyboard (get device number from command line) //if( !hi.openKeyboard( device ) ) me.exit(); //<<< "keyboard '" + hi.name() + "' ready", "" >>>;
// the patch SndBuf buf => Envelope e => ADSR masterEnv => dac.chan(channel); //SndBuf buf => Envelope e => JCRev rev => dac.chan(channel);
me.arg(1) => buf.read; 1 => buf.loop; (buf.length() / samp) / 127 => float grain_multiplier; //80 => float grain_duration; 800 => float grain_duration; 5.0 => float rand_grain_duration; 1 => int position; 1.0 => float pitch; 0 => int rand_position; //0.0 => float rand_pitch; 0.0 => float pause; 20.0 => float rand_pitch;
float position_target; float position_knob; float fineposition_knob; 1.0 => float pitch_target; 1.0 => float gain_target => buf.gain; int position_range;
int samples; buf.samples() => samples; grain_duration*0.5::ms => e.duration;
int midiMsg1[44]; int midiMsg2[44]; initMidiMsg();
fun void grain() { // can be changed to acheive a more varying // asynchronous envelope for each grain duration
0.0 => float grain_length; while( true ) { Std.rand2f(Math.max(1.0,grain_duration-rand_grain_duration),grain_duration+rand_grain_duration) => grain_length; grain_length*0.5::ms => e.duration; Std.rand2f(Math.max(0.0625,pitch-rand_pitch),pitch+rand_pitch) => buf.rate; Std.rand2(Math.max(1,position-rand_position) $ int, Math.min(samples,position+rand_position) $ int) => buf.pos; e.keyOn(); grain_length*0.5::ms => now; e.keyOff(); grain_length*0.5::ms => now; // 0.0 => buf.gain; pause::ms => now; } }
// position interpolation fun void ramp_position() { 2.0 * (samples) $ float / 10.0 => float thresh;
0.005 => float slew;
while (1) { if(Std.fabs(position - position_target) > samples/5) { 1.0 => slew; } else { 0.005 => slew; } ((position_target - position) * slew + position) $ int => position;
1 :: ms => now; } }
// pitch interpolation
fun void ramp_pitch()
{
0.05 => float slew;
while (1)
{
((pitch_target - pitch) * slew + pitch) => pitch;
5 :: ms => now;
}
}
// volume interpolation fun void ramp_gain() { 0.05 => float slew; while (1) { ((gain_target - buf.gain()) * slew + buf.gain()) => buf.gain; 10 :: ms => now; } }
// setup midimessagevalues fun void initMidiMsg() {
224 => midiMsg1[0]; 0 => midiMsg2[0]; // F1 slider 176 => midiMsg1[1]; 1 => midiMsg2[1]; // F2 slider 176 => midiMsg1[2]; 7 => midiMsg2[2]; // F3 slider 176 => midiMsg1[3]; 8 => midiMsg2[3]; // F4 slider 176 => midiMsg1[4]; 9 => midiMsg2[4]; // C1 knob 176 => midiMsg1[5]; 10 => midiMsg2[5]; // C2 knob 176 => midiMsg1[6]; 11 => midiMsg2[6]; // C3 knob 176 => midiMsg1[7]; 12 => midiMsg2[7]; // C4 knob 176 => midiMsg1[8]; 13 => midiMsg2[8]; // C5 knob 176 => midiMsg1[9]; 14 => midiMsg2[9]; // C6 knob 176 => midiMsg1[10]; 15 => midiMsg2[10]; // C7 knob 176 => midiMsg1[11]; 16 => midiMsg2[11]; // C8 knob 144 => midiMsg1[12]; 36 => midiMsg2[12]; // P1 pad, note 176 => midiMsg1[13]; 100 => midiMsg2[13]; // P1 pad, aftertouch 144 => midiMsg1[14]; 38 => midiMsg2[14]; // P2 pad, note 176 => midiMsg1[15]; 101 => midiMsg2[15]; // P2 pad, aftertouch 144 => midiMsg1[16]; 40 => midiMsg2[16]; // P3 pad, note 176 => midiMsg1[17]; 102 => midiMsg2[17]; // P3 pad, aftertouch 144 => midiMsg1[18]; 41 => midiMsg2[18]; // P4 pad, note 176 => midiMsg1[19]; 103 => midiMsg2[19]; // P4 pad, aftertouch 144 => midiMsg1[20]; 43 => midiMsg2[20]; // P5 pad, note 176 => midiMsg1[21]; 104 => midiMsg2[21]; // P5 pad, aftertouch 144 => midiMsg1[22]; 45 => midiMsg2[22]; // P6 pad, note 176 => midiMsg1[23]; 105 => midiMsg2[23]; // P6 pad, aftertouch 144 => midiMsg1[24]; 47 => midiMsg2[24]; // P7 pad, note 176 => midiMsg1[25]; 106 => midiMsg2[25]; // P7 pad, aftertouch 144 => midiMsg1[26]; 48 => midiMsg2[26]; // P8 pad, note 176 => midiMsg1[27]; 107 => midiMsg2[27]; // P8 pad, aftertouch 144 => midiMsg1[28]; 50 => midiMsg2[28]; // P9 pad, note 176 => midiMsg1[29]; 108 => midiMsg2[29]; // P9 pad, aftertouch 144 => midiMsg1[30]; 52 => midiMsg2[30]; // P10 pad, note 176 => midiMsg1[31]; 109 => midiMsg2[31]; // P10 pad, aftertouch 144 => midiMsg1[32]; 53 => midiMsg2[32]; // P11 pad, note 176 => midiMsg1[33]; 110 => midiMsg2[33]; // P11 pad, aftertouch 144 => midiMsg1[34]; 55 => midiMsg2[34]; // P12 pad, note 176 => midiMsg1[35]; 111 => midiMsg2[35]; // P12 pad, aftertouch 144 => midiMsg1[36]; 57 => midiMsg2[36]; // P13 pad, note 176 => midiMsg1[37]; 112 => midiMsg2[37]; // 13 pad, aftertouch 144 => midiMsg1[38]; 59 => midiMsg2[38]; // P14 pad, note 176 => midiMsg1[39]; 113 => midiMsg2[39]; // P14 pad, aftertouch 144 => midiMsg1[40]; 60 => midiMsg2[40]; // P15 pad, note 176 => midiMsg1[41]; 114 => midiMsg2[41]; // P15 pad, aftertouch 144 => midiMsg1[42]; 62 => midiMsg2[42]; // P16 pad, note 176 => midiMsg1[43]; 115 => midiMsg2[43]; // P16 pad, aftertouch
}
spork ~ grain();
spork ~ ramp_position();
spork ~ ramp_pitch();
spork ~ ramp_gain();
0.0 => float temp_gain; me.arg(2) => Std.atoi => int t;
if(t == 0) { // infinite event loop while( true ) {
min => now; while( min.recv(msg) ) { <<<msg.data1>>>; if ( msg.data1 == 144 ) { if (msg.data3 > 0) { masterEnv.keyOn(); } else { masterEnv.keyOff(); } }
// slider f1 => Position Macro if( msg.data1 == midiMsg1[0] && msg.data2 == midiMsg2[0] ) { (msg.data3 / 127.) * samples => position_knob; position_knob + fineposition_knob=> position_target; <<< "Position Target = ", position_target >>>; } // slider f2 => Position Micro else if( msg.data1 == midiMsg1[1] && msg.data2 == midiMsg2[1] ) { ((msg.data3/127.) * (samples/127.)) => fineposition_knob; position_knob + fineposition_knob=> position_target; <<< "Position Target = ", position_target >>>;
} // slider f3 => Grain Size else if( msg.data1 == midiMsg1[2] && msg.data2 == midiMsg2[2] ) { 8+ (msg.data3 / 127.) * ((buf.length()/samp)/127.) => grain_multiplier; <<< "Grain Duration Multiplier = ", grain_multiplier>>>; Math.fabs(Math.log(127./((127-msg.data3)+1))) * grain_multiplier $ float => grain_duration; grain_duration*0.5::ms => e.duration;
<<< "Grain Duration = ", grain_duration>>>;
} // slider f4 => Grain Size Micro else if( msg.data1 == midiMsg1[3] && msg.data2 == midiMsg2[3] ) { Math.fabs(Math.log(127./((127-msg.data3)+1))) * grain_multiplier $ float + 1 => grain_duration; grain_duration*0.5::ms => e.duration;
<<< "Grain Duration = ", grain_duration>>>; } // KNOBS // knob C1 - random duration else if( msg.data1 == midiMsg1[4] && msg.data2 == midiMsg2[4] ) { (msg.data3/ 127.) * 2000 => rand_grain_duration; <<< "Random Grain Duration = ", rand_grain_duration >>>; } // knob C2 - pitch else if( msg.data1 == midiMsg1[5] && msg.data2 == midiMsg2[5] ) { (msg.data3 / 127.) * 6 => pitch_target; <<< "Pitch Target = ", pitch_target >>>; }
// knob C3 Master release else if( msg.data1 == midiMsg1[6] && msg.data2 == midiMsg2[6] ) { ((msg.data3 / 127.) * 5)::second => masterEnv.releaseTime; <<< "Master Release = ", masterEnv.releaseTime() >>>; } // knob C4 Position Range else if( msg.data1 == midiMsg1[7] && msg.data2 == midiMsg2[7] ) { Math.round((msg.data3 / 127.) * (samples/4.)) $ int => position_range; } // knob C5 else if( msg.data1 == midiMsg1[8] && msg.data2 == midiMsg2[8] ) { ( (msg.data3 / 127.) * samples/16 ) $ int => rand_position; <<< "Random Position = ", rand_position >>>;
} // knob C6 - Random Pitch else if( msg.data1 == midiMsg1[9] && msg.data2 == midiMsg2[9] ) { ((msg.data3/ 127.) * 100) => rand_pitch; <<< "Random Pitch = ", rand_pitch >>>;
} // knob C7 - Aftertouch Mode else if( msg.data1 == midiMsg1[10] && msg.data2 == midiMsg2[10] ) { } // knob C8 else if( msg.data1 == midiMsg1[11] && msg.data2 == midiMsg2[11] ) { (msg.data3/127.) * 3 $ float => gain_target; <<< "Gain = ", gain_target >>>; } // PADS else if( msg.data1 == midiMsg1[12] && msg.data2 == midiMsg2[12] ) { pitch - 1.0 / 12 => pitch_target => pitch; <<< "Pitch Target = ", pitch >>>; } else if( msg.data1 == midiMsg1[13] && msg.data2 == midiMsg2[13] ) { // <<< "Pad P1 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[14] && msg.data2 == midiMsg2[14] ) { pitch + 1.0 / 12 => pitch_target => pitch;
<<< "Pitch Target = ", pitch >>>; } else if( msg.data1 == midiMsg1[15] && msg.data2 == midiMsg2[15] ) { // <<< "Pad P2 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[16] && msg.data2 == midiMsg2[16] ) { (Math.max(200.0, rand_position - 500.0)) $ int => rand_position; <<< "Rand Position = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[17] && msg.data2 == midiMsg2[17] ) {
// <<< "Pad P3 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[18] && msg.data2 == midiMsg2[18] ) { (Math.min(samples, rand_position + 500)) $ int => rand_position; <<< "Rand Position = ", msg.data3 >>>;
} else if( msg.data1 == midiMsg1[19] && msg.data2 == midiMsg2[19] ) { // <<< "Pad P4 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[20] && msg.data2 == midiMsg2[20] ) { 1.0 => pitch_target; // <<< "Pad P5 note = ", msg.data3 >>>; <<< "Pitch", pitch_target >>>; } else if( msg.data1 == midiMsg1[21] && msg.data2 == midiMsg2[21] ) { //<<< "Pad P5 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[22] && msg.data2 == midiMsg2[22] ) { 0.75 => pitch_target; <<< "Pitch", pitch_target >>>; }
else if( msg.data1 == midiMsg1[23] && msg.data2 == midiMsg2[23] ) { //<<< "Pad P6 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[24] && msg.data2 == midiMsg2[24] ) { 0.5 => pitch_target; <<< "Pitch", pitch_target >>>; } else if( msg.data1 == midiMsg1[25] && msg.data2 == midiMsg2[25] ) { //<<< "Pad P7 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[26] && msg.data2 == midiMsg2[26] ) { 0.25 => pitch_target; <<< "Pitch", pitch_target >>>; } else if( msg.data1 == midiMsg1[27] && msg.data2 == midiMsg2[27] ) { //<<< "Pad P8 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[28] && msg.data2 == midiMsg2[28] ) { 0.125 => pitch_target; <<< "Pitch", pitch_target >>>; } else if( msg.data1 == midiMsg1[29] && msg.data2 == midiMsg2[29] ) { // <<< "Pad P9 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[30] && msg.data2 == midiMsg2[30] ) { 2 => pitch_target; <<< "Pitch", pitch_target >>>; } else if( msg.data1 == midiMsg1[31] && msg.data2 == midiMsg2[31] ) {
//<<< "Pad P10 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[32] && msg.data2 == midiMsg2[32] ) { 4 => pitch_target; <<< "Pitch", pitch_target >>>; } else if( msg.data1 == midiMsg1[33] && msg.data2 == midiMsg2[33] ) { //<<< "Pad P11 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[34] && msg.data2 == midiMsg2[34] ) { 8 => pitch_target; <<< "Pitch", pitch_target >>>; } else if( msg.data1 == midiMsg1[35] && msg.data2 == midiMsg2[35] ) { //<<< "Pad P12 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[36] && msg.data2 == midiMsg2[36] ) { 16 => pitch_target; <<< "Pitch", pitch_target >>>; } else if( msg.data1 == midiMsg1[37] && msg.data2 == midiMsg2[37] ) { //<<< "Pad P13 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[38] && msg.data2 == midiMsg2[38] ) { <<< "Pad P14 note = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[39] && msg.data2 == midiMsg2[39] ) { //<<< "Pad P14 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[40] && msg.data2 == midiMsg2[40] ) { Math.min(samples, position + 11025) => position_target; <<< "Pad P15 note = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[41] && msg.data2 == midiMsg2[41] ) { //<<< "Pad P15 aftertouch = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[42] && msg.data2 == midiMsg2[42] ) { Math.max(1, position - 11025) => position_target; <<< "Pad P16 note = ", msg.data3 >>>; } else if( msg.data1 == midiMsg1[43] && msg.data2 == midiMsg2[43] ) { //<<< "Pad P16 aftertouch = ", msg.data3 >>>; } else { <<< "unassigned midi message: ", msg.data1, msg.data2, msg.data3 >>>; } }
// wait on event
}
}