SDL Wiki
(This is the documentation for SDL3, which is under heavy development and the API is changing! SDL2 is the current stable version!)


This function is a legacy means of mixing audio.


void SDL_MixAudio(Uint8 * dst, const Uint8 * src,
                  Uint32 len, int volume);

Function Parameters


the destination for the mixed audio


the source audio buffer to be mixed


the length of the audio buffer in bytes


ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME for full audio volume


This function is equivalent to calling...

SDL_MixAudioFormat(dst, src, format, len, volume);

...where format is the obtained format of the audio device from the legacy SDL_OpenAudio() function.


This function is available since SDL 3.0.0.

Code Examples

void MyAudioCallback(void *udata, Uint8 *stream, int len)
    extern const Uint8 *mixData;
    SDL_memset(stream, 0, len);  // make sure this is silence.
    // mix our audio against the silence, at 50% volume.
    SDL_MixAudio(stream, mixData, len, SDL_MIX_MAXVOLUME / 2);

CategoryAPI, CategoryAudio

[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.