PLEASE HELP! so close! (I think) sound fade out with image
in
Contributed Library Questions
•
2 years ago
I just want to make the sound fade out when the pixels get closer to white and have it fade back in as there is more color(movement)
THANKS.
THANKS.
- import processing.opengl.*;
import ddf.minim.*;
import ddf.minim.signals.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import hypermedia.video.*;
OpenCV opencv;
PImage trailsImg;
float threshold = 80f;
Minim minim;
AudioPlayer player;
void setup() {
// size(512, 200, P3D);
minim = new Minim(this);
// load a file, give the AudioPlayer buffers that are 2048 samples long
player = minim.loadFile("01 Space Maker 1.mp3", 2048);
// play the file
player.loop();
size( 800, 600 );
// open video stream
opencv = new OpenCV( this );
opencv.capture( 800, 600 );
trailsImg = new PImage (800, 600);
}
void draw() {
opencv.read(); // grab frame from camera
//image( opencv.image(), 0, 0); // show the original image
PImage camImage;
opencv.absDiff();
filter(INVERT);
camImage = opencv.image();
opencv.blur (OpenCV.BLUR, 3 );
trailsImg.blend( opencv.image(), 0, 0, 800, 600, 0, 0, 800, 600, SCREEN);
image( trailsImg, 0,0 ); // display the result
//opencv.read(); //do i need this?
int imgSize = opencv.height * opencv.width;
for(int i = 0; i < imgSize; i++)
color currColor = camImage;
// Extract the red, green, and blue components from current pixel
int currR = (currColor >> 16) & 0xFF; // Like red(), but faster
int currG = (currColor >> 8) & 0xFF;
int currB = currColor & 0xFF;
colorSum += currR + currG + currB;
if ( colorSum > 200)
{ player.shiftGain(0, -40, 5000);}
else {player.shiftGain(-40, 0, 5000);}
filter(INVERT);
opencv.copy (trailsImg);
opencv.blur (OpenCV.BLUR, 4 );
opencv.contrast (0);
opencv.brightness (-2);
trailsImg = opencv.image();
opencv.remember(); // store the actual image in memory
}
void keyPressed() {
}
void stop()
{
// always close Minim audio classes when you are done with them
player.close();
// always stop Minim before exiting
minim.stop();
super.stop();
}
1