MIX_TrackFramesToMS(3)

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

✨ 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
  • frames is < 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 πŸ”₯


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