MIX_StopTrack(3)

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

πŸ’… MIX_StopTrack β€” the "okay bestie, we're DONE here" function

So you're deep in the SDL_mixer3 girlie universe, flipping through the SDL_mixer functions, and you found her: MIX_StopTrack. She stops tracks. That's the whole vibe. Let's get into it. πŸŽ€


✨ NAME ✨

MIX_StopTrack β€” halt a currently-playing track, possibly fading out over time. like turning down the aux but, y'know, artistically. πŸ¦‹


🌸 SYNOPSIS 🌸

#include <SDL3_mixer/SDL_mixer.h>

bool MIX_StopTrack(MIX_Track *track, Sint64 fade_out_frames);

πŸ’– DESCRIPTION πŸ’–

Okay so here's the tea. β˜•

If fade_out_frames is > 0, the track does not stop mixing immediately. Instead she fades to silence over that many sample frames before stopping. It's giving graceful exit, main character energy, no abrupt cut, we love to see it. πŸ”₯

And sample frames are specific to the input assigned to the track β€” that's on purpose, bestie, it's so you can get sample-perfect mixing. If math is not your moment, MIX_TrackMSToFrames() can be used to convert milliseconds into an appropriate value for this parameter. ✨

Now, the plot twist: 😭 if the track ends normally while the fade-out is still in progress, the audio just stops there. The fade is not adjusted to be shorter if it will last longer than the audio remaining. She doesn't speedrun the fade to catch up. Periodt. πŸ’…

Once a track has completed any fadeout and come to a stop, it will call its MIX_TrackStoppedCallback, if any. And yes β€” it is legal to assign the track a new input and/or restart it during this callback. Go off, callback, we support you. πŸ‘‘

Also, it is legal to halt a track that's already stopped. It does nothing, and returns true. No drama, no hissy fit, just chill. 🧚


🫢 FUNCTION PARAMETERS 🫢

  • track β€” the track to halt. That's her. That's the girl.
  • fade_out_frames β€” the number of sample frames to spend fading out to silence before halting. 0 to stop immediately. zero means no fade, we're going straight to silence, bye. πŸ’€

⭐ RETURN VALUE ⭐

Returns true if the track has stopped, false on error. If you got false, call SDL_GetError() for details β€” she will tell you what went wrong, fr fr. πŸ™ˆ


🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. Multi-threaded queens, this one's for you. πŸ‘‘


✨ AVAILABILITY ✨

This function is available since SDL_mixer 3.0.0. Vintage but not vintage vintage, iykyk. πŸ“


πŸ‘€ SEE ALSO πŸ‘€

  • MIX_PlayTrack(3) β€” the other half of the story, the one who starts things. πŸ’œ

k bye bestie, that's the whole page, you understood all of it, slay πŸ¦‹βœ¨

with love from the SDL_mixer manual, version SDL_mixer 3.2.4 β€” mwah, take care of your tracks πŸ’–

πŸ“¦ where this page comes from