topical media & game development
graphic-processing-learning-20-example-20-5-example-20-5.pde / pde
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 20-5: Live Input with Sonia
// Import the Sonia library
import pitaru.sonia_v2_9.*;
void setup() {
size(200,200);
smooth();
Sonia.start(this);
// Start listening to the microphone
// All functions for sound input are static, meaning they are called from the class name itself, LiveInput, rather than an object instance.
LiveInput.start();
}
void draw() {
background(255,120,0);
// Get the overall volume (between 0 and 1.0)
float level = LiveInput.getLevel();
fill(200);
stroke(50);
// Draw an ellipse with size based on volume
ellipse(width/2,height/2,level*200,level*200);
}
// Close the sound engine
public void stop() {
Sonia.stop();
super.stop();
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.