// 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 void setup(){ size(400,200); background(0,50,0); 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(){ // do nothing } void mousePressed(){ 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. print("REC"); } void mouseReleased(){ LiveInput.stopRec(mySampleObj); mySampleObj.play(); print("PLAY"); } public void stop(){ Sonia.stop(); super.stop(); }