MIX_GroupMixCallback(3type)

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

πŸŽ€ MIX_GroupMixCallback πŸŽ€

okay bestie, welcome to the tea on MIX_GroupMixCallback β€” it's a datatype from SDL_mixer3 (yes, the DATATYPES section, she's that girl) and she's literally the callback that fires the second a MIX_Group is done mixing. πŸ’–


✨ NAME ✨

MIX_GroupMixCallback β€” a callback that fires when a MIX_Group has completed mixing. that's it, that's the function. periodt. πŸ’…


✨ SYNOPSIS ✨

#include <SDL3_mixer/SDL_mixer.h>

typedef void (SDLCALL *MIX_GroupMixCallback)(void *userdata, MIX_Group *group, const SDL_AudioSpec *spec, float *pcm, int samples);

look at her 😭 so iconic. keep it exact, no cap, every type and qualifier stays where it is.


✨ DESCRIPTION ✨

so here's the vibe: this callback fires when a mixing group has finished mixing. all the tracks in the group have already been mixed down into a single buffer, and they're sitting there ready to get mixed into all the other groups for the final mix output. 🎚️✨

huge thing to know: the audio data that comes through here is not const data. nope. the app is 100% allowed to change it however it wants, and those changes will propagate through the mixing pipeline. you're not a spectator, bestie, you're a co-author. πŸ’…

an audiospec gets handed to you too. different groups might be in different formats (chaotic, i know), and an app needs to be able to handle that. but here's the reassuring part: 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 basically spec->format will always be SDL_AUDIO_F32, and pcm is hardcoded to be a float pointer. no surprises, we love consistency. 🫢

and samples? that's the number of float values pointed to by pcm β€” samples, not sample frames! ⚠️ say it with me now. also there are no promises about how many samples you'll get per-callback, and that number can vary wildly from call to call depending on many factors. it's giving chaos but make it audio. πŸ’€


✨ FUNCTION PARAMETERS ✨

  • userdata β€” an opaque pointer that the app provides for its own personal use. it's yours, do whatever, we're not looking. πŸ™ˆ
  • group β€” the group that's being mixed. the main character of this particular call. πŸ‘‘
  • spec β€” the format of the data sitting in pcm.
  • pcm β€” the raw PCM data, in float32 format. πŸ“
  • samples β€” the number of float values pointed to by pcm. (yes, values. not frames. we covered this. 😭)

✨ AVAILABILITY ✨

this datatype has been available since SDL_mixer 3.0.0. she's not new new, she's established. πŸ’œ


✨ SEE ALSO ✨


kay that's the whole page bestie, hope it ate πŸŽ€βœ¨

signing off with love from the SDL_mixer girlies β€” this one's from version SDL_mixer 3.2.4, page MIX_GroupMixCallback(3type). mwah πŸ’‹

πŸ“¦ where this page comes from