We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Ok! So I have this code where I want to change the color of a photo based off of the input audio the code receives. I got it to do this, however, the biggest issue is that after saying a few words it changes to a solid color and stays that way. Does anyone know how to make it stay transparent? Help is appreciated! I'll post the code below.
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
PImage img;
Minim minim;
AudioInput in;
void setup()
{
size( 540, 687 );
img = loadImage("Ash.jpg");
image(img,0,0);
}
{
minim = new Minim( this );
in = minim.getLineIn( Minim.STEREO, 512 );
}
void draw()
{
float p = 0;
for ( int i = 0; i < in.bufferSize(); i++ ) {
p += abs( in.mix.get( i ) ) * 1;
}
loadPixels();
for (int i=0; i<(width*height); i++){
float r = red(pixels[i]);
float g = green(pixels[i]);
float b = blue(pixels[i]);
pixels[i] = color(r*p,g/p,b+p);
}
updatePixels();
}
void stop()
{
in.close();
minim.stop();
super.stop();
}
Answers
This is not a solution to your problem but an alternate code. Check it out.
Kf
Move line 14 to within your draw method.
Kf