MIX_MSToFrames(3)

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

✨ MIX_MSToFrames ✨

okay bestie, so we're deep in the SDL_mixer3 functions section of the SDL_mixer manual, and today's main character is a little function called MIX_MSToFrames πŸ’– It's got one job: take some milliseconds and tell you how many sample frames that is at a sample rate you pick. That's it. That's the whole vibe. Slay. πŸŽ€


🌸 NAME 🌸

MIX_MSToFrames β€” convert milliseconds to sample frames at a specific sample rate ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <SDL3_mixer/SDL_mixer.h>

Sint64 MIX_MSToFrames(int sample_rate, Sint64 ms);

πŸ’… DESCRIPTION πŸ’…

So like, here's the tea, and it's honestly a short one β˜•

  • If sample_rate is <= 0, this returns -1.
  • If ms is < 0, this returns -1.

That's literally it. No secret third thing. Not me giving you a function that's this straightforward and still eating πŸ’€


🫢 FUNCTION PARAMETERS 🫢

  • sample_rate β€” the sample rate we're using for the conversion, bestie. This is the rate the math gets done in.
  • ms β€” the milliseconds you wanna convert into rate-specific sample frames. Yes, the word "rate-specific" is doing real work there. iykyk.

🌈 RETURN VALUE 🌈

Returns the converted number of sample frames β€” iconic! πŸŽ‰ Or it returns -1 if something went wrong, in which case you gotta call SDL_GetError() for the details, fr fr. Go read your error, don't just sit there staring at the -1 😭


😌 THREAD SAFETY 😌

Good news, queen: it is safe to call this function from any thread. Go wild. Handle it. πŸ‘‘


⭐ AVAILABILITY ⭐

This function has been available since SDL_mixer 3.0.0. So if you're on anything older... bestie, no you're not. ✨


πŸ‘€ SEE ALSO πŸ‘€

  • MIX_FramesToMS(3) β€” the reverse direction, because of course there's a matching one πŸ’–

quick vibe check: negative sample_rate and negative ms are both hard -1s, not mysterious weird numbers. Don't skip the error check and then act surprised later πŸ™ˆ

and that's the whole page, periodt πŸ’… this was SDL_mixer manual, SDL_mixer 3.2.4 era, MIX_MSToFrames(3) β€” stay hydrated, check your return values, and I'll see you in the next manpage πŸ¦‹πŸŒΈπŸ’œ

πŸ“¦ where this page comes from