Hi,
I can't seem to figure out how to fade in an mp3 after reading the documentation?
This is my code:
music = loadSound('belly.mp3');
// full volume of 1 with 5 second fade in
music.setVolume(1,[5]);
music.play();
Does anyone see what I'm doing wrong??
Answers
It is properly formatted now.
Does anyone know how to fade in Audio correctly with p5?
Thanks for the proper format TechWiz.
setVolume should help: http://p5js.org/reference/#/p5.SoundFile/setVolume
so something like this:
thanks lauren, but for some reason this syntax still doesn't work. My temporary fix was to directly animate:
output.gain.value
to get a fade until it actually works in p5.
Make sure it's in draw() and not setup()
@lastnightsparty. the problem may be that loadSound is an asynchronous function, so you may be trying to set the volume before s is fully created. try putting s = loadSound() into preload, or adding a callback to set the volume after it's loaded.
something like this: http://p5js.org/reference/#p5.SoundFile/loadSound
or