4#include <SDL3/SDL_audio.h> 
    5#include "SDL3pp_iostream.h" 
    6#include "SDL3pp_properties.h" 
    7#include "SDL3pp_stdinc.h" 
  152  constexpr explicit operator bool()
 const { 
return !!
value; }
 
  188  constexpr explicit operator bool()
 const { 
return !!
value; }
 
  271    : m_audioFormat(audioFormat)
 
  300        AudioFormatRaw(SDL_DEFINE_AUDIO_FORMAT(sign, bigendian, flt, size)))
 
  348  constexpr bool IsFloat() 
const;
 
  400  constexpr bool IsInt() 
const;
 
  543  return SDL_AUDIO_BYTESIZE(x);
 
  584  return SDL_AUDIO_ISBIGENDIAN(x);
 
  606  return SDL_AUDIO_ISLITTLEENDIAN(x);
 
  666  return SDL_AUDIO_ISUNSIGNED(x);
 
  745  std::function<void(
const AudioSpec& spec, std::span<float> buffer)>;
 
  829  void(
AudioStreamRef stream, 
int additional_amount, 
int total_amount)>;
 
  856    : m_resource(resource)
 
  948    : m_resource(
CheckError(SDL_OpenAudioDevice(devid, spec)))
 
  958    std::swap(m_resource, other.m_resource);
 
  977  constexpr bool operator==(std::nullptr_t _)
 const { 
return !m_resource; }
 
  980  constexpr explicit operator bool()
 const { 
return !!m_resource; }
 
 1547  SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK;
 
 1559  SDL_AUDIO_DEVICE_DEFAULT_RECORDING;
 
 1576  return SDL_AUDIO_FRAMESIZE(x);
 
 1621    : m_resource(resource)
 
 1660    : m_resource(
CheckError(SDL_CreateAudioStream(src_spec, dst_spec)))
 
 1724              void* userdata = 
nullptr)
 
 1726        CheckError(SDL_OpenAudioDeviceStream(devid, spec, callback, userdata)))
 
 1793    std::swap(m_resource, other.m_resource);
 
 1803    auto r = m_resource;
 
 1804    m_resource = 
nullptr;
 
 1812  constexpr bool operator==(std::nullptr_t _)
 const { 
return !m_resource; }
 
 1815  constexpr explicit operator bool()
 const { 
return !!m_resource; }
 
 2788  return SDL_GetAudioDriver(index);
 
 2807  return SDL_GetCurrentAudioDriver();
 
 2837  auto data = 
CheckError(SDL_GetAudioPlaybackDevices(&count));
 
 2869  auto data = 
CheckError(SDL_GetAudioRecordingDevices(&count));
 
 2890  return CheckError(SDL_GetAudioDeviceName(devid));
 
 2930                                      int* sample_frames = 
nullptr)
 
 2933  CheckError(SDL_GetAudioDeviceFormat(devid, &spec, sample_frames));
 
 2964  auto data = SDL_GetAudioDeviceChannelMap(devid, &count);
 
 3078  return SDL_IsAudioDevicePhysical(devid);
 
 3100  return SDL_IsAudioDevicePlayback(devid);
 
 3197  return SDL_AudioDevicePaused(devid);
 
 3228  return SDL_GetAudioDeviceGain(devid);
 
 3270  CheckError(SDL_SetAudioDeviceGain(devid, gain));
 
 3299  SDL_CloseAudioDevice(devid);
 
 3341                             std::span<AudioStreamRef> streams)
 
 3345    reinterpret_cast<SDL_AudioStream* const*
>(streams.data()),
 
 3374  CheckError(SDL_BindAudioStream(devid, stream));
 
 3402  SDL_UnbindAudioStreams(
 
 3403    reinterpret_cast<SDL_AudioStream* const*
>(streams.data()), streams.size());
 
 3422  SDL_UnbindAudioStream(stream);
 
 3448  return {SDL_GetAudioStreamDevice(stream)};
 
 3495  return {
CheckError(SDL_GetAudioStreamProperties(stream))};
 
 3522  CheckError(SDL_GetAudioStreamFormat(stream, src_spec, dst_spec));
 
 3569  CheckError(SDL_SetAudioStreamFormat(stream, src_spec, dst_spec));
 
 3594  return SDL_GetAudioStreamFrequencyRatio(stream);
 
 3629  CheckError(SDL_SetAudioStreamFrequencyRatio(stream, ratio));
 
 3658  return SDL_GetAudioStreamGain(stream);
 
 3690  CheckError(SDL_SetAudioStreamGain(stream, gain));
 
 3721  auto data = SDL_GetAudioStreamInputChannelMap(stream, &count);
 
 3722  if (!data) 
