-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Glitch encountered when using spatialized audio #885
Comments
I've noticed this too. With a simple sine wave at 200Hz looping from an in-memory stream I notice a slight crackling when the sound loops. |
@mackron did you have a chance to try to reproduce it, or any idea what the problem might be? Unfortunately this issue affects a number of sounds used in our project, so would love to figure this out. Other than this issue miniaudio is a perfect fit for us. Thanks! |
I haven't forgotten about this one, just haven't a chance to properly sit down and investigate it. Same for many other outstanding issues here. @ethindp Your issue is different. Yours is almost certainly due to the start and end of the sound not being contiguous. If you're absolutely certain that's not the case feel free to open a separate ticket. |
I can confirm that I can reproduce this as well on all three major desktop operating systems. Tested and reproduced on Windows x86_64, macOS ARM64, and Linux x86_64. For the sake of being comprehensive, here's a cross-platform version of @foxtacles' test app that only uses POSIX calls and should compile cleanly on macOS and Linux. Thanks so much for your work! |
I've finally got to looking at this. It's an annoying one, but I have a workaround to get you going. The workaround is either disable pitch shifting entirely with the As for why this is happening, it's something to do with the internal resampler. I don't know why it's affecting the siren sound and not others. I'll need to investigate further, but I don't think it'll be a simple solution. I have plans to do an overhaul of the resampler so hopefully it'll be fixed when I get to that. I've added your siren sound to my test suite and have added a note to my todo list to make sure I test against your sound. You mentioned that this doesn't happen when spatialization is disabled. That is because when spatialization is disabled, so is the doppler effect. Hope this helps! And sorry for the exceptionally long delay on getting to this. |
Thank you! I can confirm that setting the Doppler factor to
Absolutely! And no worries about the time it took. |
So I'm not sure how to make my sound contiguous; I'm generating it like so: constexpr float A = 1.0;
constexpr float Fs = 44100.0;
constexpr float f = 200.0;
float phi = 0.0;
float delta = 2 * std::numbers::pi * f / Fs;
for (std::size_t i = 0; i < 44100; ++i) {
samples.emplace_back(A * std::sin(phi));
phi += delta;
} Is this wrong in some way? |
Issue was originally reported in source repository, but adding it here for visibility - also curious if this issue can be reproduced by others.
I've noticed a "crackling" sound artifact in a few cases when spatialization is enabled. Here's a video with the sound artifact:
LEGO.2024-06-08.18-13-24.mp4
I've set up a minimally reproducible example app for this issue here:
hospital.zip
It would seem the problem is related to the fact that the "siren" sound is set to have a high volume:
ma_sound_set_volume(&siren, 0.984011f); // must be high
However, the issue is not present when spatialization is disabled.
The text was updated successfully, but these errors were encountered: