Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Created February 7, 2015 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroeth/7a6032c6f6d1bf766b0b to your computer and use it in GitHub Desktop.
Save zeroeth/7a6032c6f6d1bf766b0b to your computer and use it in GitHub Desktop.
Sound movement
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioPlayer jingle;
FFT fftLin;
PFont font;
void setup()
{
size(600, 200);
minim = new Minim(this);
jingle = minim.loadFile("your song.mp3", 1024);
jingle.loop();
fftLin = new FFT( jingle.bufferSize(), jingle.sampleRate() );
// Set the number of 'sounds' to get from the music, low to high frequency.
fftLin.linAverages( 30 );
rectMode(CENTER);
noStroke();
}
void draw()
{
background(0);
fill(255);
fftLin.forward( jingle.mix );
pushMatrix();
translate(100,100);
scale(fftLin.getAvg(0));
rect(0,0,1,1);
popMatrix();
pushMatrix();
translate(300,100);
rotate(fftLin.getAvg(2)/20);
scale(100);
rect(0,0,1,1);
popMatrix();
pushMatrix();
translate(500,100);
fill(fftLin.getAvg(2)*100);
scale(100);
rect(0,0,1,1);
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment