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โ anSDL_AudioSpecto 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
- fedora 43: SDL3-devel 3.4.18-1.fc43 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 ยท Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms