import ddf.minim.*; import ddf.minim.analysis.*; String words[] = { " "," ","I", "have", "to", "walk", "the", "distance", "my", "wingsuit", "crumbled", "opart", "in", "a","Martian", "blizzard", "a", "great", "thunderbolt,", "seared,", "my", "taffeta", "dress", "I", "am", "sooty", "covered", "in", "martian", "dust", "My", "hair", "is", "rumpled", "I", "look","down", "the", "edge", "of", "the", "canyon", "In", "the", "abyss", "is", "a", "pile","of", "dark", "heavy", "hearts", "They", "have", "sunk", "to", "the", "bottom", "Unable", "to", "carry", "their", "own", "weight", "and", "daunted", "by", "the", "journey", "they", "have", "collapsed", "like", "tarps", "to", "cinder", "in", "the", "Martian", "heat", "A", "force", "from", "miles", "away", "propels", "me", "forward", "at", "such", "a", "hurtling", "speed", "I", "sear", "through", "a", "glass", " pane", "and", "emerge", "on", "the", "other", "side", "shaken", "and", "bleeding", "badly", "Gravity", "pulls", "The", "gusts", "tear", "at", "me", "I", "fight...", "The", "canyon","is", "rumbling", "rocky", "road", "chunks", "crumble...", "at", "my", "feet", "A", "boulder", "chases", "me", "In", "the", "time", "it", "takes", "Chanel", "Number", "5", "to", "evaporate", "off", "my", "skin", "I", "will", "reach", "you", "and", "when", "I", "do", "it", "will", "be", "combustion", "I","am","weary", "tattered", "and", "hurt", "The", "sun", "makes", "loops", "around", "my", "head", "and", "drenches", "me", "in", "a", "blazing", "red", "glow", "martian", "flies", "hover", "around", "me", "I", "am", "firelit", "and", "hot", "I", "take", "a", "dip", "in", "the", "pheromone", "pool", "The", "night", "is", "long", "on", "this", "side", "of", "Mars." }; 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 AudioPlayer song; BeatDetect beat; float kickSize, snareSize, hatSize; void setup() { size(1024, 768); smooth(); Minim.start(this); song = Minim.loadFile("the way you dream - edit.mp3"); //song = Minim.loadFile("sixandfour.mp3"); 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(250); textFont(createFont("Monaco", 12)); textAlign(CENTER); fill(0); } void draw() { background(255); // use the mix buffer for detection beat.detect(song.mix); //print("words length: "); //println(words.length); //print("i: "); //println(i); // if ( beat.isKick() ) { //if ( beat.isSnare() ) { //progress through text based on snare report if (song.position () < 10000) { if ( beat.isHat() ) { i++; textsizing = (i/2.5)+15+song.right.level()*200; //textsizing = constrain(textsizing * 0.95, 20, 50); //println(textsizing); // } } else { if ( beat.isKick() ) { i++; textsizing = (i/2.5)+15+song.right.level()*200; //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); text(words[i], width/2, height/2); } else { stop(); } } textSize(textsizing); text(words[i], width/2, height/2); } } void stop() { // always close Minim audio classes when you are finished with them song.close(); super.stop(); exit(); }