MIX_TrackMixCallback(3type)

πŸ“¦
version 3.2.4 Β· 2 versions
, in fedora 44

✨ 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 in pcm.
  • pcm β€” the raw PCM data in float32 format. the actual goods πŸ“
  • samples β€” the number of float values pointed to by pcm.

🌈 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