4#include <SDL3/SDL_audio.h>
5#include "SDL3pp_iostream.h"
6#include "SDL3pp_properties.h"
7#include "SDL3pp_stdinc.h"
217 : m_audioFormat(audioFormat)
290 constexpr bool IsFloat()
const;
342 constexpr bool IsInt()
const;
456 AudioFormatRaw(SDL_DEFINE_AUDIO_FORMAT(sign, bigendian, flt, size)))
493 return SDL_AUDIO_BYTESIZE(x);
534 return SDL_AUDIO_ISBIGENDIAN(x);
556 return SDL_AUDIO_ISLITTLEENDIAN(x);
616 return SDL_AUDIO_ISUNSIGNED(x);
742 int additional_amount,
785 void(
AudioStreamRaw stream,
int additional_amount,
int total_amount)>;
815 : m_resource(resource)
911 std::swap(m_resource, other.m_resource);
933 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
1552 SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK;
1564 SDL_AUDIO_DEVICE_DEFAULT_RECORDING;
1581 return SDL_AUDIO_FRAMESIZE(x);
1584#if SDL_VERSION_ATLEAST(3, 4, 0)
1643 std::function<void(
const void* buf,
int buflen)>;
1680 : m_resource(
nullptr)
1692 : m_resource(resource)
1792 void* userdata =
nullptr);
1857 std::swap(m_resource, other.m_resource);
1870 auto r = m_resource;
1871 m_resource =
nullptr;
1879 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
2344#if SDL_VERSION_ATLEAST(3, 4, 0)
2878#if SDL_VERSION_ATLEAST(3, 4, 0)
3063 : m_lock(std::move(other.m_lock))
3081 if (!m_lock)
return;
3082 SDL_UnlockAudioStream(m_lock);
3090 std::swap(m_lock, other.m_lock);
3095 constexpr operator bool()
const {
return bool(m_lock); }
3167 return SDL_GetAudioDriver(index);
3186 return SDL_GetCurrentAudioDriver();
3216 auto data =
CheckError(SDL_GetAudioPlaybackDevices(&count));
3248 auto data =
CheckError(SDL_GetAudioRecordingDevices(&count));
3278 return CheckError(SDL_GetAudioDeviceName(devid));
3317 int* sample_frames =
nullptr)
3320 CheckError(SDL_GetAudioDeviceFormat(devid, &spec, sample_frames));
3351 auto data = SDL_GetAudioDeviceChannelMap(devid, &count);
3438 : m_resource(
CheckError(SDL_OpenAudioDevice(devid, spec)))
3467 return SDL_IsAudioDevicePhysical(devid);
3489 return SDL_IsAudioDevicePlayback(devid);
3585 return SDL_AudioDevicePaused(devid);
3616 return SDL_GetAudioDeviceGain(devid);
3658 CheckError(SDL_SetAudioDeviceGain(devid, gain));
3686 SDL_CloseAudioDevice(devid);
3728 std::span<AudioStreamRef> streams)
3732 reinterpret_cast<SDL_AudioStream* const*
>(streams.data()),
3761 CheckError(SDL_BindAudioStream(devid, stream));
3789 SDL_UnbindAudioStreams(
3790 reinterpret_cast<SDL_AudioStream* const*
>(streams.data()),
3810 SDL_UnbindAudioStream(stream);
3835 return {SDL_GetAudioStreamDevice(stream)};
3871 : m_resource(
CheckError(SDL_CreateAudioStream(src_spec, dst_spec)))
3880 CheckError(SDL_OpenAudioDeviceStream(devid, spec, callback, userdata)))
3920 return {
CheckError(SDL_GetAudioStreamProperties(stream))};
3928#if SDL_VERSION_ATLEAST(3, 4, 0)
3930namespace prop::AudioStream {
3932constexpr auto _AUTO_CLEANUP_BOOLEAN =
3933 SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN;
3958 CheckError(SDL_GetAudioStreamFormat(stream, src_spec, dst_spec));
4005 CheckError(SDL_SetAudioStreamFormat(stream, src_spec, dst_spec));
4030 return SDL_GetAudioStreamFrequencyRatio(stream);
4065 CheckError(SDL_SetAudioStreamFrequencyRatio(stream, ratio));
4094 return SDL_GetAudioStreamGain(stream);
4126 CheckError(SDL_SetAudioStreamGain(stream, gain));
4157 auto data = SDL_GetAudioStreamInputChannelMap(stream, &count);
4158 if (!data)
return {};
4190 auto data = SDL_GetAudioStreamOutputChannelMap(stream, &count);
4191 if (!data)
return {};
4257 std::span<int> chmap)
4259 CheckError(SDL_SetAudioStreamInputChannelMap(
4260 stream, chmap.data(),
narrowS32(chmap.size())));
4323 std::span<int> chmap)
4325 CheckError(SDL_SetAudioStreamOutputChannelMap(
4326 stream, chmap.data(),
narrowS32(chmap.size())));
4371#if SDL_VERSION_ATLEAST(3, 4, 0)
4474 Wrapper::Wrap(std::move(callback)));
4488 m_resource, std::move(buf), std::move(callback));
4540 const void*
const* channel_buffers,
4545 stream, channel_buffers, num_channels, num_samples));
4553 m_resource, channel_buffers, num_channels, num_samples);
4587 return SDL_GetAudioStreamData(
4621 return SDL_GetAudioStreamAvailable(stream);
4666 return SDL_GetAudioStreamQueued(stream);
4746 CheckError(SDL_PauseAudioStreamDevice(stream));
4776 CheckError(SDL_ResumeAudioStreamDevice(stream));
4803 return SDL_AudioStreamDevicePaused(stream);
4872 std::move(lock).reset();
4877 if (!m_lock)
return;
4927 CheckError(SDL_SetAudioStreamGetCallback(stream, callback, userdata));
5035 CheckError(SDL_SetAudioStreamPutCallback(stream, callback, userdata));
5118 SDL_DestroyAudioStream(stream);
5183 void* userdata =
nullptr)
5185 return AudioStream(devid, spec, callback, userdata);
5252 return AudioStream(m_resource, spec, callback, userdata);
5316 CheckError(SDL_SetAudioPostmixCallback(devid, callback, userdata));
5455 bool closeio =
false)
5459 if (!SDL_LoadWAV_IO(src, closeio, spec, &buf, &len))
return {};
5491 if (!SDL_LoadWAV(path, spec, &buf, &len))
return {};
5608 CheckError(SDL_ConvertAudioSamples(&src_spec,
5630 return SDL_GetAudioFormatName(format);
5653 return SDL_GetSilenceValueForFormat(format);
SDL Audio Device instance IDs.
Definition SDL3pp_audio.h:797
constexpr AudioDeviceID get() const noexcept
Retrieves underlying AudioDeviceID.
Definition SDL3pp_audio.h:919
constexpr AudioDeviceID release() noexcept
Retrieves underlying AudioDeviceID and clear this.
Definition SDL3pp_audio.h:922
~AudioDevice()
Destructor.
Definition SDL3pp_audio.h:906
constexpr AudioDevice(AudioDeviceID resource) noexcept
Constructs from raw AudioDevice.
Definition SDL3pp_audio.h:814
constexpr AudioDevice(const AudioDevice &other) noexcept=delete
Copy constructor.
constexpr AudioDevice(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition SDL3pp_audio.h:802
AudioDevice & operator=(const AudioDevice &other)=delete
Assignment operator.
constexpr auto operator<=>(const AudioDevice &other) const noexcept=default
Comparison.
constexpr AudioDevice & operator=(AudioDevice &&other) noexcept
Assignment operator.
Definition SDL3pp_audio.h:909
constexpr AudioDevice(AudioDevice &&other) noexcept
Move constructor.
Definition SDL3pp_audio.h:823
Lock an audio stream for serialized access.
Definition SDL3pp_audio.h:3026
AudioStreamLock & operator=(AudioStreamLock &&other) noexcept
Assignment operator.
Definition SDL3pp_audio.h:3088
void release()
Releases the lock without unlocking.
Definition SDL3pp_audio.h:3117
AudioStreamRef resource() const
Get the reference to locked resource.
Definition SDL3pp_audio.h:3114
AudioStreamLock(AudioStreamLock &&other) noexcept
Move constructor.
Definition SDL3pp_audio.h:3062
AudioStreamLock(const AudioStreamLock &other)=delete
Copy constructor.
~AudioStreamLock()
Unlock an audio stream for serialized access.
Definition SDL3pp_audio.h:3079
The opaque handle that represents an audio stream.
Definition SDL3pp_audio.h:1674
AudioStream & operator=(const AudioStream &other)=delete
Assignment operator.
constexpr auto operator<=>(const AudioStream &other) const noexcept=default
Comparison.
~AudioStream()
Destructor.
Definition SDL3pp_audio.h:1852
AudioSpec GetOutputFormat() const
Query the current output format of an audio stream.
Definition SDL3pp_audio.h:1956
void SetOutputFormat(const AudioSpec &spec)
Change the output format of an audio stream.
Definition SDL3pp_audio.h:2041
constexpr AudioStream(AudioStream &&other) noexcept
Move constructor.
Definition SDL3pp_audio.h:1700
void SetInputFormat(const AudioSpec &spec)
Change the input format of an audio stream.
Definition SDL3pp_audio.h:2009
constexpr AudioStream(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition SDL3pp_audio.h:1679
constexpr AudioStreamRaw get() const noexcept
Retrieves underlying AudioStreamRaw.
Definition SDL3pp_audio.h:1865
constexpr AudioStream(AudioStreamRaw resource) noexcept
Constructs from raw AudioStream.
Definition SDL3pp_audio.h:1691
constexpr AudioStreamRaw release() noexcept
Retrieves underlying AudioStreamRaw and clear this.
Definition SDL3pp_audio.h:1868
AudioSpec GetInputFormat() const
Query the current input format of an audio stream.
Definition SDL3pp_audio.h:1936
constexpr AudioStream(const AudioStream &other) noexcept=delete
Copy constructor.
constexpr AudioStream & operator=(AudioStream &&other) noexcept
Assignment operator.
Definition SDL3pp_audio.h:1855
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:237
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition SDL3pp_strings.h:301
constexpr const char * data() const
Retrieves contained data.
Definition SDL3pp_strings.h:304
constexpr const T * data_as() const
Retrieves contained data.
Definition SDL3pp_strings.h:311
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
Target byte stream.
Definition SDL3pp_strings.h:323
constexpr char * data() const
Retrieves contained data.
Definition SDL3pp_strings.h:409
constexpr T * data_as() const
Retrieves contained data.
Definition SDL3pp_strings.h:413
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition SDL3pp_strings.h:406
#define SDL_assert_paranoid(condition)
An assertion test that is performed only when built with paranoid settings.
Definition SDL3pp_assert.h:383
constexpr bool IsAudioFloat(AudioFormatRaw x)
Determine if an AudioFormat represents floating point data.
Definition SDL3pp_audio.h:513
void SetAudioStreamInputChannelMap(AudioStreamRef stream, std::span< int > chmap)
Set the current input channel map of an audio stream.
Definition SDL3pp_audio.h:4256
void Pause()
Use this function to pause audio playback on a specified device.
Definition SDL3pp_audio.h:3530
void PutAudioStreamData(AudioStreamRef stream, SourceBytes buf)
Add data to the stream.
Definition SDL3pp_audio.h:4360
constexpr AudioFormat AUDIO_UNKNOWN
Unspecified audio format.
Definition SDL3pp_audio.h:391
void SetAudioStreamOutputChannelMap(AudioStreamRef stream, std::span< int > chmap)
Set the current output channel map of an audio stream.
Definition SDL3pp_audio.h:4322
AudioStream OpenStream(OptionalRef< const AudioSpec > spec, AudioStreamCallback callback, void *userdata)
Convenience function for straightforward audio init for the common case.
Definition SDL3pp_audio.h:5248
void Resume()
Use this function to unpause audio playback on a specified device.
Definition SDL3pp_audio.h:3561
constexpr bool IsLittleEndian() const
Determine if an AudioFormat represents littleendian data.
Definition SDL3pp_audio.h:559
constexpr bool IsBigEndian() const
Determine if an AudioFormat represents bigendian data.
Definition SDL3pp_audio.h:537
void BindAudioStreams(std::span< AudioStreamRef > streams)
Bind a list of audio streams to an audio device.
Definition SDL3pp_audio.h:3736
constexpr bool IsAudioInt(AudioFormatRaw x)
Determine if an AudioFormat represents integer data.
Definition SDL3pp_audio.h:595
bool IsAudioDevicePlayback(AudioDeviceRef devid)
Determine if an audio device is a playback device (instead of recording).
Definition SDL3pp_audio.h:3487
bool AudioDevicePaused(AudioDeviceRef devid)
Use this function to query if an audio device is paused.
Definition SDL3pp_audio.h:3583
void BindAudioStreams(AudioDeviceRef devid, std::span< AudioStreamRef > streams)
Bind a list of audio streams to an audio device.
Definition SDL3pp_audio.h:3727
AudioDevice OpenAudioDevice(AudioDeviceRef devid, OptionalRef< const AudioSpec > spec)
Open a specific audio device.
Definition SDL3pp_audio.h:3430
constexpr Uint32 AUDIO_MASK_SIGNED
Mask of bits in an AudioFormat that contain the signed data flag.
Definition SDL3pp_audio.h:181
constexpr Uint32 AUDIO_MASK_BITSIZE
Mask of bits in an AudioFormat that contains the format bit size.
Definition SDL3pp_audio.h:151
void BindAudioStream(AudioDeviceRef devid, AudioStreamRef stream)
Bind a single audio stream to an audio device.
Definition SDL3pp_audio.h:3759
void PauseDevice()
Use this function to pause audio playback on the audio device associated with an audio stream.
Definition SDL3pp_audio.h:4749
void GetFormat(AudioSpec *src_spec, AudioSpec *dst_spec) const
Query the current format of an audio stream.
Definition SDL3pp_audio.h:3961
constexpr AudioFormat AUDIO_S8
Signed 8-bit samples.
Definition SDL3pp_audio.h:396
constexpr Uint32 AUDIO_MASK_FLOAT
Mask of bits in an AudioFormat that contain the floating point flag.
Definition SDL3pp_audio.h:161
OwnArray< int > GetInputChannelMap() const
Get the current input channel map of an audio stream.
Definition SDL3pp_audio.h:4162
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:5602
void SetFrequencyRatio(float ratio)
Change the frequency ratio of an audio stream.
Definition SDL3pp_audio.h:4068
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:659
AudioStreamLock(AudioStreamRef resource)
Lock an audio stream for serialized access.
Definition SDL3pp_audio.h:4843
void GetAudioStreamFormat(AudioStreamRef stream, AudioSpec *src_spec, AudioSpec *dst_spec)
Query the current format of an audio stream.
Definition SDL3pp_audio.h:3954
constexpr bool IsAudioUnsigned(AudioFormatRaw x)
Determine if an AudioFormat represents unsigned data.
Definition SDL3pp_audio.h:614
int GetSilenceValueForFormat(AudioFormatRaw format)
Get the appropriate memset value for silencing an audio format.
Definition SDL3pp_audio.h:5651
int GetData(TargetBytes buf)
Get converted/resampled data from the stream.
Definition SDL3pp_audio.h:4591
constexpr AudioFormat AUDIO_S16
AUDIO_S16.
Definition SDL3pp_audio.h:414
bool IsAudioDevicePhysical(AudioDeviceRef devid)
Determine if an audio device is physical (instead of logical).
Definition SDL3pp_audio.h:3465
constexpr AudioFormat AUDIO_F32LE
32-bit floating point samples
Definition SDL3pp_audio.h:408
void SetPutCallback(AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is added to an audio stream.
Definition SDL3pp_audio.h:5087
std::function< void(const void *buf, int buflen)> AudioStreamDataCompleteCB
A callback that fires for completed AudioStream.PutDataNoCopy() data.
Definition SDL3pp_audio.h:1642
OwnArray< int > GetOutputChannelMap() const
Get the current output channel map of an audio stream.
Definition SDL3pp_audio.h:4195
constexpr Uint16 GetByteSize() const
Retrieve the size, in bytes, from an AudioFormat.
Definition SDL3pp_audio.h:496
void BindAudioStream(AudioStreamRef stream)
Bind a single audio stream to an audio device.
Definition SDL3pp_audio.h:3764
void PauseAudioStreamDevice(AudioStreamRef stream)
Use this function to pause audio playback on the audio device associated with an audio stream.
Definition SDL3pp_audio.h:4744
const char * GetCurrentAudioDriver()
Get the name of the current audio driver.
Definition SDL3pp_audio.h:3184
OwnArray< int > GetChannelMap() const
Get the current channel map of an audio device.
Definition SDL3pp_audio.h:3355
int GetAvailable() const
Get the number of converted/resampled bytes available.
Definition SDL3pp_audio.h:4624
float GetAudioDeviceGain(AudioDeviceRef devid)
Get the gain of an audio device.
Definition SDL3pp_audio.h:3614
float GetAudioStreamGain(AudioStreamRef stream)
Get the gain of an audio stream.
Definition SDL3pp_audio.h:4092
float GetFrequencyRatio() const
Get the frequency ratio of an audio stream.
Definition SDL3pp_audio.h:4033
constexpr bool IsAudioSigned(AudioFormatRaw x)
Determine if an AudioFormat represents signed data.
Definition SDL3pp_audio.h:576
void ResumeAudioStreamDevice(AudioStreamRef stream)
Use this function to unpause audio playback on the audio device associated with an audio stream.
Definition SDL3pp_audio.h:4774
void ResumeDevice()
Use this function to unpause audio playback on the audio device associated with an audio stream.
Definition SDL3pp_audio.h:4779
void SetAudioStreamFormat(AudioStreamRef 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:4001
const char * GetAudioFormatName(AudioFormatRaw format)
Get the human readable name of an audio format.
Definition SDL3pp_audio.h:5628
const char * GetAudioDeviceName(AudioDeviceRef devid)
Get the human-readable name of a specific audio device.
Definition SDL3pp_audio.h:3276
AudioStreamLock Lock()
Lock an audio stream for serialized access.
Definition SDL3pp_audio.h:4841
bool Paused() const
Use this function to query if an audio device is paused.
Definition SDL3pp_audio.h:3588
void UnlockAudioStream(AudioStreamRef stream)
Unlock an audio stream for serialized access.
Definition SDL3pp_audio.h:4864
SDL_AudioFormat AudioFormatRaw
Alias to raw representation for AudioFormat.
Definition SDL3pp_audio.h:117
void ClearAudioStream(AudioStreamRef stream)
Clear any pending data in the stream.
Definition SDL3pp_audio.h:4716
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:4548
constexpr AudioFormat AUDIO_U8
Unsigned 8-bit samples.
Definition SDL3pp_audio.h:394
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:4008
bool DevicePaused() const
Use this function to query if an audio device associated with a stream is paused.
Definition SDL3pp_audio.h:4806
constexpr Uint16 AudioBitSize(AudioFormatRaw x)
Retrieve the size, in bits, from an AudioFormat.
Definition SDL3pp_audio.h:472
constexpr AudioFormat AUDIO_S32
AUDIO_S32.
Definition SDL3pp_audio.h:416
int GetSilenceValue() const
Get the appropriate memset value for silencing an audio format.
Definition SDL3pp_audio.h:5656
constexpr bool IsAudioLittleEndian(AudioFormatRaw x)
Determine if an AudioFormat represents littleendian data.
Definition SDL3pp_audio.h:554
constexpr AudioFormat AUDIO_S16LE
Signed 16-bit samples.
Definition SDL3pp_audio.h:398
constexpr Uint32 AUDIO_MASK_BIG_ENDIAN
Mask of bits in an AudioFormat that contain the bigendian flag.
Definition SDL3pp_audio.h:171
float GetAudioStreamFrequencyRatio(AudioStreamRef stream)
Get the frequency ratio of an audio stream.
Definition SDL3pp_audio.h:4028
AudioSpec GetFormat(int *sample_frames=nullptr) const
Get the current audio format of a specific audio device.
Definition SDL3pp_audio.h:3324
void SetAudioStreamGain(AudioStreamRef stream, float gain)
Change the gain of an audio stream.
Definition SDL3pp_audio.h:4124
PropertiesRef GetProperties() const
Get the properties associated with an audio stream.
Definition SDL3pp_audio.h:3923
void FlushAudioStream(AudioStreamRef stream)
Tell the stream that you're done sending data, and anything being buffered should be converted/resamp...
Definition SDL3pp_audio.h:4691
void PutAudioStreamPlanarData(AudioStreamRef 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:4539
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:740
float GetGain() const
Get the gain of an audio stream.
Definition SDL3pp_audio.h:4097
PropertiesRef GetAudioStreamProperties(AudioStreamRef stream)
Get the properties associated with an audio stream.
Definition SDL3pp_audio.h:3918
void UnbindAudioStream(AudioStreamRef stream)
Unbind a single audio stream from its audio device.
Definition SDL3pp_audio.h:3808
OwnArray< AudioDeviceRef > GetAudioRecordingDevices()
Get a list of currently-connected audio recording devices.
Definition SDL3pp_audio.h:3245
void SetOutputChannelMap(std::span< int > chmap)
Set the current output channel map of an audio stream.
Definition SDL3pp_audio.h:4329
void PauseAudioDevice(AudioDeviceRef devid)
Use this function to pause audio playback on a specified device.
Definition SDL3pp_audio.h:3525
MakeFrontCallback< void(const AudioSpec *spec, float *buffer, int buflen)> AudioPostmixCB
A callback that fires when data is about to be fed to an audio device.
Definition SDL3pp_audio.h:698
void reset()
Unlock an audio stream for serialized access.
Definition SDL3pp_audio.h:4875
void SetGetCallback(AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is requested from an audio stream.
Definition SDL3pp_audio.h:4975
AudioDeviceRef GetDevice() const
Query an audio stream for its currently-bound device.
Definition SDL3pp_audio.h:3838
SDL_AudioSpec AudioSpec
Format specifier for audio data.
Definition SDL3pp_audio.h:190
constexpr AudioFormat AUDIO_S32BE
As above, but big-endian byte order.
Definition SDL3pp_audio.h:405
const char * GetAudioDriver(int index)
Use this function to get the name of a built in audio driver.
Definition SDL3pp_audio.h:3165
bool IsPlayback() const
Determine if an audio device is a playback device (instead of recording).
Definition SDL3pp_audio.h:3492
void SetAudioPostmixCallback(AudioDeviceRef 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:5312
constexpr AudioDeviceID AUDIO_DEVICE_DEFAULT_RECORDING
A value used to request a default recording audio device.
Definition SDL3pp_audio.h:1563
constexpr AudioFormat DefineAudioFormat(bool sign, bool bigendian, bool flt, Uint16 size)
Define an AudioFormat value.
Definition SDL3pp_audio.h:443
AudioDeviceRef GetAudioStreamDevice(AudioStreamRef stream)
Query an audio stream for its currently-bound device.
Definition SDL3pp_audio.h:3833
OwnArray< Uint8 > LoadWAV_IO(IOStreamRef src, AudioSpec *spec, bool closeio=false)
Load the audio data of a WAVE file into memory.
Definition SDL3pp_audio.h:5453
constexpr AudioDeviceID AUDIO_DEVICE_DEFAULT_PLAYBACK
A value used to request a default playback audio device.
Definition SDL3pp_audio.h:1551
constexpr AudioFormat AUDIO_S32LE
32-bit integer samples
Definition SDL3pp_audio.h:403
void Close()
Close a previously-opened audio device.
Definition SDL3pp_audio.h:3689
constexpr bool IsInt() const
Determine if an AudioFormat represents integer data.
Definition SDL3pp_audio.h:597
int GetAudioStreamQueued(AudioStreamRef stream)
Get the number of bytes currently queued.
Definition SDL3pp_audio.h:4664
void MixAudio(Uint8 *dst, SourceBytes src, AudioFormat format, float volume)
Mix audio data in a specified format.
Definition SDL3pp_audio.h:5526
AudioSpec GetAudioDeviceFormat(AudioDeviceRef devid, int *sample_frames=nullptr)
Get the current audio format of a specific audio device.
Definition SDL3pp_audio.h:3316
void(SDLCALL *)(void *userdata, const void *buf, int buflen) AudioStreamDataCompleteCallback
A callback that fires for completed AudioStream.PutDataNoCopy() data.
Definition SDL3pp_audio.h:1612
AudioStream CreateAudioStream(OptionalRef< const AudioSpec > src_spec, OptionalRef< const AudioSpec > dst_spec)
Create a new audio stream.
Definition SDL3pp_audio.h:3863
void SetInputChannelMap(std::span< int > chmap)
Set the current input channel map of an audio stream.
Definition SDL3pp_audio.h:4263
void Unbind()
Unbind a single audio stream from its audio device.
Definition SDL3pp_audio.h:3813
OwnArray< Uint8 > LoadWAV(StringParam path, AudioSpec *spec)
Loads a WAV from a file path.
Definition SDL3pp_audio.h:5487
const char * GetName() const
Get the human-readable name of a specific audio device.
Definition SDL3pp_audio.h:3281
constexpr bool IsFloat() const
Determine if an AudioFormat represents floating point data.
Definition SDL3pp_audio.h:515
void SetAudioDeviceGain(AudioDeviceRef devid, float gain)
Change the gain of an audio device.
Definition SDL3pp_audio.h:3656
void SetAudioStreamPutCallback(AudioStreamRef stream, AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is added to an audio stream.
Definition SDL3pp_audio.h:5031
constexpr AudioFormat AUDIO_F32BE
As above, but big-endian byte order.
Definition SDL3pp_audio.h:411
constexpr AudioFormat AUDIO_F32
AUDIO_F32.
Definition SDL3pp_audio.h:418
int GetNumAudioDrivers()
Use this function to get the number of built-in audio drivers.
Definition SDL3pp_audio.h:3141
void UnbindAudioStreams(std::span< AudioStreamRef > streams)
Unbind a list of audio streams from their audio devices.
Definition SDL3pp_audio.h:3787
AudioStream OpenAudioDeviceStream(AudioDeviceRef 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:5180
int GetQueued() const
Get the number of bytes currently queued.
Definition SDL3pp_audio.h:4669
OwnArray< int > GetAudioDeviceChannelMap(AudioDeviceRef devid)
Get the current channel map of an audio device.
Definition SDL3pp_audio.h:3348
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:5375
bool IsPhysical() const
Determine if an audio device is physical (instead of logical).
Definition SDL3pp_audio.h:3470
void DestroyAudioStream(AudioStreamRaw stream)
Free an audio stream.
Definition SDL3pp_audio.h:5116
constexpr bool IsSigned() const
Determine if an AudioFormat represents signed data.
Definition SDL3pp_audio.h:578
SDL_AudioDeviceID AudioDeviceID
Alias to raw representation for AudioDevice.
Definition SDL3pp_audio.h:126
constexpr bool IsAudioBigENDIAN(AudioFormatRaw x)
Determine if an AudioFormat represents bigendian data.
Definition SDL3pp_audio.h:532
MakeFrontCallback< void(AudioStreamRaw stream, int additional_amount, int total_amount)> AudioStreamCB
A callback that fires when data passes through an AudioStream.
Definition SDL3pp_audio.h:784
void SetGain(float gain)
Change the gain of an audio device.
Definition SDL3pp_audio.h:3661
constexpr AudioFormat AUDIO_S16BE
As above, but big-endian byte order.
Definition SDL3pp_audio.h:400
void PutData(SourceBytes buf)
Add data to the stream.
Definition SDL3pp_audio.h:4366
OwnArray< int > GetAudioStreamOutputChannelMap(AudioStreamRef stream)
Get the current output channel map of an audio stream.
Definition SDL3pp_audio.h:4187
OwnArray< AudioDeviceRef > GetAudioPlaybackDevices()
Get a list of currently-connected audio playback devices.
Definition SDL3pp_audio.h:3213
float GetGain() const
Get the gain of an audio device.
Definition SDL3pp_audio.h:3619
OwnArray< int > GetAudioStreamInputChannelMap(AudioStreamRef stream)
Get the current input channel map of an audio stream.
Definition SDL3pp_audio.h:4154
int GetAudioStreamAvailable(AudioStreamRef stream)
Get the number of converted/resampled bytes available.
Definition SDL3pp_audio.h:4619
constexpr Uint16 AudioByteSize(AudioFormatRaw x)
Retrieve the size, in bytes, from an AudioFormat.
Definition SDL3pp_audio.h:491
void PutDataNoCopy(SourceBytes buf, AudioStreamDataCompleteCallback callback, void *userdata)
Add external data to an audio stream without copying it.
Definition SDL3pp_audio.h:4477
void Clear()
Clear any pending data in the stream.
Definition SDL3pp_audio.h:4721
SDL_AudioStream * AudioStreamRaw
Alias to raw representation for AudioStream.
Definition SDL3pp_audio.h:135
void SetAudioStreamGetCallback(AudioStreamRef stream, AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is requested from an audio stream.
Definition SDL3pp_audio.h:4923
void Flush()
Tell the stream that you're done sending data, and anything being buffered should be converted/resamp...
Definition SDL3pp_audio.h:4696
bool AudioStreamDevicePaused(AudioStreamRef stream)
Use this function to query if an audio device associated with a stream is paused.
Definition SDL3pp_audio.h:4801
void ResumeAudioDevice(AudioDeviceRef devid)
Use this function to unpause audio playback on a specified device.
Definition SDL3pp_audio.h:3556
void SetGain(float gain)
Change the gain of an audio stream.
Definition SDL3pp_audio.h:4129
void Unlock(AudioStreamLock &&lock)
Unlock an audio stream for serialized access.
Definition SDL3pp_audio.h:4869
void PutAudioStreamDataNoCopy(AudioStreamRef stream, SourceBytes buf, AudioStreamDataCompleteCallback callback, void *userdata)
Add external data to an audio stream without copying it.
Definition SDL3pp_audio.h:4416
const char * GetName() const
Get the human readable name of an audio format.
Definition SDL3pp_audio.h:5633
void LockAudioStream(AudioStreamRef stream)
Lock an audio stream for serialized access.
Definition SDL3pp_audio.h:4836
void CloseAudioDevice(AudioDeviceID devid)
Close a previously-opened audio device.
Definition SDL3pp_audio.h:3684
void SetAudioStreamFrequencyRatio(AudioStreamRef stream, float ratio)
Change the frequency ratio of an audio stream.
Definition SDL3pp_audio.h:4063
constexpr Uint16 GetBitSize() const
Retrieve the size, in bits, from an AudioFormat.
Definition SDL3pp_audio.h:474
constexpr int AudioFrameSize(const AudioSpec &x)
Calculate the size of each audio frame (in bytes) from an AudioSpec.
Definition SDL3pp_audio.h:1579
int GetAudioStreamData(AudioStreamRef stream, TargetBytes buf)
Get converted/resampled data from the stream.
Definition SDL3pp_audio.h:4585
void Destroy()
Free an audio stream.
Definition SDL3pp_audio.h:5121
constexpr bool IsUnsigned() const
Determine if an AudioFormat represents unsigned data.
Definition SDL3pp_audio.h:619
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:199
::Uint16 Uint16
An unsigned 16-bit integer type.
Definition SDL3pp_stdinc.h:255
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:281
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition SDL3pp_stdinc.h:229
Main include header for the SDL3pp library.
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition SDL3pp_stdinc.h:6425
Reference for AudioDevice.
Definition SDL3pp_audio.h:1476
constexpr AudioDeviceRef(AudioDeviceID resource) noexcept
Constructs from raw AudioDevice.
Definition SDL3pp_audio.h:1486
AudioDeviceRef & operator=(const AudioDeviceRef &other) noexcept
Assignment operator.
Definition SDL3pp_audio.h:1531
constexpr AudioDeviceRef(AudioDeviceRef &&other) noexcept
Move constructor.
Definition SDL3pp_audio.h:1522
constexpr AudioDevice(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition SDL3pp_audio.h:802
constexpr AudioDeviceRef(AudioDevice &&resource) noexcept
Constructs from AudioDevice.
Definition SDL3pp_audio.h:1510
constexpr AudioDeviceRef(const AudioDeviceRef &other) noexcept
Copy constructor.
Definition SDL3pp_audio.h:1516
~AudioDeviceRef()
Destructor.
Definition SDL3pp_audio.h:1528
constexpr AudioDeviceRef(const AudioDevice &resource) noexcept
Constructs from AudioDevice.
Definition SDL3pp_audio.h:1498
Reference for AudioStream.
Definition SDL3pp_audio.h:2941
constexpr AudioStreamRef(const AudioStream &resource) noexcept
Constructs from AudioStream.
Definition SDL3pp_audio.h:2963
constexpr AudioStreamRef(const AudioStreamRef &other) noexcept
Copy constructor.
Definition SDL3pp_audio.h:2981
AudioStreamRef & operator=(const AudioStreamRef &other) noexcept
Assignment operator.
Definition SDL3pp_audio.h:2996
~AudioStreamRef()
Destructor.
Definition SDL3pp_audio.h:2993
constexpr AudioStream(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition SDL3pp_audio.h:1679
constexpr AudioStreamRef(AudioStreamRef &&other) noexcept
Move constructor.
Definition SDL3pp_audio.h:2987
constexpr AudioStreamRef(AudioStream &&resource) noexcept
Constructs from AudioStream.
Definition SDL3pp_audio.h:2975
constexpr AudioStreamRef(AudioStreamRaw resource) noexcept
Constructs from raw AudioStream.
Definition SDL3pp_audio.h:2951
Definition SDL3pp_callbackWrapper.h:20
Reference for IOStream.
Definition SDL3pp_iostream.h:1627
Definition SDL3pp_callbackWrapper.h:169
Reference for Properties.
Definition SDL3pp_properties.h:687