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

Should mix_channels() function use SDL_MixAudio() ? #659

Open
mikrosk opened this issue Jan 13, 2025 · 1 comment
Open

Should mix_channels() function use SDL_MixAudio() ? #659

mikrosk opened this issue Jan 13, 2025 · 1 comment

Comments

@mikrosk
Copy link

mikrosk commented Jan 13, 2025

Perhaps I'm missing something but when doing some changes on the ancient SDL_mixer 1.2, I have noticed that its mix_channels function calls SDL_MixAudio.

As we can read in the original 1.2 docs: Do not use this function for mixing together more than two streams of sample data. The output from repeated application of this function may be distorted by clipping, because there is no accumulator with greater range than the input (not to mention this being an inefficient way of doing it). Use mixing functions from SDL_mixer, OpenAL, or write your own mixer instead. (that reference to SDL_mixer itself is quite interesting in this context...)

To my surprise, this called stayed there even to this date:

SDL_MixAudio(stream+index, mix_input, mixer.format, remaining, fvolume);

while SDL3's SDL_MixAudio still warns about not using it for more than two channels.

Considering that SDL_mixer supports up to 8 channels:

#define MIX_CHANNELS 8

shouldn't this be rewritten into a custom mixing code for better efficiency / accuracy?

@slouken
Copy link
Collaborator

slouken commented Jan 13, 2025

Yep! We’re working towards the SDL3 launch, and updating SDL_mixer is on the post-launch TODO list. If you’d like to pitch in, feel free!

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

No branches or pull requests

2 participants