Created
February 7, 2015 15:40
-
-
Save zeroeth/7a6032c6f6d1bf766b0b to your computer and use it in GitHub Desktop.
Sound movement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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