import ddf.minim.*; import ddf.minim.signals.*; import ddf.minim.analysis.*; import ddf.minim.effects.*; Minim minim; AudioPlayer sound; float currL = 0; PFont f; String message = "I feel like I'm taking crazy pills! I invented the piano key necktie, I invented it! What have you done, Derek? Nothing! You've done nothing! NOTHING!"; // An array of Letter objects Letter[] letters; void setup() { size(1250, 200); // Load the font f = createFont("Arial", 18, true); textFont(f); minim = new Minim(this); sound = minim.loadFile("Mugatu.mp3", 512); sound.play(); smooth(); // Create the array the same size as the String letters = new Letter[message.length()]; // Initialize Letters at the correct x location int x = 16; for (int i = 0; i < message.length(); i++) { letters[i] = new Letter(x, 100, message.charAt(i)); x += textWidth(message.charAt(i)); } } void draw() { background(85, 138, 48); for (int i = 0; i < letters.length; i++) { // Display all letters letters[i].display(); float amp = sound.mix.level(); // how loud something is if (amp > 0.05) { for (int j = (int)currL; j < currL+3; j++) { if(j>149) j = 149; letters[j].shake(); } currL+=0.0027; } else { letters[i].home(); } } } // A class to describe a single Letter class Letter { char letter; // The object knows its original "home" location float homex, homey; // As well as its current location float x, y; Letter (float x_, float y_, char letter_) { homex = x = x_; homey = y = y_; letter = letter_; } // Display the letter void display() { fill(0); textAlign(LEFT); text(letter, x, y); } // Move the letter randomly void shake() { x += random(-1, 1); y += random(-2, 2); } // Return the letter home void home() { x = homex; y = homey; } }