-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Fix AudioStream cubic resampling #51082
Conversation
…sampled" This reverts commit b2264cb.
Reviewing with Ellen offline. |
Comments here #23544 (comment) |
Summarizing discussion, I think the issue Zylann is running into is related to the WASAPI driver, not |
Okay, I have a demo of this now! Took a while fiddling with OBS but I did it. The audio files I used are in this zip: My system's sample rate is 44100, so keep that in mind here. The other thing is that the github video player seems to start muted so turn on the audio for these :) This is Godot 3.2.3 with the project mix rate set to 44100. Everything sounds fine, nothing is unusual about it. godot3_official_44100.mp4This is Godot 3.2.3 with the project mix rate set to 48000. There's a fairly audible ringing artifact on the low frequency beat sound. This is what I fixed with #46086 godot3_official_48000.mp4Fast-forward to today, with a build from 23bf04a (sample rate 44100). Theoretically there's an audible low-pass effect (#49131) from the new resampling algorithm, but I can't hear it with these audio files. godot4_head_44100.mp4And 48000. Should also have a low-pass. godot4_head_48000.mp4So what I did in this PR is reverted to the old cubic algorithm and adjusted the coefficients to match a derivation I found online (linked above). Here's how that sounds at 44100 (theoretically a no-op). godot4_fixcubic_44100.mp4And here's how it sounds at 48000, which caused issues prior to the coefficient adjustment. godot4_fixcubic_48000.mp4No ringing! At least that I can hear. |
I've tested the changes locally with the files provided in #51082 (comment), and my bad ears and cheap earplugs didn't let me notice much difference (on Linux with Pulseaudio, system sampling rate seems to be 48000 Hz). No regression either though, and since cubic resampling seems to be the better option, it definitely makes sense to go back to it with a fixed implementation. I can confirm that the new implementation does not reintroduce the ringing from #23544. I suggest we merge this, include it in the 3.4 betas, and we'll see if audiophiles find new issues or can confirm that the old issues have been fixed. |
Thanks! |
Cherry-picked for 3.4. (Will be included in upcoming 3.4 beta 3.) |
Cherry-picked for 3.3.3. |
Reverts b2264cb and fixes Godot's cubic resampling algorithm. Lots of context for this is in #23544 and #49131.
Fixes #49131.
This is implemented with some help from the math on this page: https://www.paulinternet.nl/?page=bicubic
I'm not really a math person. :)