MIX_TrackMixCallback(3type)
β¨ MIX_TrackMixCallback β¨
okay bestie, welcome to the MIX_TrackMixCallback(3type) page, part of the SDL_mixer3 datatypes era π
(yes we're in the DATATYPES section, it's giving reference-material realness π)
πΈ NAME πΈ
MIX_TrackMixCallback β a callback that fires when a MIX_Track is mixing at various stages. like, she literally shows up at multiple points of the process, no cap π
π¦ 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 π
So this callback gets fired for different parts of the mixing pipeline, and it hands your app full visibility π into the audio data being generated at those various stages. it's giving backstage pass, fr fr.
the audio data passed through here is not const data β like, at all. the app is permitted to change it in any way it likes, and those changes will propagate through the mixing pipeline. glow-up your samples, they'll carry through the whole chain β¨.
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 the final output are not floating point. so as such, spec->format will always be SDL_AUDIO_F32, and pcm is hardcoded to be a float pointer. periodt π
.
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. she's unpredictable like that π.
β οΈ okay this part is important bestie: making changes to the track during this callback is undefined behavior. change the data in pcm but not the track itself. do not touch the track. i am so serious π
π«Ά FUNCTION PARAMETERS π«Ά
userdataβ an opaque pointer provided by the app for its personal use. it's yours, do whatever, she's not judging πtrackβ the track that is being mixed. the main character in question πspecβ the format of the data inpcm.pcmβ the raw PCM data in float32 format. the actual goods πsamplesβ the number of float values pointed to bypcm.
π AVAILABILITY π
this datatype is available since SDL_mixer 3.0.0. she's been iconic for a minute π
β SEE ALSO β
and that's the whole page, bestie π¦ mwah π this was brought to you by the SDL_mixer source, version SDL_mixer 3.2.4 β stay slaying, and remember: change the pcm, never the track πβ¨
π¦ where this page comes from
- fedora 44: SDL3_mixer-doc 3.2.4-3.fc44 Β· Zlib AND (GPL-2.0-or-later OR LGPL-2.0-or-later)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms