MIX_TrackMSToFrames(3)
β¨ MIX_TrackMSToFrames(3) β¨
okay bestie, so this one lives in the SDL_mixer3 FUNCTIONS section of the manual, and it's literally the glow-up translator between milliseconds and sample frames π
π NAME π
MIX_TrackMSToFrames β convert milliseconds to sample frames for a track's current format π
π¦ SYNOPSIS π¦
#include <SDL3_mixer/SDL_mixer.h>
Sint64 MIX_TrackMSToFrames(MIX_Track *track, Sint64 ms);
πΈ DESCRIPTION πΈ
So here's the tea: this function does the math based on the track's current input format. And no cap, that format can change β it changes whenever the track's input changes, and it also changes if that input switches formats mid-stream (the iconic example: decoding a file that's literally two MP3s concatenated together π« ). So it's giving "read the room, not your assumptions."
Now, the sad part π β on various errors it returns -1:
MIX_Init()was not called- the
trackisNULL
Also, if the track has no input, it returns -1. And if ms is < 0, it returns -1 too. Basically if anything is off, it's a -1, periodt.
π FUNCTION PARAMETERS π
trackβ the track to query πmsβ the milliseconds to convert to track-specific sample frames β±οΈ
β RETURN VALUE β
Returns the converted number of sample frames, or -1 for errors / no input. When you get that -1, call SDL_GetError() for the details, bestie π
π§ THREAD SAFETY π§
It is safe to call this function from any thread π β go off, no gatekeeping here.
π AVAILABILITY π
This function is available since SDL_mixer 3.0.0 β
π SEE ALSO π
MIX_TrackFramesToMS(3)β the reverse trip, iykyk π«
mwah π that's the whole page, and it's from SDL_mixer 3.2.4, dated SDL_mixer β the OG source/version and date line, but make it cute. stay slay, go convert some frames πβ¨
π¦ where this page comes from
- fedora 44: SDL3_mixer-doc 3.2.4-3.fc44 Β· Zlib AND (GPL-2.0-or-later OR LGPL-2.0-or-later)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms