/* From minim documentation.*/ /** * This sketch demonstrates how to use the BeatDetect object song SOUND_ENERGY mode.
* You must call detect every frame and then you can use isOnset * to track the beat of the music. *

* This sketch plays an entire song, so it may be a little slow to load. *

* For more information about Minim and additional features, * visit http://code.compartmental.net/minim/ */ import ddf.minim.*; import ddf.minim.analysis.*; Minim minim; AudioPlayer song; BeatDetect beat; float eRadius; void setup() { size(200, 200); minim = new Minim(this); song = minim.loadFile("song.mp3", 2048); song.play(); // a beat detection object song SOUND_ENERGY mode with a sensitivity of 10 milliseconds beat = new BeatDetect(); ellipseMode(RADIUS); eRadius = 20; } void draw() { background(0); beat.detect(song.mix); float a = map(eRadius, 20, 80, 60, 255); fill(60, 255, 0, a); if ( beat.isOnset() ) eRadius = 80; ellipse(width/2, height/2, eRadius, eRadius); eRadius *= 0.95; if ( eRadius < 20 ) eRadius = 20; }