return {};
 
 3754  auto data = SDL_GetAudioStreamOutputChannelMap(stream, &count);
 
 3755  if (!data) 
return {};
 
 3821                                          std::span<int> chmap)
 
 3824    SDL_SetAudioStreamInputChannelMap(stream, chmap.data(), chmap.size()));
 
 3887                                           std::span<int> chmap)
 
 3890    SDL_SetAudioStreamOutputChannelMap(stream, chmap.data(), chmap.size()));
 
 3963  return SDL_GetAudioStreamData(stream, buf.
data(), buf.
size_bytes());
 
 3997  return SDL_GetAudioStreamAvailable(stream);
 
 4043  return SDL_GetAudioStreamQueued(stream);
 
 4123  CheckError(SDL_PauseAudioStreamDevice(stream));
 
 4153  CheckError(SDL_ResumeAudioStreamDevice(stream));
 
 4180  return SDL_AudioStreamDevicePaused(stream);
 
 4290  CheckError(SDL_SetAudioStreamGetCallback(stream, callback, userdata));
 
 4338  if (!SDL_SetAudioStreamGetCallback(
 
 4341           SDL_AudioStream* stream,
 
 4342           int additional_amount,
 
 4344          Wrapper::Call(userdata, {stream}, additional_amount, total_amount);
 
 4346        Wrapper::Wrap(stream, std::move(callback)))) {
 
 4347    Wrapper::release(stream);
 
 4414  CheckError(SDL_SetAudioStreamPutCallback(stream, callback, userdata));
 
 4465  if (!SDL_SetAudioStreamPutCallback(
 
 4468           SDL_AudioStream* stream,
 
 4469           int additional_amount,
 
 4471          Wrapper::Call(userdata, {stream}, additional_amount, total_amount);
 
 4473        Wrapper::Wrap(stream, std::move(callback)))) {
 
 4474    Wrapper::release(stream);
 
 4511  SDL_DestroyAudioStream(stream);
 
 4577                                         void* userdata = 
nullptr)
 
 4579  return AudioStream(devid, spec, callback, userdata);
 
 4646  return AudioStream(m_resource, spec, callback, userdata);
 
 4723  CheckError(SDL_SetAudioPostmixCallback(devid, callback, userdata));
 
 4780  if (!SDL_SetAudioPostmixCallback(
 
 4783           const SDL_AudioSpec* spec,
 
 4787            userdata, *spec, std::span<float>(buffer, 
size_t(buflen)));
 
 4789        Wrapper::Wrap(devid, std::move(callback)))) {
 
 4790    Wrapper::release(devid);
 
 4875                               bool closeio = 
false)
 
 4879  if (!SDL_LoadWAV_IO(src, closeio, spec, &buf, &len)) 
return {};
 
 4910  if (!SDL_LoadWAV(path, spec, &buf, &len)) 
return {};
 
 5029  CheckError(SDL_ConvertAudioSamples(&src_spec,
 
 5051  return SDL_GetAudioFormatName(format);
 
 5075  return SDL_GetSilenceValueForFormat(format);
 
SDL Audio Device instance IDs.
Definition: SDL3pp_audio.h:841
constexpr AudioDevice(const AudioDevice &other)=delete
Copy constructor.
AudioDevice & operator=(AudioDevice other)
Assignment operator.
Definition: SDL3pp_audio.h:956
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_audio.h:977
constexpr AudioDevice(AudioDevice &&other)
Move constructor.
Definition: SDL3pp_audio.h:864
~AudioDevice()
Destructor.
Definition: SDL3pp_audio.h:953
constexpr auto operator<=>(const AudioDevice &other) const =default
Comparison.
AudioDevice(AudioDeviceParam devid, OptionalRef< const AudioSpec > spec)
Open a specific audio device.
Definition: SDL3pp_audio.h:947
constexpr AudioDevice(const AudioDeviceID resource)
Constructs from AudioDeviceParam.
Definition: SDL3pp_audio.h:855
constexpr AudioDeviceID release()
Retrieves underlying AudioDeviceID and clear this.
Definition: SDL3pp_audio.h:966
constexpr AudioDevice()=default
Default ctor.
constexpr AudioDeviceID get() const
Retrieves underlying AudioDeviceID.
Definition: SDL3pp_audio.h:963
The opaque handle that represents an audio stream.
Definition: SDL3pp_audio.h:1606
~AudioStream()
Destructor.
Definition: SDL3pp_audio.h:1788
AudioSpec GetOutputFormat() const
Query the current output format of an audio stream.
Definition: SDL3pp_audio.h:1884
void SetOutputFormat(const AudioSpec &spec)
Change the output format of an audio stream.
Definition: SDL3pp_audio.h:1969
void SetInputFormat(const AudioSpec &spec)
Change the input format of an audio stream.
Definition: SDL3pp_audio.h:1937
constexpr bool operator==(std::nullptr_t _) const
Comparison.
Definition: SDL3pp_audio.h:1812
AudioStream & operator=(AudioStream other)
Assignment operator.
Definition: SDL3pp_audio.h:1791
constexpr auto operator<=>(const AudioStream &other) const =default
Comparison.
AudioStream(OptionalRef< const AudioSpec > src_spec, OptionalRef< const AudioSpec > dst_spec)
Create a new audio stream.
Definition: SDL3pp_audio.h:1658
constexpr AudioStreamRaw release()
Retrieves underlying AudioStreamRaw and clear this.
Definition: SDL3pp_audio.h:1801
constexpr AudioStreamRaw get() const
Retrieves underlying AudioStreamRaw.
Definition: SDL3pp_audio.h:1798
AudioSpec GetInputFormat() const
Query the current input format of an audio stream.
Definition: SDL3pp_audio.h:1864
constexpr AudioStream(const AudioStream &other)=delete
Copy constructor.
constexpr AudioStream(const AudioStreamRaw resource)
Constructs from AudioStreamParam.
Definition: SDL3pp_audio.h:1620
AudioStream(AudioDeviceParam devid, OptionalRef< const AudioSpec > spec=std::nullopt, AudioStreamCallback callback=nullptr, void *userdata=nullptr)
Convenience function for straightforward audio init for the common case.
Definition: SDL3pp_audio.h:1721
constexpr AudioStream()=default
Default ctor.
constexpr AudioStream(AudioStream &&other)
Move constructor.
Definition: SDL3pp_audio.h:1629
An exception that returns GetError()
Definition: SDL3pp_error.h:165
Optional-like shim for references.
Definition: SDL3pp_optionalRef.h:20
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
Source byte stream.
Definition: SDL3pp_strings.h:239
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition: SDL3pp_strings.h:303
constexpr const char * data() const
Retrieves contained data.
Definition: SDL3pp_strings.h:306
constexpr const T * data_as() const
Retrieves contained data.
Definition: SDL3pp_strings.h:313
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
Target byte stream.
Definition: SDL3pp_strings.h:325
constexpr char * data() const
Retrieves contained data.
Definition: SDL3pp_strings.h:411
constexpr T * data_as() const
Retrieves contained data.
Definition: SDL3pp_strings.h:415
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition: SDL3pp_strings.h:408
constexpr bool IsAudioFloat(AudioFormatRaw x)
Determine if an AudioFormat represents floating point data.
Definition: SDL3pp_audio.h:563
void Pause()
Use this function to pause audio playback on a specified device.
Definition: SDL3pp_audio.h:3141
constexpr AudioFormat AUDIO_UNKNOWN
Unspecified audio format.
Definition: SDL3pp_audio.h:450
bool IsAudioDevicePlayback(AudioDeviceParam devid)
Determine if an audio device is a playback device (instead of recording).
Definition: SDL3pp_audio.h:3098
AudioStream OpenStream(OptionalRef< const AudioSpec > spec, AudioStreamCallback callback, void *userdata)
Convenience function for straightforward audio init for the common case.
Definition: SDL3pp_audio.h:4642
void Resume()
Use this function to unpause audio playback on a specified device.
Definition: SDL3pp_audio.h:3173
constexpr bool IsLittleEndian() const
Determine if an AudioFormat represents littleendian data.
Definition: SDL3pp_audio.h:609
void SetAudioPostmixCallback(AudioDeviceParam devid, AudioPostmixCallback callback, void *userdata)
Set a callback that fires when data is about to be fed to an audio device.
Definition: SDL3pp_audio.h:4718
const char * GetAudioDeviceName(AudioDeviceParam devid)
Get the human-readable name of a specific audio device.
Definition: SDL3pp_audio.h:2888
void GetAudioStreamFormat(AudioStreamParam stream, AudioSpec *src_spec, AudioSpec *dst_spec)
Query the current format of an audio stream.
Definition: SDL3pp_audio.h:3518
constexpr bool IsBigEndian() const
Determine if an AudioFormat represents bigendian data.
Definition: SDL3pp_audio.h:587
void BindAudioStreams(std::span< AudioStreamRef > streams)
Bind a list of audio streams to an audio device.
Definition: SDL3pp_audio.h:3349
constexpr bool IsAudioInt(AudioFormatRaw x)
Determine if an AudioFormat represents integer data.
Definition: SDL3pp_audio.h:645
void LockAudioStream(AudioStreamParam stream)
Lock an audio stream for serialized access.
Definition: SDL3pp_audio.h:4213
void Lock()
Lock an audio stream for serialized access.
Definition: SDL3pp_audio.h:4218
constexpr Uint32 AUDIO_MASK_SIGNED
Mask of bits in an AudioFormat that contain the signed data flag.
Definition: SDL3pp_audio.h:235
constexpr Uint32 AUDIO_MASK_BITSIZE
Mask of bits in an AudioFormat that contains the format bit size.
Definition: SDL3pp_audio.h:205
bool AudioDevicePaused(AudioDeviceParam devid)
Use this function to query if an audio device is paused.
Definition: SDL3pp_audio.h:3195
void PauseDevice()
Use this function to pause audio playback on the audio device associated with an audio stream.
Definition: SDL3pp_audio.h:4126
void GetFormat(AudioSpec *src_spec, AudioSpec *dst_spec) const
Query the current format of an audio stream.
Definition: SDL3pp_audio.h:3525
constexpr AudioFormat AUDIO_S8
Signed 8-bit samples.
Definition: SDL3pp_audio.h:455
AudioDeviceRef GetAudioStreamDevice(AudioStreamParam stream)
Query an audio stream for its currently-bound device.
Definition: SDL3pp_audio.h:3446
constexpr Uint32 AUDIO_MASK_FLOAT
Mask of bits in an AudioFormat that contain the floating point flag.
Definition: SDL3pp_audio.h:215
SDL_AudioFormat AudioFormatRaw
Alias to raw representation for AudioFormat.
Definition: SDL3pp_audio.h:120
OwnArray< int > GetInputChannelMap() const
Get the current input channel map of an audio stream.
Definition: SDL3pp_audio.h:3726
OwnArray< Uint8 > ConvertAudioSamples(const AudioSpec &src_spec, SourceBytes src_data, const AudioSpec &dst_spec)
Convert some audio data of one format to another format.
Definition: SDL3pp_audio.h:5023
void SetFrequencyRatio(float ratio)
Change the frequency ratio of an audio stream.
Definition: SDL3pp_audio.h:3632
SDL_AudioSpec AudioSpec
Format specifier for audio data.
Definition: SDL3pp_audio.h:244
OwnArray< int > GetAudioStreamOutputChannelMap(AudioStreamParam stream)
Get the current output channel map of an audio stream.
Definition: SDL3pp_audio.h:3751
constexpr bool IsAudioUnsigned(AudioFormatRaw x)
Determine if an AudioFormat represents unsigned data.
Definition: SDL3pp_audio.h:664
int GetSilenceValueForFormat(AudioFormatRaw format)
Get the appropriate memset value for silencing an audio format.
Definition: SDL3pp_audio.h:5073
int GetData(TargetBytes buf)
Get converted/resampled data from the stream.
Definition: SDL3pp_audio.h:3966
OwnArray< Uint8 > LoadWAV(IOStreamParam src, AudioSpec *spec, bool closeio=false)
Load the audio data of a WAVE file into memory.
Definition: SDL3pp_audio.h:4873
int GetAudioStreamQueued(AudioStreamParam stream)
Get the number of bytes currently queued.
Definition: SDL3pp_audio.h:4041
SDL_AudioPostmixCallback AudioPostmixCallback
A callback that fires when data is about to be fed to an audio device.
Definition: SDL3pp_audio.h:709
constexpr AudioFormat AUDIO_S16
AUDIO_S16.
Definition: SDL3pp_audio.h:473
constexpr AudioFormat AUDIO_F32LE
32-bit floating point samples
Definition: SDL3pp_audio.h:467
void SetPutCallback(AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is added to an audio stream.
Definition: SDL3pp_audio.h:4479
OwnArray< int > GetOutputChannelMap() const
Get the current output channel map of an audio stream.
Definition: SDL3pp_audio.h:3759
float GetAudioDeviceGain(AudioDeviceParam devid)
Get the gain of an audio device.
Definition: SDL3pp_audio.h:3226
constexpr Uint16 GetByteSize() const
Retrieve the size, in bytes, from an AudioFormat.
Definition: SDL3pp_audio.h:546
void ClearAudioStream(AudioStreamParam stream)
Clear any pending data in the stream.
Definition: SDL3pp_audio.h:4093
void SetAudioStreamGain(AudioStreamParam stream, float gain)
Change the gain of an audio stream.
Definition: SDL3pp_audio.h:3688
const char * GetCurrentAudioDriver()
Get the name of the current audio driver.
Definition: SDL3pp_audio.h:2805
OwnArray< int > GetChannelMap() const
Get the current channel map of an audio device.
Definition: SDL3pp_audio.h:2968
int GetAvailable() const
Get the number of converted/resampled bytes available.
Definition: SDL3pp_audio.h:4000
float GetAudioStreamGain(AudioStreamParam stream)
Get the gain of an audio stream.
Definition: SDL3pp_audio.h:3656
void PutAudioStreamData(AudioStreamParam stream, SourceBytes buf)
Add data to the stream.
Definition: SDL3pp_audio.h:3924
void Unlock()
Unlock an audio stream for serialized access.
Definition: SDL3pp_audio.h:4240
float GetFrequencyRatio() const
Get the frequency ratio of an audio stream.
Definition: SDL3pp_audio.h:3597
void SetAudioStreamGetCallback(AudioStreamParam stream, AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is requested from an audio stream.
Definition: SDL3pp_audio.h:4285
constexpr bool IsAudioSigned(AudioFormatRaw x)
Determine if an AudioFormat represents signed data.
Definition: SDL3pp_audio.h:626
void ResumeDevice()
Use this function to unpause audio playback on the audio device associated with an audio stream.
Definition: SDL3pp_audio.h:4156
void SetAudioStreamOutputChannelMap(AudioStreamParam stream, std::span< int > chmap)
Set the current output channel map of an audio stream.
Definition: SDL3pp_audio.h:3886
const char * GetAudioFormatName(AudioFormatRaw format)
Get the human readable name of an audio format.
Definition: SDL3pp_audio.h:5049
AudioDevice OpenAudioDevice(AudioDeviceParam devid, OptionalRef< const AudioSpec > spec)
Open a specific audio device.
Definition: SDL3pp_audio.h:3047
bool IsAudioDevicePhysical(AudioDeviceParam devid)
Determine if an audio device is physical (instead of logical).
Definition: SDL3pp_audio.h:3076
bool Paused() const
Use this function to query if an audio device is paused.
Definition: SDL3pp_audio.h:3200
OwnArray< int > GetAudioStreamInputChannelMap(AudioStreamParam stream)
Get the current input channel map of an audio stream.
Definition: SDL3pp_audio.h:3718
void BindAudioStream(AudioStreamParam stream)
Bind a single audio stream to an audio device.
Definition: SDL3pp_audio.h:3377
void SetAudioDeviceGain(AudioDeviceParam devid, float gain)
Change the gain of an audio device.
Definition: SDL3pp_audio.h:3268
constexpr AudioFormat AUDIO_U8
Unsigned 8-bit samples.
Definition: SDL3pp_audio.h:453
void SetFormat(OptionalRef< const AudioSpec > src_spec, OptionalRef< const AudioSpec > dst_spec)
Change the input and output formats of an audio stream.
Definition: SDL3pp_audio.h:3572
bool DevicePaused() const
Use this function to query if an audio device associated with a stream is paused.
Definition: SDL3pp_audio.h:4183
int GetAudioStreamAvailable(AudioStreamParam stream)
Get the number of converted/resampled bytes available.
Definition: SDL3pp_audio.h:3995
SDL_AudioDeviceID AudioDeviceID
Alias to raw representation for AudioDevice.
Definition: SDL3pp_audio.h:129
constexpr Uint16 AudioBitSize(AudioFormatRaw x)
Retrieve the size, in bits, from an AudioFormat.
Definition: SDL3pp_audio.h:522
constexpr AudioFormat AUDIO_S32
AUDIO_S32.
Definition: SDL3pp_audio.h:475
void SetAudioStreamPutCallback(AudioStreamParam stream, AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is added to an audio stream.
Definition: SDL3pp_audio.h:4409
int GetSilenceValue() const
Get the appropriate memset value for silencing an audio format.
Definition: SDL3pp_audio.h:5078
std::function< void(AudioStreamRef stream, int additional_amount, int total_amount)> AudioStreamCB
A callback that fires when data passes through an AudioStream.
Definition: SDL3pp_audio.h:829
constexpr bool IsAudioLittleEndian(AudioFormatRaw x)
Determine if an AudioFormat represents littleendian data.
Definition: SDL3pp_audio.h:604
constexpr AudioFormat AUDIO_S16LE
Signed 16-bit samples.
Definition: SDL3pp_audio.h:457
constexpr Uint32 AUDIO_MASK_BIG_ENDIAN
Mask of bits in an AudioFormat that contain the bigendian flag.
Definition: SDL3pp_audio.h:225
AudioSpec GetFormat(int *sample_frames=nullptr) const
Get the current audio format of a specific audio device.
Definition: SDL3pp_audio.h:2937
PropertiesRef GetProperties() const
Get the properties associated with an audio stream.
Definition: SDL3pp_audio.h:3498
float GetGain() const
Get the gain of an audio stream.
Definition: SDL3pp_audio.h:3661
void SetAudioStreamFrequencyRatio(AudioStreamParam stream, float ratio)
Change the frequency ratio of an audio stream.
Definition: SDL3pp_audio.h:3627
OwnArray< AudioDeviceRef > GetAudioRecordingDevices()
Get a list of currently-connected audio recording devices.
Definition: SDL3pp_audio.h:2866
void SetOutputChannelMap(std::span< int > chmap)
Set the current output channel map of an audio stream.
Definition: SDL3pp_audio.h:3893
void SetGetCallback(AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is requested from an audio stream.
Definition: SDL3pp_audio.h:4352
AudioDeviceRef GetDevice() const
Query an audio stream for its currently-bound device.
Definition: SDL3pp_audio.h:3451
bool AudioStreamDevicePaused(AudioStreamParam stream)
Use this function to query if an audio device associated with a stream is paused.
Definition: SDL3pp_audio.h:4178
constexpr AudioFormat AUDIO_S32BE
As above, but big-endian byte order.
Definition: SDL3pp_audio.h:464
const char * GetAudioDriver(int index)
Use this function to get the name of a built in audio driver.
Definition: SDL3pp_audio.h:2786
bool IsPlayback() const
Determine if an audio device is a playback device (instead of recording).
Definition: SDL3pp_audio.h:3103
constexpr AudioDeviceID AUDIO_DEVICE_DEFAULT_RECORDING
A value used to request a default recording audio device.
Definition: SDL3pp_audio.h:1558
std::function< void(const AudioSpec &spec, std::span< float > buffer)> AudioPostmixCB
A callback that fires when data is about to be fed to an audio device.
Definition: SDL3pp_audio.h:745
AudioStream OpenAudioDeviceStream(AudioDeviceParam devid, OptionalRef< const AudioSpec > spec, AudioStreamCallback callback=nullptr, void *userdata=nullptr)
Convenience function for straightforward audio init for the common case.
Definition: SDL3pp_audio.h:4574
constexpr AudioFormat DefineAudioFormat(bool sign, bool bigendian, bool flt, Uint16 size)
Define an AudioFormat value.
Definition: SDL3pp_audio.h:502
constexpr AudioDeviceID AUDIO_DEVICE_DEFAULT_PLAYBACK
A value used to request a default playback audio device.
Definition: SDL3pp_audio.h:1546
constexpr AudioFormat AUDIO_S32LE
32-bit integer samples
Definition: SDL3pp_audio.h:462
void SetAudioStreamFormat(AudioStreamParam stream, OptionalRef< const AudioSpec > src_spec, OptionalRef< const AudioSpec > dst_spec)
Change the input and output formats of an audio stream.
Definition: SDL3pp_audio.h:3565
void Close()
Close a previously-opened audio device.
Definition: SDL3pp_audio.h:3302
constexpr bool IsInt() const
Determine if an AudioFormat represents integer data.
Definition: SDL3pp_audio.h:647
void BindAudioStream(AudioDeviceParam devid, AudioStreamParam stream)
Bind a single audio stream to an audio device.
Definition: SDL3pp_audio.h:3372
OwnArray< int > GetAudioDeviceChannelMap(AudioDeviceParam devid)
Get the current channel map of an audio device.
Definition: SDL3pp_audio.h:2961
void MixAudio(Uint8 *dst, SourceBytes src, AudioFormat format, float volume)
Mix audio data in a specified format.
Definition: SDL3pp_audio.h:4946
AudioStream CreateAudioStream(OptionalRef< const AudioSpec > src_spec, OptionalRef< const AudioSpec > dst_spec)
Create a new audio stream.
Definition: SDL3pp_audio.h:3476
void SetInputChannelMap(std::span< int > chmap)
Set the current input channel map of an audio stream.
Definition: SDL3pp_audio.h:3827
void Unbind()
Unbind a single audio stream from its audio device.
Definition: SDL3pp_audio.h:3425
SDL_AudioStream * AudioStreamRaw
Alias to raw representation for AudioStream.
Definition: SDL3pp_audio.h:165
const char * GetName() const
Get the human-readable name of a specific audio device.
Definition: SDL3pp_audio.h:2893
constexpr bool IsFloat() const
Determine if an AudioFormat represents floating point data.
Definition: SDL3pp_audio.h:565
constexpr AudioFormat AUDIO_F32BE
As above, but big-endian byte order.
Definition: SDL3pp_audio.h:470
constexpr AudioFormat AUDIO_F32
AUDIO_F32.
Definition: SDL3pp_audio.h:477
int GetNumAudioDrivers()
Use this function to get the number of built-in audio drivers.
Definition: SDL3pp_audio.h:2762
void BindAudioStreams(AudioDeviceParam devid, std::span< AudioStreamRef > streams)
Bind a list of audio streams to an audio device.
Definition: SDL3pp_audio.h:3340
void UnbindAudioStreams(std::span< AudioStreamRef > streams)
Unbind a list of audio streams from their audio devices.
Definition: SDL3pp_audio.h:3400
void SetAudioStreamInputChannelMap(AudioStreamParam stream, std::span< int > chmap)
Set the current input channel map of an audio stream.
Definition: SDL3pp_audio.h:3820
int GetQueued() const
Get the number of bytes currently queued.
Definition: SDL3pp_audio.h:4046
int GetAudioStreamData(AudioStreamParam stream, TargetBytes buf)
Get converted/resampled data from the stream.
Definition: SDL3pp_audio.h:3961
void UnbindAudioStream(AudioStreamParam stream)
Unbind a single audio stream from its audio device.
Definition: SDL3pp_audio.h:3420
void SetPostmixCallback(AudioPostmixCallback callback, void *userdata)
Set a callback that fires when data is about to be fed to an audio device.
Definition: SDL3pp_audio.h:4795
bool IsPhysical() const
Determine if an audio device is physical (instead of logical).
Definition: SDL3pp_audio.h:3081
void DestroyAudioStream(AudioStreamRaw stream)
Free an audio stream.
Definition: SDL3pp_audio.h:4509
constexpr bool IsSigned() const
Determine if an AudioFormat represents signed data.
Definition: SDL3pp_audio.h:628
constexpr bool IsAudioBigENDIAN(AudioFormatRaw x)
Determine if an AudioFormat represents bigendian data.
Definition: SDL3pp_audio.h:582
void SetGain(float gain)
Change the gain of an audio device.
Definition: SDL3pp_audio.h:3273
void UnlockAudioStream(AudioStreamParam stream)
Unlock an audio stream for serialized access.
Definition: SDL3pp_audio.h:4235
constexpr AudioFormat AUDIO_S16BE
As above, but big-endian byte order.
Definition: SDL3pp_audio.h:459
void PutData(SourceBytes buf)
Add data to the stream.
Definition: SDL3pp_audio.h:3929
void PauseAudioStreamDevice(AudioStreamParam stream)
Use this function to pause audio playback on the audio device associated with an audio stream.
Definition: SDL3pp_audio.h:4121
OwnArray< AudioDeviceRef > GetAudioPlaybackDevices()
Get a list of currently-connected audio playback devices.
Definition: SDL3pp_audio.h:2834
float GetGain() const
Get the gain of an audio device.
Definition: SDL3pp_audio.h:3231
AudioSpec GetAudioDeviceFormat(AudioDeviceParam devid, int *sample_frames=nullptr)
Get the current audio format of a specific audio device.
Definition: SDL3pp_audio.h:2929
PropertiesRef GetAudioStreamProperties(AudioStreamParam stream)
Get the properties associated with an audio stream.
Definition: SDL3pp_audio.h:3493
void FlushAudioStream(AudioStreamParam stream)
Tell the stream that you're done sending data, and anything being buffered should be converted/resamp...
Definition: SDL3pp_audio.h:4068
constexpr Uint16 AudioByteSize(AudioFormatRaw x)
Retrieve the size, in bytes, from an AudioFormat.
Definition: SDL3pp_audio.h:541
void Clear()
Clear any pending data in the stream.
Definition: SDL3pp_audio.h:4098
float GetAudioStreamFrequencyRatio(AudioStreamParam stream)
Get the frequency ratio of an audio stream.
Definition: SDL3pp_audio.h:3592
void Flush()
Tell the stream that you're done sending data, and anything being buffered should be converted/resamp...
Definition: SDL3pp_audio.h:4073
void PauseAudioDevice(AudioDeviceParam devid)
Use this function to pause audio playback on a specified device.
Definition: SDL3pp_audio.h:3136
void ResumeAudioDevice(AudioDeviceParam devid)
Use this function to unpause audio playback on a specified device.
Definition: SDL3pp_audio.h:3168
void SetGain(float gain)
Change the gain of an audio stream.
Definition: SDL3pp_audio.h:3693
SDL_AudioStreamCallback AudioStreamCallback
A callback that fires when data passes through an AudioStream.
Definition: SDL3pp_audio.h:787
const char * GetName() const
Get the human readable name of an audio format.
Definition: SDL3pp_audio.h:5054
void ResumeAudioStreamDevice(AudioStreamParam stream)
Use this function to unpause audio playback on the audio device associated with an audio stream.
Definition: SDL3pp_audio.h:4151
void CloseAudioDevice(AudioDeviceID devid)
Close a previously-opened audio device.
Definition: SDL3pp_audio.h:3297
constexpr Uint16 GetBitSize() const
Retrieve the size, in bits, from an AudioFormat.
Definition: SDL3pp_audio.h:524
constexpr int AudioFrameSize(const AudioSpec &x)
Calculate the size of each audio frame (in bytes) from an AudioSpec.
Definition: SDL3pp_audio.h:1574
void Destroy()
Free an audio stream.
Definition: SDL3pp_audio.h:4514
constexpr bool IsUnsigned() const
Determine if an AudioFormat represents unsigned data.
Definition: SDL3pp_audio.h:669
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:198
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:310
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:258
::Uint16 Uint16
An unsigned 16-bit integer type.
Definition: SDL3pp_stdinc.h:284
Main include header for the SDL3pp library.
Safely wrap AudioDevice for non owning parameters.
Definition: SDL3pp_audio.h:136
AudioDeviceID value
parameter's AudioDeviceID
Definition: SDL3pp_audio.h:137
constexpr AudioDeviceParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_audio.h:146
constexpr auto operator<=>(const AudioDeviceParam &other) const =default
Comparison.
constexpr AudioDeviceParam(AudioDeviceID value)
Constructs from AudioDeviceID.
Definition: SDL3pp_audio.h:140
Semi-safe reference for AudioDevice.
Definition: SDL3pp_audio.h:1514
AudioDeviceRef(AudioDeviceParam resource)
Constructs from AudioDeviceParam.
Definition: SDL3pp_audio.h:1522
~AudioDeviceRef()
Destructor.
Definition: SDL3pp_audio.h:1534
AudioDeviceRef(const AudioDeviceRef &other)
Copy constructor.
Definition: SDL3pp_audio.h:1528
Safely wrap AudioStream for non owning parameters.
Definition: SDL3pp_audio.h:172
AudioStreamRaw value
parameter's AudioStreamRaw
Definition: SDL3pp_audio.h:173
constexpr auto operator<=>(const AudioStreamParam &other) const =default
Comparison.
constexpr AudioStreamParam(AudioStreamRaw value)
Constructs from AudioStreamRaw.
Definition: SDL3pp_audio.h:176
constexpr AudioStreamParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_audio.h:182
Semi-safe reference for AudioStream.
Definition: SDL3pp_audio.h:2718
AudioStreamRef(AudioStreamParam resource)
Constructs from AudioStreamParam.
Definition: SDL3pp_audio.h:2726
~AudioStreamRef()
Destructor.
Definition: SDL3pp_audio.h:2738
AudioStreamRef(const AudioStreamRef &other)
Copy constructor.
Definition: SDL3pp_audio.h:2732
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
Store callbacks by key.
Definition: SDL3pp_callbackWrapper.h:222
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:701