// *********************************************************** // "Grip Maestro" Testing Sin Wave // By, Michael Berger ~ May 2008 //MUSIC 220C ~ Research Seminar //in Computer-Generated Music // *********************************************************** //CONSTANTS //Slew every... 1::ms => dur SlewRez; //signal path SinOsc s[4]; Gain g; Pan2 p; for (0 => int i; i < 4; i++) s[i] => g => p => dac; //GLOBAL VARIABLES float a[6]; float amp, ang; 0.55 => float Gaine => float target_gaine=> float temp_gaine; float target_sGain[4]; float target_freq[4]; float temp_freq[4]; // create our OSC receiver OscRecv GripMaestro; // use port 6449 (or whatever) 6868 => GripMaestro.port; // start listening (launch thread) GripMaestro.listen(); //create an address in the receiver, store in new variable GripMaestro.event ("/GM, f f f f f f f f") @=> OscEvent @ GM; //SPORKINGS spork ~ GetGMnumbers(); spork ~ SlewifyThings(0.015, SlewRez); //FUNCTIONS //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> fun void GetGMnumbers() //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> { while (true) { GM => now; GM.nextMsg(); GM.getFloat() => a[0]; GM.getFloat() => a[1]; GM.getFloat() => a[2]; GM.getFloat() => a[3]; GM.getFloat() => a[4]; GM.getFloat() => a[5]; GM.getFloat() => amp; GM.getFloat() => ang; } } // interpolation >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> fun void SlewifyThings (float slew, dur resolution) //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> { //ADD PANNING HERE while (true) { (target_gaine - temp_gaine) * slew + temp_gaine => temp_gaine => g.gain; for (0 => int i; i < 4; i++) { (target_freq[i] - temp_freq[i]) * slew + temp_freq[i] => temp_freq[i] => s[i].freq; (target_sGain[i] - s[i].gain()) * slew + s[i].gain() => s[i].gain; } resolution => now; //time resolution of changes } } //MAIN BLOCK //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> <<< " ", "" >>>; <<< "GRIP MAESTRO - SINE OSCILLATOR APPLICATION", "" >>>; <<< "by, Michael Berger'", "" >>>; <<< "~", "" >>>; <<< "Use the GRIP MAESTRO device to control the Sounds.", "" >>>; <<< "Each finger pad controls the frequency of a Sine Oscillator.", "" >>>; <<< "The palm pad controls the volume and panning of the sounds.", "" >>>; <<< " ", "" >>>; <<< "Press CTRL+C to exit.", "" >>>; while (true) { //CONTROL amp => target_gaine; for (0 => int i; i < 4; i++) { //sends a frequency to the oscilator based on the position of each pad a[i] * 500 + (i * 500) => target_freq[i]; //volumes (amp / 2.) => target_sGain[i]; } ang => p.pan; 1::ms => now; }