SDL_AUDIO_BYTESIZE(3)

πŸ’– SDL_AUDIO_BYTESIZE πŸ’–

okay bestie, welcome to the SDL3 functions corner of the manual, where we learn how to turn an audio format into a number of bytes. it's giving "small macro, big brain" energy and honestly? we're obsessed. πŸŽ€


✨ NAME ✨

SDL_AUDIO_BYTESIZE β€” retrieve the size, in bytes, from an SDL_AudioFormat. πŸ¦‹


✨ SYNOPSIS ✨

#include <SDL3/SDL_audio.h>

#define SDL_AUDIO_BYTESIZE(x)        (SDL_AUDIO_BITSIZE(x) / 8)

like, that's the whole thing. one line. she's tiny but she ate. πŸ’…


✨ DESCRIPTION ✨

so here's the vibe: you hand her an audio format, she hands you back how many bytes that format takes up. no cap.

for example, SDL_AUDIO_BYTESIZE(SDL_AUDIO_S16) returns 2. ✨

lowkey iconic that it's just doing bits divided by eight, but hey, that's the whole point β€” you don't have to remember the math, you just call the macro. periodt.


✨ MACRO PARAMETERS ✨

  • x β€” an SDL_AudioFormat value. that's it, that's the parameter, she's low maintenance. 🌸

✨ RETURN VALUE ✨

returns the data size in bytes. 🫢


✨ THREAD SAFETY ✨

it is safe to call this macro from any thread. literally any of them. go wild, queen. πŸ‘‘


✨ AVAILABILITY ✨

this macro has been available since SDL 3.2.0. 🌈


heads up bestie: this page is part of the Simple Directmedia Layer docs, and the version we're looking at is SDL 3.4.18. if your SDL is older than 3.2.0, this macro is not gonna show up for you β€” not her fault, she was literally born in 3.2.0. πŸ’€

okay that's the whole page, mwah, go count some bytes πŸ’–πŸŽ€πŸ¦‹βœ¨πŸŒΈπŸ«ΆπŸ‘‘πŸŒˆβ­πŸ’œ

πŸ“¦ where this page comes from