We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi everyone! Im new using processing, and i find myself stuck with this doubt, im looking for something that helps me to sincronize the audio and the image and fade out the image, all of that part is in the keyPressed part, i hope i make myself clear
import ddf.minim.*;
PImage img1, img2;
int trans ;
int vol = 1;
float transparency = 255;
AudioPlayer latido;
AudioPlayer pip;
Minim minim;
void setup() {
size(500, 500);
background(0);
trans = 255;
vol = 1;
pipi = 3;
img1 = loadImage("cora.jpg");
minim = new Minim(this);
pip = minim.loadFile("pip.mp3");
latido = minim.loadFile("latido.mp3");
// the audio "latido" in loop
latido.loop();
}
void draw() {
//i combine the audio with the transparency of the image
int vol = int(latido.mix.level()*500);
println(vol);
int trans = int(map(vol,-100,200,80,200));
tint(trans,100);
image(img1, -30, -300);
if (transparency > 0) { transparency -= 10; }
tint(0, transparency);
image(img1, -30, -300);
}
_
** void keyPressed(){
//when you press any key the audio "latido" stop, and another audio(pip) starts and the image fade out with tthe last audio(here is my doubt)
latido.pause();
pip.setGain(-15);
pip.play();
pip.loop();
}**_
Answers
Prev related posts: https://forum.processing.org/two/search?Search=fading
Just to clarify, how is the fading out relates to the sound? Should it fade out along the length of the sound? I notice your sound is activated by calling its loop() function.
Kf
Hi, first of all thank you for the help! And yes, the fade out should be along the lenght of the sound, i try to activate the sound by the function "play" and i also put it on "loop" because i want that everytime that you press any key, the sound be continuos and start at the beggining of it, i hope i kind of make myself clear its the first time that i use processing, again thanks for the help!
These two posts can get you started:
This is a fading over a length of time: https://forum.processing.org/two/discussion/comment/96806/#Comment_96806
This indicates when the sound has stop playing:
https://forum.processing.org/one/topic/minim-know-when-a-song-is-done.html
However, to determine what is the current position of the sound that is playing, you need to check the docmentation: http://code.compartmental.net/minim/ and become familiar with the length() and position() functions of the AudioPlayer class.
Kf