-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Consider using the Speex resampler consistenly for every audio device #3595
Comments
I'll continue our discussion from #3629 here. We probably want to add the flag int sdl_allow_flags = 0;
if (negotiate) {
// We allow chunk size changes (if supported), but don't allow
// frequency changes because we've only seen them go beyond
// SDL's desired 48 Khz limit
#if defined(SDL_AUDIO_ALLOW_SAMPLES_CHANGE)
sdl_allow_flags |= SDL_AUDIO_ALLOW_SAMPLES_CHANGE;
#endif
The behavior if we add the flag is that it will return the closest thing the platform can do and we have to do the resampling ourselves. With the flag off we're saying "OK SDL this is the type of audio we have, deal with it!" and it will automatically convert the audio if it needs to.
I believe this is enough to avoid resampling for our use-case but I'd really have to check the SDL source code to be sure. If we ever use the SDL audio streams, it's a bit different but I'd probably recommend staying away from those and continue using the lower-level callback like we currently are. There is also some |
That's absolutely what we want! We handle the resampling of all the individual mixer channels to the host rate.
That's what we absolutely do not want! 😅 No second resampling pass please using some shitty linear interpolation or sample dropping algo 🥶
Great, I'd appreciate that.
Extremely unlikely.
Absolutely. We only need a callback that allows us to fill a stereo DAC buffer—and thank you very much SDL, yourd audio duties stop right there 😆
That's good to know, but there's no need for that. We'll just keep using Speex. It does the job very well and has low latency figures, which is super important. I've done a comparison of various resampling libraries, and while, for example, libsamplerate consumes less CPU power, it introduces unacceptably high latencies (in the 30-50ms+ range, from memory—that's a no-go for games). |
Some audio devices use the resampler from the reSIDfp library. This creates an unfortunate dependency on reSID in these unrelated devices, plus we're already using the Speex resampler for the Sound Blaster, and there's generic resampling support in the mixer for any mixer channel.
The Speex resampler is probably more performant than all these other resamplers bundled with the libraries.
Consider rendering OPL and MT-32 output at their original rates too, then use Speex to resample to the host sample rate. Rendering at the host sample rate instead of the device's native sample rate might introduce timing discrepancies and these bundled resamplers might be lower quality and not as performant as Speex.
The text was updated successfully, but these errors were encountered: