Scroll to navigation

Mix_SetPostMix(3) SDL_mixer3 FUNCTIONS Mix_SetPostMix(3)

NAME

Mix_SetPostMix - Set a function that is called after all mixing is performed.

SYNOPSIS

#include "SDL3_mixer/SDL_mixer.h"
void Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);

DESCRIPTION

This can be used to provide real-time visual display of the audio stream or add a custom mixer filter for the stream data.

The callback will fire every time SDL_mixer is ready to supply more data to the audio device, after it has finished all its mixing work. This runs inside an SDL audio callback, so it's important that the callback return quickly, or there could be problems in the audio playback.

The data provided to the callback is in the format that the audio device was opened in, and it represents the exact waveform SDL_mixer has mixed from all playing chunks and music for playback. You are allowed to modify the data, but it cannot be resized (so you can't add a reverb effect that goes past the end of the buffer without saving some state between runs to add it into the next callback, or resample the buffer to a smaller size to speed it up, etc).

The arg pointer supplied here is passed to the callback as-is, for whatever the callback might want to do with it (keep track of some ongoing state, settings, etc).

Passing a NULL callback disables the post-mix callback until such a time as a new one callback is set.

There is only one callback available. If you need to mix multiple inputs, be prepared to handle them from a single function.

FUNCTION PARAMETERS

the callback function to become the new post-mix callback.
a pointer that is passed, untouched, to the callback.

AVAILABILITY

This function is available since SDL_mixer 3.0.0.

SEE ALSO

Mix_HookMusic(3)

SDL_mixer 3.0.0 SDL_mixer