Hello!
I wrote this code to make sounds according to the pixel colour value. I also want the pixels to be drawn simultaneously in sync with the sound.
Please help me as I'm pretty new to Processing
Link to the picture used http://theblackliberalboomer.com/wp-content/uploads/2013/01/President-Obama-Official-Pic-2013.jpg
PImage obama;
import ddf.minim.*;
import ddf.minim.ugens.*;
Minim minim;
AudioOutput out;
Oscil wave;
void setup(){
size(612,612);
obama = loadImage("obama.jpg");
minim = new Minim(this);
out = minim.getLineOut();
wave = new Oscil( 440, 0.5f, Waves.SINE );
wave.patch( out );
noLoop();
}
void draw(){
obama.loadPixels();
//image(obama,0,0);
for(int x = 0; x<612; x++){
for(int y=0; y<612; y++){
int index = x+y*612;
color c = obama.pixels[index];
//stroke(c);
float amp = map( c, 0, 255, 1, 0 );
wave.setAmplitude( amp );
float freq = map( c, 0, 255, 110, 880 );
wave.setFrequency( freq );
stroke(c);
point(x,y);
//delay(500);
}
}
}