4#include <SDL3/SDL_audio.h>
5#include "SDL3pp_iostream.h"
6#include "SDL3pp_properties.h"
7#include "SDL3pp_stdinc.h"
148 constexpr explicit operator bool()
const {
return !!
value; }
184 constexpr explicit operator bool()
const {
return !!
value; }
267 : m_audioFormat(audioFormat)
296 AudioFormatRaw(SDL_DEFINE_AUDIO_FORMAT(sign, bigendian, flt, size)))
344 constexpr bool IsFloat()
const;
396 constexpr bool IsInt()
const;
538 return SDL_AUDIO_BYTESIZE(x);
579 return SDL_AUDIO_ISBIGENDIAN(x);
601 return SDL_AUDIO_ISLITTLEENDIAN(x);
661 return SDL_AUDIO_ISUNSIGNED(x);
787 int additional_amount,
830 void(
AudioStreamRaw stream,
int additional_amount,
int total_amount)>;
860 : m_resource(resource)
949 : m_resource(
CheckError(SDL_OpenAudioDevice(devid, spec)))
959 std::swap(m_resource, other.m_resource);
983 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
1572 SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK;
1584 SDL_AUDIO_DEVICE_DEFAULT_RECORDING;
1601 return SDL_AUDIO_FRAMESIZE(x);
1604#if SDL_VERSION_ATLEAST(3, 3, 6)
1663 std::function<void(
const void* buf,
int buflen)>;
1712 : m_resource(resource)
1751 : m_resource(
CheckError(SDL_CreateAudioStream(src_spec, dst_spec)))
1815 void* userdata =
nullptr)
1817 CheckError(SDL_OpenAudioDeviceStream(devid, spec, callback, userdata)))
1884 std::swap(m_resource, other.m_resource);
1899 auto r = m_resource;
1900 m_resource =
nullptr;
1908 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
2376#if SDL_VERSION_ATLEAST(3, 3, 6)
2910#if SDL_VERSION_ATLEAST(3, 3, 6)
3053 return SDL_GetAudioDriver(index);
3072 return SDL_GetCurrentAudioDriver();
3102 auto data =
CheckError(SDL_GetAudioPlaybackDevices(&count));
3134 auto data =
CheckError(SDL_GetAudioRecordingDevices(&count));
3164 return CheckError(SDL_GetAudioDeviceName(devid));
3203 int* sample_frames =
nullptr)
3206 CheckError(SDL_GetAudioDeviceFormat(devid, &spec, sample_frames));
3237 auto data = SDL_GetAudioDeviceChannelMap(devid, &count);
3347 return SDL_IsAudioDevicePhysical(devid);
3369 return SDL_IsAudioDevicePlayback(devid);
3465 return SDL_AudioDevicePaused(devid);
3496 return SDL_GetAudioDeviceGain(devid);
3538 CheckError(SDL_SetAudioDeviceGain(devid, gain));
3567 SDL_CloseAudioDevice(devid);
3609 std::span<AudioStreamRef> streams)
3613 reinterpret_cast<SDL_AudioStream* const*
>(streams.data()),
3642 CheckError(SDL_BindAudioStream(devid, stream));
3670 SDL_UnbindAudioStreams(
3671 reinterpret_cast<SDL_AudioStream* const*
>(streams.data()), streams.size());
3690 SDL_UnbindAudioStream(stream);
3715 return {SDL_GetAudioStreamDevice(stream)};
3773 return {
CheckError(SDL_GetAudioStreamProperties(stream))};
3781namespace prop::AudioStream {
3783#if SDL_VERSION_ATLEAST(3, 3, 2)
3785constexpr auto _AUTO_CLEANUP_BOOLEAN =
3786 SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN;
3811 CheckError(SDL_GetAudioStreamFormat(stream, src_spec, dst_spec));
3858 CheckError(SDL_SetAudioStreamFormat(stream, src_spec, dst_spec));
3883 return SDL_GetAudioStreamFrequencyRatio(stream);
3918 CheckError(SDL_SetAudioStreamFrequencyRatio(stream, ratio));
3947 return SDL_GetAudioStreamGain(stream);
3979 CheckError(SDL_SetAudioStreamGain(stream, gain));
4010 auto data = SDL_GetAudioStreamInputChannelMap(stream, &count);
4011 if (!data)
return {};
4043 auto data = SDL_GetAudioStreamOutputChannelMap(stream, &count);
4044 if (!data)
return {};
4110 std::span<int> chmap)
4113 SDL_SetAudioStreamInputChannelMap(stream, chmap.data(), chmap.size()));
4176 std::span<int> chmap)
4179 SDL_SetAudioStreamOutputChannelMap(stream, chmap.data(), chmap.size()));
4223#if SDL_VERSION_ATLEAST(3, 3, 6)
4326 Wrapper::Wrap(std::move(callback)));
4391 const void*
const* channel_buffers,
4396 stream, channel_buffers, num_channels, num_samples));
4404 m_resource, channel_buffers, num_channels, num_samples);
4438 return SDL_GetAudioStreamData(stream, buf.
data(), buf.
size_bytes());
4471 return SDL_GetAudioStreamAvailable(stream);
4516 return SDL_GetAudioStreamQueued(stream);
4596 CheckError(SDL_PauseAudioStreamDevice(stream));
4626 CheckError(SDL_ResumeAudioStreamDevice(stream));
4653 return SDL_AudioStreamDevicePaused(stream);
4760 CheckError(SDL_SetAudioStreamGetCallback(stream, callback, userdata));
4868 CheckError(SDL_SetAudioStreamPutCallback(stream, callback, userdata));
4951 SDL_DestroyAudioStream(stream);
5016 void* userdata =
nullptr)
5018 return AudioStream(devid, spec, callback, userdata);
5085 return AudioStream(m_resource, spec, callback, userdata);
5161 CheckError(SDL_SetAudioPostmixCallback(devid, callback, userdata));
5299 bool closeio =
false)
5303 if (!SDL_LoadWAV_IO(src, closeio, spec, &buf, &len))
return {};
5334 if (!SDL_LoadWAV(path, spec, &buf, &len))
return {};
5451 CheckError(SDL_ConvertAudioSamples(&src_spec,
5473 return SDL_GetAudioFormatName(format);
5496 return SDL_GetSilenceValueForFormat(format);
SDL Audio Device instance IDs.
Definition: SDL3pp_audio.h:842
constexpr AudioDevice(const AudioDevice &other)=delete
Copy constructor.
constexpr AudioDeviceID get() const noexcept
Retrieves underlying AudioDeviceID.
Definition: SDL3pp_audio.h:969
constexpr AudioDevice & operator=(const AudioDevice &other) noexcept=default
Assignment operator.
constexpr AudioDeviceID release() noexcept
Retrieves underlying AudioDeviceID and clear this.
Definition: SDL3pp_audio.h:972
~AudioDevice()
Destructor.
Definition: SDL3pp_audio.h:954
AudioDevice(AudioDeviceParam devid, OptionalRef< const AudioSpec > spec)
Open a specific audio device.
Definition: SDL3pp_audio.h:948
constexpr AudioDevice(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_audio.h:847
constexpr AudioDevice(const AudioDeviceID resource) noexcept
Constructs from AudioDeviceParam.
Definition: SDL3pp_audio.h:859
constexpr auto operator<=>(const AudioDevice &other) const noexcept=default
Comparison.
constexpr AudioDevice & operator=(AudioDevice &&other) noexcept
Assignment operator.
Definition: SDL3pp_audio.h:957
constexpr AudioDevice(AudioDevice &&other) noexcept
Move constructor.
Definition: SDL3pp_audio.h:868
The opaque handle that represents an audio stream.
Definition: SDL3pp_audio.h:1694
constexpr auto operator<=>(const AudioStream &other) const noexcept=default
Comparison.
~AudioStream()
Destructor.
Definition: SDL3pp_audio.h:1879
AudioSpec GetOutputFormat() const
Query the current output format of an audio stream.
Definition: SDL3pp_audio.h:1988
void SetOutputFormat(const AudioSpec &spec)
Change the output format of an audio stream.
Definition: SDL3pp_audio.h:2073
constexpr AudioStream(AudioStream &&other) noexcept
Move constructor.
Definition: SDL3pp_audio.h:1720
void SetInputFormat(const AudioSpec &spec)
Change the input format of an audio stream.
Definition: SDL3pp_audio.h:2041
constexpr AudioStream(const AudioStreamRaw resource) noexcept
Constructs from AudioStreamParam.
Definition: SDL3pp_audio.h:1711
AudioStream(OptionalRef< const AudioSpec > src_spec, OptionalRef< const AudioSpec > dst_spec)
Create a new audio stream.
Definition: SDL3pp_audio.h:1749
constexpr AudioStream(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_audio.h:1699
constexpr AudioStreamRaw get() const noexcept
Retrieves underlying AudioStreamRaw.
Definition: SDL3pp_audio.h:1894
constexpr AudioStreamRaw release() noexcept
Retrieves underlying AudioStreamRaw and clear this.
Definition: SDL3pp_audio.h:1897
AudioSpec GetInputFormat() const
Query the current input format of an audio stream.
Definition: SDL3pp_audio.h:1968
constexpr AudioStream(const AudioStream &other)=delete
Copy constructor.
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:1812
constexpr AudioStream & operator=(const AudioStream &other) noexcept=default
Assignment operator.
constexpr AudioStream & operator=(AudioStream &&other) noexcept
Assignment operator.
Definition: SDL3pp_audio.h:1882
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:558
void Pause()
Use this function to pause audio playback on a specified device.
Definition: SDL3pp_audio.h:3410
constexpr AudioFormat AUDIO_UNKNOWN
Unspecified audio format.
Definition: SDL3pp_audio.h:445
bool IsAudioDevicePlayback(AudioDeviceParam devid)
Determine if an audio device is a playback device (instead of recording).
Definition: SDL3pp_audio.h:3367
AudioStream OpenStream(OptionalRef< const AudioSpec > spec, AudioStreamCallback callback, void *userdata)
Convenience function for straightforward audio init for the common case.
Definition: SDL3pp_audio.h:5081
void Resume()
Use this function to unpause audio playback on a specified device.
Definition: SDL3pp_audio.h:3441
constexpr bool IsLittleEndian() const
Determine if an AudioFormat represents littleendian data.
Definition: SDL3pp_audio.h:604
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:5157
const char * GetAudioDeviceName(AudioDeviceParam devid)
Get the human-readable name of a specific audio device.
Definition: SDL3pp_audio.h:3162
void GetAudioStreamFormat(AudioStreamParam stream, AudioSpec *src_spec, AudioSpec *dst_spec)
Query the current format of an audio stream.
Definition: SDL3pp_audio.h:3807
constexpr bool IsBigEndian() const
Determine if an AudioFormat represents bigendian data.
Definition: SDL3pp_audio.h:582
void BindAudioStreams(std::span< AudioStreamRef > streams)
Bind a list of audio streams to an audio device.
Definition: SDL3pp_audio.h:3617
constexpr bool IsAudioInt(AudioFormatRaw x)
Determine if an AudioFormat represents integer data.
Definition: SDL3pp_audio.h:640
void LockAudioStream(AudioStreamParam stream)
Lock an audio stream for serialized access.
Definition: SDL3pp_audio.h:4686
void Lock()
Lock an audio stream for serialized access.
Definition: SDL3pp_audio.h:4691
constexpr Uint32 AUDIO_MASK_SIGNED
Mask of bits in an AudioFormat that contain the signed data flag.
Definition: SDL3pp_audio.h:231
constexpr Uint32 AUDIO_MASK_BITSIZE
Mask of bits in an AudioFormat that contains the format bit size.
Definition: SDL3pp_audio.h:201
bool AudioDevicePaused(AudioDeviceParam devid)
Use this function to query if an audio device is paused.
Definition: SDL3pp_audio.h:3463
void PauseDevice()
Use this function to pause audio playback on the audio device associated with an audio stream.
Definition: SDL3pp_audio.h:4599
void GetFormat(AudioSpec *src_spec, AudioSpec *dst_spec) const
Query the current format of an audio stream.
Definition: SDL3pp_audio.h:3814
constexpr AudioFormat AUDIO_S8
Signed 8-bit samples.
Definition: SDL3pp_audio.h:450
AudioDeviceRef GetAudioStreamDevice(AudioStreamParam stream)
Query an audio stream for its currently-bound device.
Definition: SDL3pp_audio.h:3713
constexpr Uint32 AUDIO_MASK_FLOAT
Mask of bits in an AudioFormat that contain the floating point flag.
Definition: SDL3pp_audio.h:211
SDL_AudioFormat AudioFormatRaw
Alias to raw representation for AudioFormat.
Definition: SDL3pp_audio.h:116
OwnArray< int > GetInputChannelMap() const
Get the current input channel map of an audio stream.
Definition: SDL3pp_audio.h:4015
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:5445
void SetFrequencyRatio(float ratio)
Change the frequency ratio of an audio stream.
Definition: SDL3pp_audio.h:3921
SDL_AudioSpec AudioSpec
Format specifier for audio data.
Definition: SDL3pp_audio.h:240
OwnArray< int > GetAudioStreamOutputChannelMap(AudioStreamParam stream)
Get the current output channel map of an audio stream.
Definition: SDL3pp_audio.h:4040
constexpr bool IsAudioUnsigned(AudioFormatRaw x)
Determine if an AudioFormat represents unsigned data.
Definition: SDL3pp_audio.h:659
int GetSilenceValueForFormat(AudioFormatRaw format)
Get the appropriate memset value for silencing an audio format.
Definition: SDL3pp_audio.h:5494
int GetData(TargetBytes buf)
Get converted/resampled data from the stream.
Definition: SDL3pp_audio.h:4441
OwnArray< Uint8 > LoadWAV(IOStreamParam src, AudioSpec *spec, bool closeio=false)
Load the audio data of a WAVE file into memory.
Definition: SDL3pp_audio.h:5297
int GetAudioStreamQueued(AudioStreamParam stream)
Get the number of bytes currently queued.
Definition: SDL3pp_audio.h:4514
constexpr AudioFormat AUDIO_S16
AUDIO_S16.
Definition: SDL3pp_audio.h:468
constexpr AudioFormat AUDIO_F32LE
32-bit floating point samples
Definition: SDL3pp_audio.h:462
void SetPutCallback(AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is added to an audio stream.
Definition: SDL3pp_audio.h:4920
OwnArray< int > GetOutputChannelMap() const
Get the current output channel map of an audio stream.
Definition: SDL3pp_audio.h:4048
float GetAudioDeviceGain(AudioDeviceParam devid)
Get the gain of an audio device.
Definition: SDL3pp_audio.h:3494
constexpr Uint16 GetByteSize() const
Retrieve the size, in bytes, from an AudioFormat.
Definition: SDL3pp_audio.h:541
void(SDLCALL *)(void *userdata, const AudioSpec *spec, float *buffer, int buflen) AudioPostmixCallback
A callback that fires when data is about to be fed to an audio device.
Definition: SDL3pp_audio.h:707
void ClearAudioStream(AudioStreamParam stream)
Clear any pending data in the stream.
Definition: SDL3pp_audio.h:4566
void SetAudioStreamGain(AudioStreamParam stream, float gain)
Change the gain of an audio stream.
Definition: SDL3pp_audio.h:3977
const char * GetCurrentAudioDriver()
Get the name of the current audio driver.
Definition: SDL3pp_audio.h:3070
void(SDLCALL *)(void *userdata, const void *buf, int buflen) AudioStreamDataCompleteCallback
A callback that fires for completed AudioStream.PutDataNoCopy() data.
Definition: SDL3pp_audio.h:1634
OwnArray< int > GetChannelMap() const
Get the current channel map of an audio device.
Definition: SDL3pp_audio.h:3241
int GetAvailable() const
Get the number of converted/resampled bytes available.
Definition: SDL3pp_audio.h:4474
float GetAudioStreamGain(AudioStreamParam stream)
Get the gain of an audio stream.
Definition: SDL3pp_audio.h:3945
void PutAudioStreamData(AudioStreamParam stream, SourceBytes buf)
Add data to the stream.
Definition: SDL3pp_audio.h:4213
void Unlock()
Unlock an audio stream for serialized access.
Definition: SDL3pp_audio.h:4713
float GetFrequencyRatio() const
Get the frequency ratio of an audio stream.
Definition: SDL3pp_audio.h:3886
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:4756
constexpr bool IsAudioSigned(AudioFormatRaw x)
Determine if an AudioFormat represents signed data.
Definition: SDL3pp_audio.h:621
void ResumeDevice()
Use this function to unpause audio playback on the audio device associated with an audio stream.
Definition: SDL3pp_audio.h:4629
void SetAudioStreamOutputChannelMap(AudioStreamParam stream, std::span< int > chmap)
Set the current output channel map of an audio stream.
Definition: SDL3pp_audio.h:4175
const char * GetAudioFormatName(AudioFormatRaw format)
Get the human readable name of an audio format.
Definition: SDL3pp_audio.h:5471
AudioDevice OpenAudioDevice(AudioDeviceParam devid, OptionalRef< const AudioSpec > spec)
Open a specific audio device.
Definition: SDL3pp_audio.h:3316
bool IsAudioDevicePhysical(AudioDeviceParam devid)
Determine if an audio device is physical (instead of logical).
Definition: SDL3pp_audio.h:3345
bool Paused() const
Use this function to query if an audio device is paused.
Definition: SDL3pp_audio.h:3468
OwnArray< int > GetAudioStreamInputChannelMap(AudioStreamParam stream)
Get the current input channel map of an audio stream.
Definition: SDL3pp_audio.h:4007
void BindAudioStream(AudioStreamParam stream)
Bind a single audio stream to an audio device.
Definition: SDL3pp_audio.h:3645
void PutPlanarData(const void *const *channel_buffers, int num_channels, int num_samples)
Add data to the stream with each channel in a separate array.
Definition: SDL3pp_audio.h:4399
void SetAudioDeviceGain(AudioDeviceParam devid, float gain)
Change the gain of an audio device.
Definition: SDL3pp_audio.h:3536
constexpr AudioFormat AUDIO_U8
Unsigned 8-bit samples.
Definition: SDL3pp_audio.h:448
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:3861
bool DevicePaused() const
Use this function to query if an audio device associated with a stream is paused.
Definition: SDL3pp_audio.h:4656
int GetAudioStreamAvailable(AudioStreamParam stream)
Get the number of converted/resampled bytes available.
Definition: SDL3pp_audio.h:4469
SDL_AudioDeviceID AudioDeviceID
Alias to raw representation for AudioDevice.
Definition: SDL3pp_audio.h:125
constexpr Uint16 AudioBitSize(AudioFormatRaw x)
Retrieve the size, in bits, from an AudioFormat.
Definition: SDL3pp_audio.h:517
constexpr AudioFormat AUDIO_S32
AUDIO_S32.
Definition: SDL3pp_audio.h:470
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:4864
int GetSilenceValue() const
Get the appropriate memset value for silencing an audio format.
Definition: SDL3pp_audio.h:5499
constexpr bool IsAudioLittleEndian(AudioFormatRaw x)
Determine if an AudioFormat represents littleendian data.
Definition: SDL3pp_audio.h:599
constexpr AudioFormat AUDIO_S16LE
Signed 16-bit samples.
Definition: SDL3pp_audio.h:452
constexpr Uint32 AUDIO_MASK_BIG_ENDIAN
Mask of bits in an AudioFormat that contain the bigendian flag.
Definition: SDL3pp_audio.h:221
AudioSpec GetFormat(int *sample_frames=nullptr) const
Get the current audio format of a specific audio device.
Definition: SDL3pp_audio.h:3210
PropertiesRef GetProperties() const
Get the properties associated with an audio stream.
Definition: SDL3pp_audio.h:3776
float GetGain() const
Get the gain of an audio stream.
Definition: SDL3pp_audio.h:3950
void SetAudioStreamFrequencyRatio(AudioStreamParam stream, float ratio)
Change the frequency ratio of an audio stream.
Definition: SDL3pp_audio.h:3916
OwnArray< AudioDeviceRef > GetAudioRecordingDevices()
Get a list of currently-connected audio recording devices.
Definition: SDL3pp_audio.h:3131
void SetOutputChannelMap(std::span< int > chmap)
Set the current output channel map of an audio stream.
Definition: SDL3pp_audio.h:4182
void PutAudioStreamDataNoCopy(AudioStreamParam stream, SourceBytes buf, AudioStreamDataCompleteCallback callback, void *userdata)
Add external data to an audio stream without copying it.
Definition: SDL3pp_audio.h:4268
void SetGetCallback(AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is requested from an audio stream.
Definition: SDL3pp_audio.h:4808
AudioDeviceRef GetDevice() const
Query an audio stream for its currently-bound device.
Definition: SDL3pp_audio.h:3718
bool AudioStreamDevicePaused(AudioStreamParam stream)
Use this function to query if an audio device associated with a stream is paused.
Definition: SDL3pp_audio.h:4651
constexpr AudioFormat AUDIO_S32BE
As above, but big-endian byte order.
Definition: SDL3pp_audio.h:459
const char * GetAudioDriver(int index)
Use this function to get the name of a built in audio driver.
Definition: SDL3pp_audio.h:3051
bool IsPlayback() const
Determine if an audio device is a playback device (instead of recording).
Definition: SDL3pp_audio.h:3372
constexpr AudioDeviceID AUDIO_DEVICE_DEFAULT_RECORDING
A value used to request a default recording audio device.
Definition: SDL3pp_audio.h:1583
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:5013
constexpr AudioFormat DefineAudioFormat(bool sign, bool bigendian, bool flt, Uint16 size)
Define an AudioFormat value.
Definition: SDL3pp_audio.h:497
constexpr AudioDeviceID AUDIO_DEVICE_DEFAULT_PLAYBACK
A value used to request a default playback audio device.
Definition: SDL3pp_audio.h:1571
constexpr AudioFormat AUDIO_S32LE
32-bit integer samples
Definition: SDL3pp_audio.h:457
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:3854
void Close()
Close a previously-opened audio device.
Definition: SDL3pp_audio.h:3570
constexpr bool IsInt() const
Determine if an AudioFormat represents integer data.
Definition: SDL3pp_audio.h:642
void BindAudioStream(AudioDeviceParam devid, AudioStreamParam stream)
Bind a single audio stream to an audio device.
Definition: SDL3pp_audio.h:3640
OwnArray< int > GetAudioDeviceChannelMap(AudioDeviceParam devid)
Get the current channel map of an audio device.
Definition: SDL3pp_audio.h:3234
void MixAudio(Uint8 *dst, SourceBytes src, AudioFormat format, float volume)
Mix audio data in a specified format.
Definition: SDL3pp_audio.h:5369
AudioStream CreateAudioStream(OptionalRef< const AudioSpec > src_spec, OptionalRef< const AudioSpec > dst_spec)
Create a new audio stream.
Definition: SDL3pp_audio.h:3743
void SetInputChannelMap(std::span< int > chmap)
Set the current input channel map of an audio stream.
Definition: SDL3pp_audio.h:4116
void Unbind()
Unbind a single audio stream from its audio device.
Definition: SDL3pp_audio.h:3693
SDL_AudioStream * AudioStreamRaw
Alias to raw representation for AudioStream.
Definition: SDL3pp_audio.h:161
const char * GetName() const
Get the human-readable name of a specific audio device.
Definition: SDL3pp_audio.h:3167
constexpr bool IsFloat() const
Determine if an AudioFormat represents floating point data.
Definition: SDL3pp_audio.h:560
constexpr AudioFormat AUDIO_F32BE
As above, but big-endian byte order.
Definition: SDL3pp_audio.h:465
constexpr AudioFormat AUDIO_F32
AUDIO_F32.
Definition: SDL3pp_audio.h:472
int GetNumAudioDrivers()
Use this function to get the number of built-in audio drivers.
Definition: SDL3pp_audio.h:3027
void BindAudioStreams(AudioDeviceParam devid, std::span< AudioStreamRef > streams)
Bind a list of audio streams to an audio device.
Definition: SDL3pp_audio.h:3608
void UnbindAudioStreams(std::span< AudioStreamRef > streams)
Unbind a list of audio streams from their audio devices.
Definition: SDL3pp_audio.h:3668
void SetAudioStreamInputChannelMap(AudioStreamParam stream, std::span< int > chmap)
Set the current input channel map of an audio stream.
Definition: SDL3pp_audio.h:4109
int GetQueued() const
Get the number of bytes currently queued.
Definition: SDL3pp_audio.h:4519
int GetAudioStreamData(AudioStreamParam stream, TargetBytes buf)
Get converted/resampled data from the stream.
Definition: SDL3pp_audio.h:4436
void UnbindAudioStream(AudioStreamParam stream)
Unbind a single audio stream from its audio device.
Definition: SDL3pp_audio.h:3688
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:5220
bool IsPhysical() const
Determine if an audio device is physical (instead of logical).
Definition: SDL3pp_audio.h:3350
void DestroyAudioStream(AudioStreamRaw stream)
Free an audio stream.
Definition: SDL3pp_audio.h:4949
constexpr bool IsSigned() const
Determine if an AudioFormat represents signed data.
Definition: SDL3pp_audio.h:623
constexpr bool IsAudioBigENDIAN(AudioFormatRaw x)
Determine if an AudioFormat represents bigendian data.
Definition: SDL3pp_audio.h:577
void SetGain(float gain)
Change the gain of an audio device.
Definition: SDL3pp_audio.h:3541
void UnlockAudioStream(AudioStreamParam stream)
Unlock an audio stream for serialized access.
Definition: SDL3pp_audio.h:4708
constexpr AudioFormat AUDIO_S16BE
As above, but big-endian byte order.
Definition: SDL3pp_audio.h:454
void PutData(SourceBytes buf)
Add data to the stream.
Definition: SDL3pp_audio.h:4218
void PauseAudioStreamDevice(AudioStreamParam stream)
Use this function to pause audio playback on the audio device associated with an audio stream.
Definition: SDL3pp_audio.h:4594
OwnArray< AudioDeviceRef > GetAudioPlaybackDevices()
Get a list of currently-connected audio playback devices.
Definition: SDL3pp_audio.h:3099
float GetGain() const
Get the gain of an audio device.
Definition: SDL3pp_audio.h:3499
AudioSpec GetAudioDeviceFormat(AudioDeviceParam devid, int *sample_frames=nullptr)
Get the current audio format of a specific audio device.
Definition: SDL3pp_audio.h:3202
PropertiesRef GetAudioStreamProperties(AudioStreamParam stream)
Get the properties associated with an audio stream.
Definition: SDL3pp_audio.h:3771
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:4541
void(SDLCALL *)(void *userdata, AudioStreamRaw stream, int additional_amount, int total_amount) AudioStreamCallback
A callback that fires when data passes through an AudioStream.
Definition: SDL3pp_audio.h:788
constexpr Uint16 AudioByteSize(AudioFormatRaw x)
Retrieve the size, in bytes, from an AudioFormat.
Definition: SDL3pp_audio.h:536
void PutDataNoCopy(SourceBytes buf, AudioStreamDataCompleteCallback callback, void *userdata)
Add external data to an audio stream without copying it.
Definition: SDL3pp_audio.h:4329
void Clear()
Clear any pending data in the stream.
Definition: SDL3pp_audio.h:4571
float GetAudioStreamFrequencyRatio(AudioStreamParam stream)
Get the frequency ratio of an audio stream.
Definition: SDL3pp_audio.h:3881
void Flush()
Tell the stream that you're done sending data, and anything being buffered should be converted/resamp...
Definition: SDL3pp_audio.h:4546
void PauseAudioDevice(AudioDeviceParam devid)
Use this function to pause audio playback on a specified device.
Definition: SDL3pp_audio.h:3405
void ResumeAudioDevice(AudioDeviceParam devid)
Use this function to unpause audio playback on a specified device.
Definition: SDL3pp_audio.h:3436
void SetGain(float gain)
Change the gain of an audio stream.
Definition: SDL3pp_audio.h:3982
const char * GetName() const
Get the human readable name of an audio format.
Definition: SDL3pp_audio.h:5476
void PutAudioStreamPlanarData(AudioStreamParam stream, const void *const *channel_buffers, int num_channels, int num_samples)
Add data to the stream with each channel in a separate array.
Definition: SDL3pp_audio.h:4390
void ResumeAudioStreamDevice(AudioStreamParam stream)
Use this function to unpause audio playback on the audio device associated with an audio stream.
Definition: SDL3pp_audio.h:4624
std::function< void(const void *buf, int buflen)> AudioStreamDataCompleteCB
A callback that fires for completed AudioStream.PutDataNoCopy() data.
Definition: SDL3pp_audio.h:1663
void CloseAudioDevice(AudioDeviceID devid)
Close a previously-opened audio device.
Definition: SDL3pp_audio.h:3565
constexpr Uint16 GetBitSize() const
Retrieve the size, in bits, from an AudioFormat.
Definition: SDL3pp_audio.h:519
constexpr int AudioFrameSize(const AudioSpec &x)
Calculate the size of each audio frame (in bytes) from an AudioSpec.
Definition: SDL3pp_audio.h:1599
void Destroy()
Free an audio stream.
Definition: SDL3pp_audio.h:4954
constexpr bool IsUnsigned() const
Determine if an AudioFormat represents unsigned data.
Definition: SDL3pp_audio.h:664
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:341
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:289
::Uint16 Uint16
An unsigned 16-bit integer type.
Definition: SDL3pp_stdinc.h:315
Main include header for the SDL3pp library.
Safely wrap AudioDevice for non owning parameters.
Definition: SDL3pp_audio.h:132
AudioDeviceID value
parameter's AudioDeviceID
Definition: SDL3pp_audio.h:133
constexpr AudioDeviceParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_audio.h:142
constexpr auto operator<=>(const AudioDeviceParam &other) const =default
Comparison.
constexpr AudioDeviceParam(AudioDeviceID value)
Constructs from AudioDeviceID.
Definition: SDL3pp_audio.h:136
Semi-safe reference for AudioDevice.
Definition: SDL3pp_audio.h:1525
AudioDeviceRef(AudioDeviceID resource) noexcept
Constructs from AudioDeviceParam.
Definition: SDL3pp_audio.h:1547
AudioDeviceRef(const AudioDeviceRef &other) noexcept
Copy constructor.
Definition: SDL3pp_audio.h:1553
AudioDeviceRef(AudioDeviceParam resource) noexcept
Constructs from AudioDeviceParam.
Definition: SDL3pp_audio.h:1535
~AudioDeviceRef()
Destructor.
Definition: SDL3pp_audio.h:1559
Safely wrap AudioStream for non owning parameters.
Definition: SDL3pp_audio.h:168
AudioStreamRaw value
parameter's AudioStreamRaw
Definition: SDL3pp_audio.h:169
constexpr auto operator<=>(const AudioStreamParam &other) const =default
Comparison.
constexpr AudioStreamParam(AudioStreamRaw value)
Constructs from AudioStreamRaw.
Definition: SDL3pp_audio.h:172
constexpr AudioStreamParam(std::nullptr_t _=nullptr)
Constructs null/invalid.
Definition: SDL3pp_audio.h:178
Semi-safe reference for AudioStream.
Definition: SDL3pp_audio.h:2969
~AudioStreamRef()
Destructor.
Definition: SDL3pp_audio.h:3003
AudioStreamRef(AudioStreamParam resource) noexcept
Constructs from AudioStreamParam.
Definition: SDL3pp_audio.h:2979
AudioStreamRef(AudioStreamRaw resource) noexcept
Constructs from AudioStreamParam.
Definition: SDL3pp_audio.h:2991
AudioStreamRef(const AudioStreamRef &other) noexcept
Copy constructor.
Definition: SDL3pp_audio.h:2997
Definition: SDL3pp_callbackWrapper.h:20
Safely wrap IOStream for non owning parameters.
Definition: SDL3pp_iostream.h:34
Definition: SDL3pp_callbackWrapper.h:169
Semi-safe reference for Properties.
Definition: SDL3pp_properties.h:711