Changes

Jump to: navigation, search

MidtermProject

2,601 bytes added, 23:08, 20 May 2010
Visualization
The flow in of information will go as follows: As the user moves the flashlight across the screen, it will change the MIDI note's parameters (amplitude and frequency) while the random squares play a melody on the bottom half of the screen. The ending result is an interactive MIDI sound dialogue between the user and the program.
== Visualization Documentation ==*Functional DiagramsCodeFlow Diagram/** *MIDI Capture[[Image:flowdiagram * by Leilani Martin * * Tracks the brightest pixel in a live video signal and plays a musical note at that pixel, a live duet between a predetermined/random MIDI melody and the drum notes controlled by the user.jpg]] */
import processing.video.*;
import arb.soundcipher.*;
Sample Screenshots //soundcipher dataSoundCipher sc = new SoundCipher(this); //MIDI scale for square melodyint[] scale = {57, 60, 60, 62, 64, 67, 67, 69, 72};int rate = 7;   Capture video;void setup() { size(What 640, 480); //160 // Uses the user will default video input, seethe reference if this causes an error video = new Capture(this, width, height, 30); noStroke(); smooth(); frameRate(6); } //Handles Frame Ratevoid keyPressed(){ if (key == CODED){ if (keyCode == UP){ frameRate(rate * 2); } else if(keyCode == DOWN){ frameRate(rate - 1); } }}  //Captures the video and finds the brightest pixelvoid draw() { if (video.available()) { video.read(); image(video, 0, 0, width, height); // Draw the webcam video onto the screen int brightestX = 0; // X-coordinate of the brightest video pixel int brightestY = 0; // Y-coordinate of the brightest video pixel float brightestValue = 0; // Brightness of the brightest video pixel // Search for the brightest pixel: For each row of pixels in the video image and // for each pixel in the yth row, compute each pixel's index in the video video.loadPixels(); int index = 0; for (int y = 0; y < video.height; y++) { for (int x = 0; x < video.width; x++){ // Get the color stored in the pixel int pixelValue = video.pixels[index]; // Determine the brightness of the pixel float pixelBrightness = brightness(pixelValue); // If that value is brighter than any previous, then store the // brightness of that pixel, as well as its (x,y) location if (pixelBrightness > brightestValue) { brightestValue = pixelBrightness; brightestY = y; brightestX = x; } index++; } } //Capture to MIDI note (Drum sounds) ellipse(brightestX, brightestY, 25, 25); fill(random(0, 255), random(0, 255), random(0, 255)); stroke(random(0, 255)); strokeWeight(3); sc.instrument(sc.DRUM); sc.playNote(brightestY, brightestX, 3000); //Line dividing the screen line(0, 160, 700, 160); stroke(200); //Random square melody if (random(1) < 0.8) { sc.instrument(2); sc.playNote(scale[Image:screenshots(int)random(scale.jpg]length)], (int)random(80)+40, 0.2); stroke(color(random(256), random (256), random(256))); ellipse(random(0, 1000), random(300, 500), 100, 100); }}}
28
edits

Navigation menu