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; equals SDL_AUDIO_S16LE when SDL_BYTEORDER == SDL_LIL_ENDIAN, otherwise SDL_AUDIO_S16BE.
  • SDL_AUDIO_S32 β€” represents the current system's byteorder; equals SDL_AUDIO_S32LE when SDL_BYTEORDER == SDL_LIL_ENDIAN, otherwise SDL_AUDIO_S32BE.
  • SDL_AUDIO_F32 β€” represents the current system's byteorder; equals SDL_AUDIO_F32LE when SDL_BYTEORDER == SDL_LIL_ENDIAN, otherwise SDL_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 🌈


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