/** * AcousticDebris * by Cameron Boulton * * Free floating debris influenced by audio input. * * Notes: For this to work, please ensure your microphone is selected as your default input device. */ // Include external libraries import ddf.minim.*; import processing.opengl.*; // Gloabal Constants final int BG_COLOR = 0x000000; final int NUM_CUBES = 250; // Global Variables Minim minim; AudioInput input; Cube[]cubes = new Cube[NUM_CUBES]; float angle; void setup() { size(1024, 768, OPENGL); background(BG_COLOR); noStroke(); // Initialize sound library minim = new Minim(this); // Open input line input = minim.getLineIn(Minim.STEREO); // Generate random cube array for (int i = 0; i< cubes.length; i++) { cubes[i] = new Cube(int(random(-10, 10)), int(random(-10, 10)), int(random(-10, 10)), int(random(-140, 140)), int(random(-140, 140)), int(random(-140, 140))); } } void draw() { background(BG_COLOR); ambientLight(255, 255, 255); // Set up some different colored lights pointLight(random(0,255), random(0,255), random(0,255), 0, 0, 0); // Center geometry in display windwow and zoom based on audio input translate(width/2, height/2, (int)(norm(input.mix.get(0),-1,1)*((width+height)/2))); // Rotate around y and x axes rotateY(radians(angle)); rotateX(radians(angle)); // Draw cubes for (int i = 0; i < cubes.length; i++){ cubes[i].drawCube(); } // Used in rotate function calls above angle++; } void stop() { // Close input input.close(); // Stop sound library minim.stop(); // Continue up the event chain super.stop(); }