Scroll to navigation

MIX_TrackMixCallback(3type) SDL_mixer3 DATATYPES MIX_TrackMixCallback(3type)

NAME

MIX_TrackMixCallback - A callback that fires when a MIX_Track
is mixing at various stages.

HEADER FILE

Defined in SDL3_mixer/SDL_mixer.h

SYNOPSIS

#include "SDL3_mixer/SDL_mixer.h"
typedef void (SDLCALL *MIX_TrackMixCallback)(void *userdata, MIX_Track *track, const SDL_AudioSpec *spec, float *pcm, int samples);

DESCRIPTION

This callback is fired for different parts of the mixing pipeline, and gives the app visbility into the audio data that is being generated at various stages.

The audio data passed through here is _not_ const data; the app is permitted to change it in any way it likes, and those changes will propagate through the mixing pipeline.

An audiospec is provided. Different tracks might be in different formats, and an app needs to be able to handle that, but SDL_mixer always does its mixing work in 32-bit float samples, even if the inputs or final output are not floating point. As such, spec->format will always be SDL_AUDIO_F32 and pcm hardcoded to be a float pointer. samples is the number of float values pointed to by pcm : samples, not sample frames! There are no promises how many samples will be provided per-callback, and this number can vary wildly from call to call, depending on many factors.

Making changes to the track during this callback is undefined behavior. Change the data in pcm but not the track itself.

FUNCTION PARAMETERS

an opaque pointer provided by the app for its personal use.
the track that is being mixed.
the format of the data in pcm .
the raw PCM data in float32 format.
the number of float values pointed to by pcm .

AVAILABILITY

This datatype is available since SDL_mixer 3.0.0.

SEE ALSO

(3), MIX_SetTrackRawCallback(3), (3), MIX_SetTrackCookedCallback(3)

SDL_mixer 3.1.0 SDL_mixer