// Ball reacting to Sound import ddf.minim.*; AudioInput in; float x; float y; float targetX, targetY; float easing = 0.01; void setup() { Minim.start(this); in = Minim.getLineIn(Minim.MONO, 512); size(1024, 768); smooth(); noStroke(); float x = 0.0; float y = 0.0; } void draw() { background( 51 ); targetX = random(abs(in.left.get(1)*1000)+50, abs(in.left.get(1)*1000)-50); float dx = targetX - x; if(abs(dx) > 1) { x += dx * easing; } targetY = random(abs(in.left.get(1)*1000)+50, abs(in.left.get(1)*1000)-50); float dy = targetY - y; if(abs(dy) > 1) { y += dy * easing; } fill(255); ellipse((width/2)+x, (height/2)-y, max(300-x, 0), max(300-x, 0)); fill(255, 0, 0); ellipse(abs(in.left.get(1)*1000), abs(in.left.get(1)*1000), 5, 5); } void stop() { in.close(); Minim.stop(); super.stop(); }