import ddf.minim.signals.*; import ddf.minim.*; import ddf.minim.analysis.*; import ddf.minim.effects.*; float magnetx, magnety; String notes[] = { "c", "e", "g", "a", "bb" }; //note order in notes int seq[] = { 0, 1, 2, 3, 4, 3, 2, 1 }; Minim minim; ArrayList activeMovers = new ArrayList(); int boogienote = 0; HashMap noteName2AudioFile = new HashMap(); boolean makeAllMoversOlderThisFrame; boolean virgin = true; float titleFade = 255; //AudioSnippet bam; String alphabet[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m", "n","o","p","q","r","s","t","u","v","w","x","y","z"}; void setup() { size(500, 500); minim = new Minim(this); //minim.debugOn(); magnetx = width/2; magnety = height/2; textFont(createFont("arial black",100)); textSize(100); for (int g = 0; g < notes.length; g++) { for (char v = 0; v < 26; v++) { String notename = notes[g]+"_"+alphabet[v]; String filepath = notes[g]+"/"+alphabet[v]+".mp3"; noteName2AudioFile.put(notename, minim.loadSnippet(filepath)); } } } void draw() { background(64); if(! virgin){ titleFade-= 4; } if(titleFade > 64){ textSize(50); fill(titleFade); text("alphaboogie\n\nclick here\nthen type",10,110); } ArrayList activeMoversToRemove = new ArrayList(); for (Mover m : activeMovers) { m.move(); m.draw(); if (makeAllMoversOlderThisFrame) { m.oldenize(); if (m.kill()) { activeMoversToRemove.add(m); } } } activeMovers.removeAll(activeMoversToRemove); makeAllMoversOlderThisFrame = false; } int MAXAGE = 5; class Mover { float origr, origg, origb; String s; int age = MAXAGE; boolean moving; float xs, ys, x, y, tx, ty; void move() { tx = magnetx; ty = magnety; if (moving) { if (x < tx) xs += .1; if (x > tx) xs -= .1; if (y < ty) ys += .1; if (y > ty) ys -= .1; x += xs; y += ys; } } Mover(String ps) { origr = random(64, 255); origg = random(64, 255); origb = random(64, 255); s = ps; x = random(width/4, width*3/4); y = random(width/4, width*3/4); // tx = width / 2; /// ty =width / 2; moving = false; } void letgo() { moving = true; } void draw() { if (age <= 0) age = 0; fill(origr, origg, origb, age*(250/MAXAGE)); pushMatrix(); translate(x, y); rotate((xs)/2); text(s, -textWidth(s)/2, 30); popMatrix(); } void oldenize() { age--; } boolean kill() { if (age <= 0) { return true; } return false; } } void mousePressed() { virgin = false; magnetx = mouseX; magnety = mouseY; } void mouseDragged() { magnetx = mouseX; magnety = mouseY; } void keyReleased() { for (Mover m : activeMovers) { m.letgo(); } skipkey = false; } boolean skipkey = false; void keyPressed() { int c = int(key); //if(c >= int('A') && c <= int('Z')) c -= int('A'); //c = c.toLowerCase(c); if (c >= int('a') && c <= int('z')) { if (skipkey) return; skipkey = true; String notelettername = notes[seq[boogienote]]+"_"+ alphabet[c - int('a')];; AudioSnippet a = (AudioSnippet)noteName2AudioFile.get(notelettername); a.rewind(); a.play(); boogienote++; if (boogienote >= seq.length) { boogienote = 0; } activeMovers.add(new Mover((new Character(key)).toString())); makeAllMoversOlderThisFrame = true; } } // bam.rewind(); // bam.play(); void stop() { for (int g = 0; g < notes.length; g++) { for (char v = 'a'; v <= 'z'; v++) { String notename = notes[g]+"_"+v; AudioSnippet a = noteName2AudioFile.get(notename); a.close(); } } minim.stop(); super.stop(); }