We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm making a simple bouncing ball that is affected by gravity.
Every time the ball hits the bottom of the screen, it plays a bounce sound. It also decreases the volume slightly on every bounce.
I have an issue where there are sudden spikes in the volume of the sound.
Also, I'm perplexed by the fact the sound does not start off at maximum volume, even though I set that volume in setup().
I've recorded a video to explain the problem further in some detail, showing some of the things I have tried.
I've also got my current source code here: https://github.com/michaelphipps/p5js-bouncy-ball
I'd appreciate any tips or nudges towards finding a solution to this issue. I'd really like to feel like I can set the volume of a sound, and be confident it will always play at the volume that has been set.
Answers
https://GitHub.com/processing/p5.js-sound/issues
https://GitHub.com/processing/p5.js-sound/issues/158
I've posted this issue to github (which GoToLoop has referenced). Also, looking around after that, I think I've been able to narrow down to another active issue: https://github.com/processing/p5.js-sound/issues/56. There may be some additional values I can pass to the play() function that will solve this issue. Will keep you updated.
Alrighty - I have almost worked out a solution without resorting to a change in the library source code.
Instead of playing the sound using
play()
, I useplay(time, rate, amp)
. so in my case:bounceSound.play(0,1,this.volume); // play at start of sound, at normal speed, with the desired volume.
Something to note, is that if you set the volume to 0, the sound library plays the sound at full volume (1). I understand why - why are you telling the program to play a sound you don't want to hear, right?
SO, in my code I wrap the play method to check the volume is greater than 1, like this:
The only issue that remains is the first bounce sound is not at full volume. I don't understand why, so if anyone can offer some insight on that, that would be awesome.