Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How To Get The Colors To Stay Transparent

$
0
0

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();
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles