// create our OSC receiver OscIn oscin; // a thing to retrieve message contents OscMsg msg; // use port 12000 (default Wekinator output port) 12000 => oscin.port; // listen for "/wek/output" message with 1 floats coming in oscin.addAddress( "/wek/outputs, f" ); // print <<< "listening for OSC message from Wekinator on port 12000...", "" >>>; // synthesis patch SqrOsc sqr => dac; SinOsc sin => dac; 0 => sqr.gain; 0 => sin.gain; 0 => float f; fun void waitForEvent() { while( true ) { // wait for event to arrive oscin => now; // grab the next message from the queue. while (oscin.recv(msg)) { msg.getFloat(0) => f; } } } fun void play() { while(true) { 500 => int speed; if (f == 1) { <<< "1 : NOTHING", "" >>>; 0 => sin.gain; 0 => sqr.gain; 500 => speed; } else if (f == 2) { <<< "2 : SQUARE", "" >>>; [65.41,73.42, 82.41, 98.00, 110] @=> float freqs[]; .15 => sqr.gain; 0 => sin.gain; Math.random2(0,4) => int my_choice; freqs[my_choice] => sqr.freq; 500 => speed; } else if (f == 3) { <<< "3 : SIN", "" >>>; [65.41,73.42, 82.41, 98.00, 110] @=> float freqs2[]; 1.5 => sin.gain; 0 => sqr.gain; Math.random2(0,4) => int my_choice2; freqs2[my_choice2] => sin.freq; 250 => speed; } speed::ms => now; } } // spork osc receiver loop spork ~waitForEvent(); spork ~play(); // time loop to keep everything going while( true ) { //<<< f >>>; 1::second => now; }