Giter Club home page Giter Club logo

Comments (2)

weirddan455 avatar weirddan455 commented on June 9, 2024 2

I'll continue our discussion from #3629 here. We probably want to add the flag SDL_AUDIO_ALLOW_FREQUENCY_CHANGE when we open the SDL audio device.

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

That's a bit crap. I'd expect to to simply fail with negotiation off if the driver doesn't support that requested rate, and with negotiation on, it should just find the closest driver-supported rate.

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'd really like disallow any SDL-side resampling whatsoever. Is that possible with some flags? I want it to work as per above, and I want to keep all resampling business in our hands.

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 SDL_Hint flags (which can also be set as environment variables). One of which can use a third-party re-sampler library if available (I think it had "rabbit" in the name or something).

from dosbox-staging.

johnnovak avatar johnnovak commented on June 9, 2024

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.

That's absolutely what we want! We handle the resampling of all the individual mixer channels to the host rate.

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.

That's what we absolutely do not want! 😅 No second resampling pass please using some shitty linear interpolation or sample dropping algo 🥶

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.

Great, I'd appreciate that.

If we ever use the SDL audio streams, ...

Extremely unlikely.

...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.

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 😆

There is also some SDL_Hint flags (which can also be set as environment variables). One of which can use a third-party re-sampler library if available (I think it had "rabbit" in the name or something).

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).

from dosbox-staging.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.