// @author HANNAH CHOI (hchoi20@ccrma) // Final ////////////////////////////// //OSC Message Receiver //1. Create OSC receiver OscRecv recv; // //2. Define receive port 12000 // This should be matched with Wekinator's output port 12000 => recv.port; // //3. Action: Start listening (launch thread) recv.listen(); // //4. Listen for this OSC message, containing one float // Event oe will be triggered whenever this message arrives. // Cautions: Match with number of parameters from Sender side (Wekinator) recv.event( "/wek/outputs, f" ) @=> OscEvent oe; // //For test, 3/4/5 inputs case //recv.event( "/wek/outputs, f f f" ) @=> OscEvent oe; //recv.event( "/wek/outputs, f f f f" ) @=> OscEvent oe; //recv.event( "/wek/outputs, f f f f f" ) @=> OscEvent oe; // //Just message. <<< "Listening: Outpus from Wekinator on port 12000 (IP:localhost), message name /wek/outputs">>>; ////////////////////////////// WvOut2 reverb_sound_echo_final; "/Users/hannahleechoi/Documents/hwfp_milestone2_submit/reverb_sound_echo_final.wav" => reverb_sound_echo_final.wavFilename; //adc => NRev rev => reverb_sound_final => dac; //With echo adc => NRev rev => reverb_sound_echo_final => Echo echo => Gain g0 => dac; //g0.gain(1);; //echo.delay(0.5::second); //echo.mix(0.5); //adc => reverb_sound_final => dac; //As it is //Set reverb/dry mixture //0.05 => rev.mix; //0.1 => rev.mix; //Real //0.5 => rev.mix; //0.9 => rev.mix; fun void waitForEvent() { // infinite event loop while ( true ) { //wait for OSC message to arrive oe => now; // grab the next message from the queue. while ( oe.nextMsg() != 0 ) { //Receive trained data from Wekinator in float oe.getFloat() => float f_cur; //0.1/0.2/0.3 //Convert the received data to integer f_cur*10 => Std.ftoi => int c;//1/2/3 //Print <<< "got (via OSC):", f_cur, "c:", c>>>; //Dynamic rev.mix control if(f_cur < 0.3) { g0.gain(0.25);; echo.delay(1.5::second); echo.mix(0.5); 0.3 => rev.mix; } else if(f_cur > 0.3 && f_cur < 0.6) { g0.gain(0.4);; echo.delay(1.5::second); echo.mix(0.5); 0.5 => rev.mix; } else { g0.gain(0.75);; echo.delay(1.5::second); echo.mix(0.5); 0.75 => rev.mix; } } 1.5 :: second => now; } } spork ~waitForEvent(); 10::hour => now; reverb_sound_echo_final.closeFile();