Skip to content
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

WebAudio: Fix a noise sound before device was started #908

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

FrancoisRecisio
Copy link

Hello! In our project compiled with Emscripten and executed in a browser, we had a noise sound at startup. We found that it occurred after the device was init and before it was started. And if we don't start the device, we can hear the never-ending noise. This code fixes that: if the device is not started, the output buffer is filled with 0.

@FrancoisRecisio
Copy link
Author

I updated this PR, we still had the problem (but I don't know if there was a version regression on our side...). So now I use a loop to iterate through outputs, rather than having a single MA_ZERO_MEMORY. Or maybe pDevice->playback.internalChannels = pOutputs[i].numberOfChannels * outputCount ?

On another topic, emscripten has exposed samplesPerChannel instead of 128, since version 3.1.70. This could be the subject of another PR but it would be great to use.

@mackron
Copy link
Owner

mackron commented Nov 15, 2024

Thanks for this. This looks fine to me on the surface. I've just switched from Windows to Linux and haven't yet moved all of my projects over to my new workflow so might be a bit before I get to this.

On another topic, emscripten has exposed samplesPerChannel instead of 128, since version 3.1.70. This could be the subject of another PR but it would be great to use.

Nice! Thanks a lot for the tip on that. I actually mentioned this to the Emscripten developers a while ago, so I'll definitely be open to integrating that (my issue if you care: emscripten-core/emscripten#18853).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants