-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grain/Popping/Crackling audio when playing several Players #953
Comments
My guess is that you are overloading the system. You could try two things: |
Hey dirkk0, Thank you very much for taking the time to reply. I appreciate it! a) I just put the .start() inside setTimout as follows but the result was the same. I changed the delay from 0 to 1000 but couldn't see any difference in the popping sounds.
b) I also tried .restart() the player when they are already playing but unfortunately the result is the same.
You suggested to restart it only when it's NOT playing. It seems we can't apply .restart() to a Player when its state is "stopped". Maybe you meant the opposite? I checked the link you sent but they suggest stopping and starting the audio through What I think it's strange is that it seems to be possible to do that without Popping sounds, as we can hear on this example. We can play the samples there in the same speed as in my example but we do not hear any popping... |
Still I think that the stuttering comes from too many concurrent players playing, since the crackling doesn't happen when you move 'slow enough'. |
I see what you are saying now... 1- Here's a codesandbox demo with the pool suggestion. 2- That makes me think that the problem isn't really that we have several Players playing at the same time, but actually the fact that we start the Players too fast, one after the other, and for some reason tone.js has some issue with that. I created this sandbox demo in order to make sure that we have a minimum delay between the Players and it indeed reduced the poppings a lot. The problem is that it needs a huge delay (around 80 microseconds) to remove the poppings. The interaction feels quite bad with that delay, so that can't be a good solution for the problem. Here's what the code does: The function
The function
Finally, when the user tries to play a Player, we check whether there's a minimum delay with the previous Player played.
It seems to me that that's not the right way to go since it needs such a huge delay that it makes the interaction really bad. Any ideas on how we can do that with Tone.js? |
I am not sure what was the issue, but I think it was the stopping and immediately restarting. I can't hear any crackling anymore. |
Hey again dirkk0! Thank you so much for taking the time to look into the code. It really does reduce the poppings!
Although this solution of creating several Players with the same .wav works in some cases, it might be strange to have to create like 30 Players with the same audio just because restart(), or doing stop() and start(), creates these popping sounds. Imagine if we have 30 samples, that would result in 900 Players. I'm not sure whether this is actually a common issue when dealing with sound (I have no experience with sound), but I wonder whether it might be possible to simply restart(); Players without having those popping sounds. I'll follow with your solution for now. Thank you very much, I really appreciate it! |
You are very welcome! |
Thank you for your help @dirkk0 🙏🏻, i really appreciate it. We can close this issue if it seems like it's been addressed? |
You are welcome, too! :) Yes, I think @kaua-melo would agree that we can close this. |
Hey! Sorry for the delay to respond! My specific case of the issue was solved, but I'm not sure how I would address the problem if I had many more samples. In sum, the issue is: Restarting a Player which is currently playing makes a pop sound. What @dirkk0 suggested (and worked really well! Thank you super much!) was to create several Players with the same sample. If that's a common solution when dealing with sound, then it's 100% solved. But if that sounds like a workaround, it could possibly be interesting to investigate if there's any way of stopping and restarting a player without having those poppings. I think I'm not in a position to judge if that's a real issue or if that's a common limitation when dealing with sound. So feel free to close or keep the issue open. Here's a demo of the problem: https://codesandbox.io/s/relaxed-noyce-xoto8?file=/index.html Thank you very much for the attention. I really appreciate it! |
Hi, first of all thank you very much for the effort to making the library! It was an amazing finding!
I'm getting some popping/crackling sounds when playing several Players fast, one after the other.
Here's a live example. Press on the top left button first and then hover over the squares. If you hover over the squares slowly, you'll see that the samples play fine, without poppings (it might take few seconds to load all samples). But if you move your mouse fast, we get some annoying poppings.
I initialize tone as:
Tone.start();
and start the Players as:
players["s" parseInt((13 * cValue) / 100)].start()
Source code can be found under "View Page Source" of the page.
I tried adding fadeIn/fadeOut and also tried to use the restart() method in case the Player was already playing, but the problem persists.
I found a similar scenario example where the same problem exists: https://musiclab.chromeexperiments.com/Song-Maker/ (choose 'Woodwind' instrument). And a similar scenario where the problem doesn't exist: https://musiclab.chromeexperiments.com/Shared-Piano/#lmC19e8Jq. But I can't look into their code source.
I found this issue but I couldn't reproduce it, so I didn't know if that was the same. That's why I decided not to reopen it.
Is there any way I can play several samples (let's say from 10 to 15), one after the other, very fast, without getting this popping sounds?
I'm not experience with sound, so I'm sorry in advance if I'm not using the lib as expected.
Tested on:
macOs 10.14.6
Chrome 94.0.4606.54
Firefox 92.0
The text was updated successfully, but these errors were encountered: