SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SDL::AudioFormat Class Reference

Audio format. More...

Public Member Functions

constexpr AudioFormat (SDL_AudioFormat audioFormat={})
 Wraps AudioFormat.
 
constexpr AudioFormat (bool sign, bool bigendian, bool flt, Uint16 size)
 Define an AudioFormat value.
 
constexpr bool operator== (const AudioFormat &other) const =default
 Default comparison operator.
 
constexpr bool operator== (SDL_AudioFormat audioFormat) const
 Compares with the underlying type.
 
constexpr operator SDL_AudioFormat () const
 Unwraps to the underlying AudioFormat.
 
constexpr operator bool () const
 Check if valid.
 
constexpr Uint16 GetBitSize ()
 Retrieve the size, in bits, from an AudioFormat.
 
constexpr Uint16 GetByteSize ()
 Retrieve the size, in bytes, from an AudioFormat.
 
constexpr bool IsFloat ()
 Determine if an AudioFormat represents floating point data.
 
constexpr bool IsBigEndian ()
 Determine if an AudioFormat represents bigendian data.
 
constexpr bool IsLittleEndian ()
 Determine if an AudioFormat represents littleendian data.
 
constexpr bool IsSigned ()
 Determine if an AudioFormat represents signed data.
 
constexpr bool IsInt ()
 Determine if an AudioFormat represents integer data.
 
constexpr bool IsUnsigned ()
 Determine if an AudioFormat represents unsigned data.
 
const char * GetName () const
 Get the human readable name of an audio format.
 
int GetSilenceValue () const
 Get the appropriate memset value for silencing an audio format.
 

Detailed Description

Since
This enum is available since SDL 3.2.0.
See also
AudioFormat.GetBitSize
AudioFormat.GetByteSize
AudioFormat.IsInt
AudioFormat.IsFloat
AudioFormat.IsBigEndian
AudioFormat.IsLittleEndian
AudioFormat.IsSigned
AudioFormat.IsUnsigned

Constructor & Destructor Documentation

◆ AudioFormat() [1/2]

constexpr SDL::AudioFormat::AudioFormat ( SDL_AudioFormat  audioFormat = {})
inlineconstexpr
Parameters
audioFormatthe value to be wrapped

◆ AudioFormat() [2/2]

constexpr SDL::AudioFormat::AudioFormat ( bool  sign,
bool  bigendian,
bool  flt,
Uint16  size 
)
inlineconstexpr

SDL does not support custom audio formats, so this function is not of much use externally, but it can be illustrative as to what the various bits of an AudioFormat mean.

For example, AUDIO_S32LE looks like this:

SDL_DEFINE_AUDIO_FORMAT(1, 0, 0, 32)
Parameters
signtrue for signed data, false for unsigned data.
bigendiantrue for bigendian data, false for littleendian data.
flttrue for floating point data, false for integer data.
sizenumber of bits per sample.
Postcondition
a format value in the style of AudioFormat.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

Member Function Documentation

◆ GetBitSize()

constexpr Uint16 SDL::AudioFormat::GetBitSize ( )
inlineconstexpr

For example, AudioFormat.GetBitSize(AUDIO_S16) returns 16.

Returns
data size in bits.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetByteSize()

constexpr Uint16 SDL::AudioFormat::GetByteSize ( )
inlineconstexpr

For example, AudioFormat.GetByteSize(AUDIO_S16) returns 2.

Returns
data size in bytes.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetName()

const char * SDL::AudioFormat::GetName ( ) const
inline
Returns
the human readable name of the specified audio format or "AUDIO_UNKNOWN" if the format isn't recognized.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ GetSilenceValue()

int SDL::AudioFormat::GetSilenceValue ( ) const
inline

The value returned by this function can be used as the second argument to memset (or memset) to set an audio buffer in a specific format to silence.

Returns
a byte value that can be passed to memset.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ IsBigEndian()

constexpr bool SDL::AudioFormat::IsBigEndian ( )
inlineconstexpr

For example, AudioFormat.IsBigEndian(AUDIO_S16LE) returns 0.

Returns
non-zero if format is bigendian, zero otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ IsFloat()

constexpr bool SDL::AudioFormat::IsFloat ( )
inlineconstexpr

For example, AudioFormat.IsFloat(AUDIO_S16) returns 0.

Returns
non-zero if format is floating point, zero otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ IsInt()

constexpr bool SDL::AudioFormat::IsInt ( )
inlineconstexpr

For example, AudioFormat.IsInt(AUDIO_F32) returns 0.

Returns
non-zero if format is integer, zero otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ IsLittleEndian()

constexpr bool SDL::AudioFormat::IsLittleEndian ( )
inlineconstexpr

For example, AudioFormat.IsLittleEndian(AUDIO_S16BE) returns 0.

Returns
non-zero if format is littleendian, zero otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ IsSigned()

constexpr bool SDL::AudioFormat::IsSigned ( )
inlineconstexpr

For example, AudioFormat.IsSigned(AUDIO_U8) returns 0.

Returns
non-zero if format is signed, zero otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ IsUnsigned()

constexpr bool SDL::AudioFormat::IsUnsigned ( )
inlineconstexpr

For example, AudioFormat.IsUnsigned(AUDIO_S16) returns 0.

Returns
non-zero if format is unsigned, zero otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ operator bool()

constexpr SDL::AudioFormat::operator bool ( ) const
inlineexplicitconstexpr
Returns
True if valid state, false otherwise.

◆ operator SDL_AudioFormat()

constexpr SDL::AudioFormat::operator SDL_AudioFormat ( ) const
inlineconstexpr
Returns
the underlying AudioFormat.

The documentation for this class was generated from the following file: