SDL_AudioFormat(3type)
π SDL_AudioFormat β the vibe check on audio formats
okay bestie, welcome to SDL_AudioFormat(3type), straight outta the SDL3 DATATYPES section of your local manual. this is the enum that tells SDL what shape your audio samples are in β how many bits, signed or unsigned, int or float, little-endian or big-endian. it's giving β¨the blueprint of every beep and boopβ¨.
πΈ NAME πΈ
SDL_AudioFormat β Audio format.
π SYNOPSIS π
#include <SDL3/SDL_audio.h>
typedef enum SDL_AudioFormat
{
SDL_AUDIO_UNKNOWN = 0x0000u, /**< Unspecified audio format */
SDL_AUDIO_U8 = 0x0008u, /**< Unsigned 8-bit samples */
/* SDL_DEFINE_AUDIO_FORMAT(0, 0, 0, 8), */
SDL_AUDIO_S8 = 0x8008u, /**< Signed 8-bit samples */
/* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 8), */
SDL_AUDIO_S16LE = 0x8010u, /**< Signed 16-bit samples */
/* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 16), */
SDL_AUDIO_S16BE = 0x9010u, /**< As above, but big-endian byte order */
/* SDL_DEFINE_AUDIO_FORMAT(1, 1, 0, 16), */
SDL_AUDIO_S32LE = 0x8020u, /**< 32-bit integer samples */
/* SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 32), */
SDL_AUDIO_S32BE = 0x9020u, /**< As above, but big-endian byte order */
/* SDL_DEFINE_AUDIO_FORMAT(1, 1, 0, 32), */
SDL_AUDIO_F32LE = 0x8120u, /**< 32-bit floating point samples */
/* SDL_DEFINE_AUDIO_FORMAT(1, 0, 1, 32), */
SDL_AUDIO_F32BE = 0x9120u, /**< As above, but big-endian byte order */
/* SDL_DEFINE_AUDIO_FORMAT(1, 1, 1, 32), */
/* These represent the current system's byteorder. */
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
SDL_AUDIO_S16 = SDL_AUDIO_S16LE,
SDL_AUDIO_S32 = SDL_AUDIO_S32LE,
SDL_AUDIO_F32 = SDL_AUDIO_F32LE
#else
SDL_AUDIO_S16 = SDL_AUDIO_S16BE,
SDL_AUDIO_S32 = SDL_AUDIO_S32BE,
SDL_AUDIO_F32 = SDL_AUDIO_F32BE
#endif
} SDL_AudioFormat;
π¦ DESCRIPTION π¦
so like, this is the enum where all the audio formats live. every value here is a SDL_AudioFormat, and each one is basically a lil barcode encoding four things: signedness, byte order, int vs float, and bit size. iykyk, those comment lines next to each value are showing you exactly how each one gets built by SDL_DEFINE_AUDIO_FORMAT().
here's the rundown, one by one, no skips:
SDL_AUDIO_UNKNOWN=0x0000uβ unspecified audio format. literally the "idk her" of formats π.SDL_AUDIO_U8=0x0008uβ unsigned 8-bit samples.SDL_AUDIO_S8=0x8008uβ signed 8-bit samples.SDL_AUDIO_S16LE=0x8010uβ signed 16-bit samples.SDL_AUDIO_S16BE=0x9010uβ same as above, but big-endian byte order.SDL_AUDIO_S32LE=0x8020uβ 32-bit integer samples.SDL_AUDIO_S32BE=0x9020uβ same as above, but big-endian byte order.SDL_AUDIO_F32LE=0x8120uβ 32-bit floating point samples.SDL_AUDIO_F32BE=0x9120uβ same as above, but big-endian byte order.
and then the icon behavior β¨: these three adapt to whatever machine you're on.
SDL_AUDIO_S16β represents the current system's byteorder; equalsSDL_AUDIO_S16LEwhenSDL_BYTEORDER == SDL_LIL_ENDIAN, otherwiseSDL_AUDIO_S16BE.SDL_AUDIO_S32β represents the current system's byteorder; equalsSDL_AUDIO_S32LEwhenSDL_BYTEORDER == SDL_LIL_ENDIAN, otherwiseSDL_AUDIO_S32BE.SDL_AUDIO_F32β represents the current system's byteorder; equalsSDL_AUDIO_F32LEwhenSDL_BYTEORDER == SDL_LIL_ENDIAN, otherwiseSDL_AUDIO_F32BE.
π«Ά bestie note: those three are not their own separate format bits, they're aliases. so don't go assuming they mean "little-endian always" β they mean "whatever this box is". no cap.
β AVAILABILITY β
this enum has been around since SDL 3.2.0. vintage-ish but not vintage vintage. periodt.
π SEE ALSO π
SDL_AUDIO_BITSIZE(3)SDL_AUDIO_BYTESIZE(3)SDL_AUDIO_ISINT(3)SDL_AUDIO_ISFLOAT(3)SDL_AUDIO_ISBIGENDIAN(3)SDL_AUDIO_ISLITTLEENDIAN(3)SDL_AUDIO_ISSIGNED(3)SDL_AUDIO_ISUNSIGNED(3)
and that's the whole page, babe π
brought to you by Simple Directmedia Layer, running the SDL 3.4.18 era, and this little SDL_AudioFormat(3type) writeup is officially signed, sealed, and slayed. go make some noise π§β¨
π¦ 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