import ddf.minim.analysis.*; import ddf.minim.*; Minim minim; FFT fft; AudioPlayer song; BeatDetect beat; BeatListener bl; float kickSize, snareSize, hatSize; int counter1, counter2, c; PFont font; void setup() { size(640, 480, P2D); minim = new Minim(this); minim.debugOn(); song = minim.loadFile("hny.mp3", 2048); song.play(); fft = new FFT(song.bufferSize(), song.sampleRate()); fft.linAverages(64); beat = new BeatDetect(song.bufferSize(), song.sampleRate()); beat.setSensitivity(400); kickSize = snareSize = hatSize = 16; bl = new BeatListener(beat, song); font = loadFont("Ballsontherampage-48.vlw"); textFont(font); textAlign(CENTER); } void draw() { fill(255,0,0, 40); rect(-1, -1, width+1, height+1); fill(255); if ( beat.isKick() ) { kickSize = 32; counter1 = int(random(words.length)); counter2 = int(random(hyear.length)); } if ( beat.isSnare() ) { snareSize = 32; counter1 = int(random(words.length)); } if ( beat.isHat() ) { hatSize = 32; } textSize(kickSize); text(hyear[counter2], 320, 60+fft.getAvg(5)); textSize(snareSize); text(words[counter1], 40+fft.getAvg(20)*200, height/2); textSize(hatSize); if(frameCount % 300 == 0){ c++; } if(c >= 2){ c = 0; } text(jc[c], 480, height - fft.getAvg(60)*160); kickSize = constrain(kickSize * 1.4, 16, 64); snareSize = constrain(snareSize * 1.95, 16, 36); hatSize = constrain(hatSize * 1.25, 16, 64); noFill(); stroke(255); fft.forward(song.mix); int w = int(fft.specSize()/64); for (int i = 2; i < fft.avgSize()*2-125; i++) { text("2", i*w, height - fft.getAvg(i)*4); } for (int i = 5; i < fft.avgSize()*2-122; i++) { text("0", i*w, height - fft.getAvg(i)*10); } for (int i = 8; i < fft.avgSize()*2-119; i++) { text("1", i*w, height - fft.getAvg(i)*20); } for (int i = 11; i < fft.avgSize()*2-116; i++) { text("2", i*w, height - fft.getAvg(i)*2); } for (int i = 10; i < song.bufferSize()/4 - 490; i++) { ellipse(130-i, 150-i, song.left.get(i)*120, song.right.get(i)*120); } for (int i = 112; i < song.bufferSize()/4 - 312; i+=5) { ellipse(160+i*2, 140, song.left.get(i)*120, song.right.get(i)*120); } drawEllipses(height/2); } void drawEllipses(float y1) { for (int x = 670; x > 0; x -= 50) { float r = fft.getAvg(5)*3; fill(100+r, 0, 0, 140+r*2); ellipse(x+2, y1+60, r, r); } } void stop() { song.close(); minim.stop(); super.stop(); } String[] words = { "Happy", "New", "Year", "Hallo", "Hi", "Yuppie Ai", "2012", }; String[] hyear = { "Bonne annee!", "Happy new year!", "Feliz Ano Novo!", "Buon anno!", "Mutlu Yıllar!", "La Multi Ani!", "Happy new Ears!" }; String[] jc = { "John Cage", "John's Cage" };