This applet requires the Jsyn plug-in.

Example
// 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();
}
  • carolina

    I keep on getting this error, having updated Java:

    Could not load native library for JSyn V142
    com.softsynth.jsyn.SynthException: JSyn error: Could not access JSyn synthesis engine.  -  JSyn not properly installed, or web page is not calling smart_embed_jsyn.js!, 0×0=0, 0×0=0
    com.softsynth.jsyn.SynthException: JSyn error: Could not access JSyn synthesis engine.  -  JSyn not properly installed, or web page is not calling smart_embed_jsyn.js!, 0×0=0, 0×0=0
    Exception in thread “Animation Thread” java.lang.NullPointerException
        at com.softsynth.jsyn.SynthObject.(Unknown Source)
        at com.softsynth.jsyn.SynthChannelData.(Unknown Source)
        at com.softsynth.jsyn.SynthSample.(Unknown Source)
        at com.softsynth.jsyn.SynthSample.(Unknown Source)
        at com.softsynth.jsyn.SynthSample.(Unknown Source)
        at pitaru.sonia_v2_9.LiveInput.start(LiveInput.java:88)
        at pitaru.sonia_v2_9.LiveInput.start(LiveInput.java:154)
        at pitaru.sonia_v2_9.LiveInput.start(LiveInput.java:147)
        at sketch_oct13c.setup(sketch_oct13c.java:38)
        at processing.core.PApplet.handleDraw(PApplet.java:1608)
        at processing.core.PApplet.run(PApplet.java:1530)
        at java.lang.Thread.run(Thread.java:680)
     

  • carolina

    Hi Daniel, this site makes me happy!

     

  • Anonymous

    You have to install the jsyn plug-in: http://www.softsynth.com/jsyn/plugins/.  I would recommend, however, using the Minim library instead.  For the next edition of this book all the examples will be updated for Minim.