import ddf.minim.*; import ddf.minim.analysis.*; String words[] = loadStrings("http://itp.nyu.edu/~gpv206/pt/chang_style/manifesto.txt"); String theWords[]; // hold the split string for multi-line text int i=0; //words index int j=6; //audio decibel scale = 6 to -45 float k=0; //fade out at end float textsizing; //variable text sizing based on audio level int startY ; AudioPlayer song; BeatDetect beat; float kickSize, snareSize, hatSize; PFont theFont; void setup() { size(640,480); // smooth(); Minim.start(this); song = Minim.loadFile("http://itp.nyu.edu/~gpv206/pt/chang_style/taiko_dance_short.mp3",1024); song.setGain(j); song.play(); // a beat detection object that is FREQ_ENERGY mode that // expects buffers the length of song's buffer size // and samples captured at songs's sample rate beat = new BeatDetect(song.bufferSize(), song.sampleRate()); // set the sensitivity to 300 milliseconds // After a beat has been detected, the algorithm will wait for 300 milliseconds // before allowing another beat to be reported. You can use this to dampen the // algorithm if it is giving too many false-positives. The default value is 10, // which is essentially no damping. If you try to set the sensitivity to a negative value, // an error will be reported and it will be set to 10 instead. beat.setSensitivity(400); theFont = loadFont("Consolas-48.vlw"); textFont(theFont); textAlign(CENTER); fill(0); } void draw() { background(255); // use the mix buffer for detection beat.detect(song.mix); if ( beat.isKick() ) { // if ( beat.isSnare() ) { //progress through text based on snare report // if ( beat.isHat() ) { i++; textsizing = 30+song.right.level()*100; //textsizing = constrain(textsizing * 0.95, 20, 50); //println(textsizing); // } } if (i >= words.length){ i=(words.length)-1; if (j > (-45)) { //AUDIO SCALE: 6 to -45dB j=j-2; k=k+15; song.setGain(j); //print("The current gain is "); //println(song.getGain()); fill(k); } else { stop(); } } fill(k); textFont(theFont); textSize(textsizing); textAlign(CENTER); theWords = split(words[i],"/"); startY = int((height - (theWords.length * textsizing))/2 + textsizing) ; for (int l = 0; l < theWords.length; l++) { text(theWords[l], width/2, startY); startY = int(startY + textsizing); } } void stop() { // always close Minim audio classes when you are finished with them song.close(); super.stop(); exit(); }