MIX_GetTrackRemaining(3)

๐Ÿ“ฆ
version 3.2.4 ยท 2 versions
, in fedora 44

โœจ MIX_GetTrackRemaining(3) โœจ

okay bestie, welcome to the SDL_mixer3 FUNCTIONS corner of the manual ๐Ÿ’– this one lives in the SDL_mixer3 family, and it's all about finding out how much audio is still left in a track. it's giving "are we there yet" but for sample frames ๐ŸŽ€


๐ŸŒธ NAME ๐ŸŒธ

MIX_GetTrackRemaining โ€” returns the number of sample frames remaining to be mixed in a track. no cap, that's literally the whole job ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <SDL3_mixer/SDL_mixer.h>

Sint64 MIX_GetTrackRemaining(MIX_Track *track);

๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

so here's the tea ๐Ÿ“ โ€” if the track is playing or paused, and its total duration is known, this function will report how much audio is left to mix. and if the track is playing? every future call will report a different value, because time keeps on slippin' (into the future) โณโœจ

remaining audio is defined in _sample frames_ of decoded audio, not units of time, so that sample-perfect mixing can be achieved. if you'd rather operate in units of time instead, use MIX_TrackFramesToMS() to convert the return value to milliseconds ๐Ÿงš

heads up: this function does not take into account fade-outs or looping โ€” it's just the current mixing position vs. the duration of the track. periodt ๐Ÿ’€

if the duration of the track isn't known, or track is NULL, this function returns -1. a stopped track reports 0. iconic behaviour honestly ๐Ÿ‘‘


๐ŸŽ€ FUNCTION PARAMETERS ๐ŸŽ€

  • track โ€” the track to query. that's your main character right there ๐Ÿซถ

๐Ÿ’– RETURN VALUE ๐Ÿ’–

returns the total sample frames still to be mixed, or -1 if unknown. so either a nice number or a mystery โœจ๐Ÿ”ฎ


๐Ÿ”ฅ THREAD SAFETY ๐Ÿ”ฅ

it is safe to call this function from any thread. go forth, multithread, slay ๐ŸŒˆ


โญ AVAILABILITY โญ

this function is available since SDL_mixer 3.0.0 โ€” so it's been here for a minute, fr fr ๐Ÿ’œ


and that's the whole page, bestie!! you just read MIX_GetTrackRemaining(3) from SDL_mixer 3.2.4 (yep, the SDL_mixer source, version 3.2.4) โ€” go convert some frames to milliseconds and live your sample-perfect truth ๐Ÿ’…๐Ÿ’–๐ŸŽ€๐Ÿฆ‹๐ŸŒธ

๐Ÿ“ฆ where this page comes from