// Sample-recording example for Processing V90 // Description: Records sound from the active input device into a sample object. // Instructions: Press the mouse to start recording. The recording will play back once upon mouse-release // For PC: use the 'Sounds & Audio Devices' menu in the control panel to choose your input; Mic, wave, etc. // For Mac: the current microphone device will be used as input. // By: Amit Pitaru, July 16th 2005 import pitaru.sonia_v2_9.*; // added automatically when Sonia is imported from the processing menu. Sample mySampleObj; // The Sonia Sample object which we'll record into int yes=0; int ye=250; int r=250; void setup(){ size(400,300); background(255); Sonia.start(this); LiveInput.start(); // start the liveInput engine (see liveInput example) int recTimeSec = 10; // number of seconds to record, determines the sample's max size. mySampleObj = new Sample(44100*recTimeSec); // Create an empty Sample object with 44100*10 frames (ten seconds of data). } void draw(){ smooth(); strokeWeight(5); stroke(255); fill(74,218,12,40); rect(50, 40, 300, 200); rect(60,50,280,200); fill(255,0,0,r); ellipseMode(CORNER); ellipse(88,108,100,100); fill(ye,255,0); triangle(230,208,230,108,310,158); if (keyPressed == true) { LiveInput.startRec(mySampleObj); // Record LiveInput data into the Sample object. // The recording will automatically end when all of the Sample's frames are filled with data. // r=r-2; print("REC"); yes = 1; ye=250; } if (keyPressed==false && yes==1) { live(); } } void live(){ LiveInput.stopRec(mySampleObj); mySampleObj.play(); print("PLAY"); r=250; ye=0; yes=0; } public void stop(){ Sonia.stop(); super.stop(); ye=250; }