MIX_TrackFramesToMS(3)
β¨ MIX_TrackFramesToMS β¨
okay bestie, welcome to the SDL_mixer3 FUNCTIONS corner of the manual π this one's called MIX_TrackFramesToMS, and it's genuinely one of the more useful little guys in here, no cap.
πΈ NAME πΈ
MIX_TrackFramesToMS β converts sample frames for a track's current format into milliseconds. π
π SYNOPSIS π
#include <SDL3_mixer/SDL_mixer.h>
Sint64 MIX_TrackFramesToMS(MIX_Track *track, Sint64 frames);
π¦ DESCRIPTION π¦
so the vibe here is: this calculates time based on the track's current input format. and the tea is that format can literally change whenever the input does β and also if that input changes formats mid-stream. like, imagine you're decoding a file that's literally two MP3s concatenated together. yeah. that. π the format can just swap on you partway through.
also important: sample frames are way more precise than milliseconds, so out of necessity this function approximates β it rounds down to the closest full millisecond. it's giving "close enough, bestie" π«Ά
on various errors, it returns -1. specifically:
MIX_Init()was not called- the track is
NULL - the track has no input
framesis < 0
all of those? -1. every time. π
π FUNCTION PARAMETERS π
trackβ the track to query. that's the one you're asking about, bestie π―framesβ the track-specific sample frames you want converted to milliseconds.
β RETURN VALUE β
returns the converted number of milliseconds, or -1 for errors / no input. and if you got a -1 and you're like "okay but why", go call SDL_GetError() for the details. it'll tell you. π
π THREAD SAFETY π
it is safe to call this function from any thread. go off, multithreaded icon π
π AVAILABILITY π
this function is available since SDL_mixer 3.0.0. so if you're on anything newer, you're sooooo fine. β¨
π₯ SEE ALSO π₯
MIX_TrackMSToFrames(3)β the reverse girlypop, going the other direction π«
and that's the whole page, bestie!! this was SDL_mixer 3.2.4 from the SDL_mixer manual, and you absolutely ate reading all of it. mwah πππ¦
π¦ 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