MIX_PostMixCallback(3type)

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

πŸ’– MIX_PostMixCallback(3type) πŸ’–

okay bestie, welcome to the SDL_mixer3 DATATYPES corner of the docs 🌸 this one's a 3type, so it's a type page, not a function page β€” we're describing a callback type, and it's lowkey iconic. no cap.

✨ NAME ✨

MIX_PostMixCallback β€” a callback that fires when all mixing has completed. like, the mixer does its whole thing and then it's like "okay, here's the final product, do what you want with it" 🫢

πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3_mixer/SDL_mixer.h>

typedef void (SDLCALL *MIX_PostMixCallback)(void *userdata, MIX_Mixer *mixer, const SDL_AudioSpec *spec, float *pcm, int samples);

πŸ¦‹ DESCRIPTION πŸ¦‹

This callback fires when the mixer has completed all its work. it's giving "final boss of the pipeline" energy, fr fr.

Where exactly the data comes from depends on how you made your mixer, and this part matters so pay attention:

  • If the mixer was created with MIX_CreateMixerDevice(), the data handed to this callback is what's being sent to the audio hardware β€” minus the last conversions needed for format requirements.
  • If the mixer was created with MIX_CreateMixer(), this is what's being output from MIX_Generate(), after the final conversions.
πŸ‘€ The audio data passed through here is not const data! the app is fully permitted to change it in any way it likes, and those changes will replace the final mixer pipeline output. you're not a spectator, you're a co-author. main character energy.

An audiospec is provided too. SDL_mixer always does its mixing work in 32-bit float samples, even if the inputs or the final output aren't floating point. so as a result, spec->format will always be SDL_AUDIO_F32 and pcm is hardcoded to be a float pointer. always. no exceptions, periodt. πŸ’…

And samples? that's the number of float values pointed to by pcm β€” samples, not sample frames! πŸ™ˆ there are no promises about how many samples you'll get per-callback, and honestly that number can vary wildly from call to call depending on many factors. don't get attached to a specific count, bestie.

πŸ’œ FUNCTION PARAMETERS πŸ’œ

  • userdata β€” an opaque pointer provided by the app for its own personal use. it's yours, do whatever, we won't look 🫣
  • mixer β€” the mixer that is generating audio.
  • spec β€” the format of the data in pcm.
  • pcm β€” the raw PCM data in float32 format.
  • samples β€” the number of float values pointed to by pcm.

🌈 AVAILABILITY 🌈

This datatype has been available since SDL_mixer 3.0.0. so yes, it's been serving looks for a minute πŸ’…

⭐ SEE ALSO ⭐


and that's the whole vibe check, bestie πŸŽ€ this page came to you from the SDL_mixer docs, version 3.2.4 β€” the manual page is MIX_PostMixCallback(3type), and now you know it fr fr. go forth and rewrite that final pipeline output, queen πŸ‘‘βœ¨

πŸ“¦ where this page comes from