SDL_AUDIO_FRAMESIZE(3)

โœจ SDL_AUDIO_FRAMESIZE(3) โ€” the SDL3 functions page, bestie edition โœจ

okay so you're in the SDL3 FUNCTIONS corner of the manual and you clicked on SDL_AUDIO_FRAMESIZE ๐Ÿ’– buckle up, this one is tiny but it's lowkey carrying the whole audio pipeline on its back.


๐ŸŒธ NAME ๐ŸŒธ

SDL_AUDIO_FRAMESIZE โ€” calculate the size of each audio frame (in bytes) from an SDL_AudioSpec.

like. one frame. how many bytes. that's the whole assignment. ๐Ÿ’…


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <SDL3/SDL_audio.h>

#define SDL_AUDIO_FRAMESIZE(x) (SDL_AUDIO_BYTESIZE((x).format) * (x).channels)

it's a macro, not a function, so there's no linking drama, no ABI nonsense, it just inlines itself into your soul at compile time. iconic behavior fr fr โœจ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

This reports on the size of an audio sample frame: stereo Sint16 data (2 channels of 2 bytes each) would be 4 bytes per frame, for example.

so it's doing the math for you: how many bytes does one single sample frame eat up, given the format and the channel count. 2 channels ร— 2 bytes = 4 bytes per frame, and the macro just. knows. it's giving "she did the math so you don't have to" ๐Ÿงฎ๐Ÿ’…


๐Ÿ“ MACRO PARAMETERS ๐Ÿ“

  • x โ€” an SDL_AudioSpec to query. that's it, that's the whole input list. hand her your spec and she'll tell you the frame size. ๐Ÿซถ

๐Ÿ‘‘ RETURN VALUE ๐Ÿ‘‘

Returns the number of bytes used per sample frame.

no error code, no -1, no NULL check, no drama. just bytes. ๐ŸŒˆ


๐Ÿ’œ THREAD SAFETY ๐Ÿ’œ

It is safe to call this macro from any thread.

bestie you can call this from literally any thread, it does not care, it has no state, it is at peace. ๐Ÿง˜โ€โ™€๏ธโœจ

โญ AVAILABILITY โญ

This macro is available since SDL 3.2.0.

if you're on anything older, sorry babe, this macro does not exist yet ๐Ÿ˜ญ go upgrade.


and that's the whole page!! no SEE ALSO, no bugs section, no warnings โ€” just a very well-behaved little macro that minds its own business ๐Ÿ’–

this was brought to you by Simple Directmedia Layer, page version SDL 3.4.18 โ€” stay hydrated, read your manpages, and may your audio frames always be exactly the size you expected ๐ŸŽ€๐Ÿฆ‹๐Ÿ’…

๐Ÿ“ฆ where this page comes from