/** * Input Noise * by Cameron Boulton * * A basic noise generation sketch that uses the user's microphone or line-in as a generator. * * Notes: For this to work, please ensure your microphone is selected as your default input device. */ // Include sound library namespace import ddf.minim.*; Minim minim; AudioInput input; int x = 0, y = 0; int cellSize = 10; void setup() { size(640, 480, P2D); frameRate(255); noStroke(); // Initialize sound library minim = new Minim(this); // Open input line input = minim.getLineIn(Minim.STEREO); } void draw() { fill(norm(input.mix.get(0),-1,1)*255); rect(x, y, cellSize, cellSize); // Have we hit the side of the window? if (x >= width) { // Then move to the next line x = 0; y += cellSize; } else { // Otherwise continue x += cellSize; } // Have we hit the bottom of the window? if (y >= height) { // Then start over from the beginning x = 0; y = 0; } } void stop() { // Close input input.close(); // Stop sound library minim.stop(); // Continue up the event chain super.stop(); }