// Based on Learning Processing // Daniel Shiffman // http://www.learningprocessing.com // Example 20-1: Simple Sound Playback import processing.sound.*; SoundFile song; Amplitude amp; float threshold = 0.25; void setup() { size(640, 360); song = new SoundFile(this, "beat.aiff"); // You might get IndexOutOfBoundsException error when loading a mp3 file with mono channel //song = new SoundFile(this, "beat.mp3"); song.loop(); amp = new Amplitude(this); amp.input(song); } void draw() { background(amp.analyze()*255); //if (amp.analyze()>threshold) // background(255); //else // background(0); }