4#include <SDL3/SDL_audio.h>
5#include "SDL3pp_iostream.h"
6#include "SDL3pp_properties.h"
7#include "SDL3pp_stdinc.h"
228 : m_audioFormat(audioFormat)
301 constexpr bool IsFloat()
const;
353 constexpr bool IsInt()
const;
467 AudioFormatRaw(SDL_DEFINE_AUDIO_FORMAT(sign, bigendian, flt, size)))
504 return SDL_AUDIO_BYTESIZE(x);
545 return SDL_AUDIO_ISBIGENDIAN(x);
567 return SDL_AUDIO_ISLITTLEENDIAN(x);
627 return SDL_AUDIO_ISUNSIGNED(x);
755 int additional_amount,
800 void(
AudioStreamRaw stream,
int additional_amount,
int total_amount)>;
1357 using AudioDeviceBase::AudioDeviceBase;
1471 SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK;
1483 SDL_AUDIO_DEVICE_DEFAULT_RECORDING;
1502 return SDL_AUDIO_FRAMESIZE(x);
1505#if SDL_VERSION_ATLEAST(3, 4, 0)
1564 std::function<void(
const void* buf,
int buflen)>;
2043#if SDL_VERSION_ATLEAST(3, 4, 0)
2587#if SDL_VERSION_ATLEAST(3, 4, 0)
2673 using AudioStreamBase::AudioStreamBase;
2783 void* userdata =
nullptr);
2930 : m_lock(std::move(other.m_lock))
2948 if (!m_lock)
return;
2949 SDL_UnlockAudioStream(m_lock);
2957 std::swap(m_lock, other.m_lock);
2962 constexpr operator bool()
const {
return bool(m_lock); }
3034 return SDL_GetAudioDriver(index);
3053 return SDL_GetCurrentAudioDriver();
3083 auto data =
CheckError(SDL_GetAudioPlaybackDevices(&count));
3115 auto data =
CheckError(SDL_GetAudioRecordingDevices(&count));
3145 return CheckError(SDL_GetAudioDeviceName(devid));
3184 int* sample_frames =
nullptr)
3187 CheckError(SDL_GetAudioDeviceFormat(devid, &spec, sample_frames));
3218 auto data = SDL_GetAudioDeviceChannelMap(devid, &count);
3334 return SDL_IsAudioDevicePhysical(devid);
3356 return SDL_IsAudioDevicePlayback(devid);
3452 return SDL_AudioDevicePaused(devid);
3483 return SDL_GetAudioDeviceGain(devid);
3525 CheckError(SDL_SetAudioDeviceGain(devid, gain));
3553 SDL_CloseAudioDevice(devid);
3595 std::span<AudioStreamRef> streams)
3599 reinterpret_cast<SDL_AudioStream* const*
>(streams.data()),
3628 CheckError(SDL_BindAudioStream(devid, stream));
3656 SDL_UnbindAudioStreams(
3657 reinterpret_cast<SDL_AudioStream* const*
>(streams.data()),
3677 SDL_UnbindAudioStream(stream);
3702 return SDL_GetAudioStreamDevice(stream);
3754 CheckError(SDL_OpenAudioDeviceStream(devid, spec, callback, userdata)))
3793 return CheckError(SDL_GetAudioStreamProperties(stream));
3801#if SDL_VERSION_ATLEAST(3, 4, 0)
3818 SDL_PROP_AUDIOSTREAM_AUTO_CLEANUP_BOOLEAN;
3843 CheckError(SDL_GetAudioStreamFormat(stream, src_spec, dst_spec));
3893 CheckError(SDL_SetAudioStreamFormat(stream, src_spec, dst_spec));
3918 return SDL_GetAudioStreamFrequencyRatio(stream);
3953 CheckError(SDL_SetAudioStreamFrequencyRatio(stream, ratio));
3982 return SDL_GetAudioStreamGain(stream);
4014 CheckError(SDL_SetAudioStreamGain(stream, gain));
4045 auto data = SDL_GetAudioStreamInputChannelMap(stream, &count);
4046 if (!data)
return {};
4078 auto data = SDL_GetAudioStreamOutputChannelMap(stream, &count);
4079 if (!data)
return {};
4145 std::span<int> chmap)
4147 CheckError(SDL_SetAudioStreamInputChannelMap(
4148 stream, chmap.data(),
narrowS32(chmap.size())));
4211 std::span<int> chmap)
4213 CheckError(SDL_SetAudioStreamOutputChannelMap(
4214 stream, chmap.data(),
narrowS32(chmap.size())));
4259#if SDL_VERSION_ATLEAST(3, 4, 0)
4362 Wrapper::Wrap(std::move(callback)));
4428 const void*
const* channel_buffers,
4433 stream, channel_buffers, num_channels, num_samples));
4441 get(), channel_buffers, num_channels, num_samples);
4475 return SDL_GetAudioStreamData(
4509 return SDL_GetAudioStreamAvailable(stream);
4554 return SDL_GetAudioStreamQueued(stream);
4634 CheckError(SDL_PauseAudioStreamDevice(stream));
4664 CheckError(SDL_ResumeAudioStreamDevice(stream));
4691 return SDL_AudioStreamDevicePaused(stream);
4773 std::move(lock).reset();
4778 if (!m_lock)
return;
4828 CheckError(SDL_SetAudioStreamGetCallback(stream, callback, userdata));
4936 CheckError(SDL_SetAudioStreamPutCallback(stream, callback, userdata));
5019 SDL_DestroyAudioStream(stream);
5084 void* userdata =
nullptr)
5086 return AudioStream(devid, spec, callback, userdata);
5219 CheckError(SDL_SetAudioPostmixCallback(devid, callback, userdata));
5363 if (!SDL_LoadWAV_IO(src.
stream, src.
closeio, spec, &buf, &len))
return {};
5400 if (!SDL_LoadWAV(path, spec, &buf, &len))
return {};
5517 CheckError(SDL_ConvertAudioSamples(&src_spec,
5539 return SDL_GetAudioFormatName(format);
5562 return SDL_GetSilenceValueForFormat(format);
Lock an audio stream for serialized access.
Definition SDL3pp_audio.h:2883
AudioStreamLock & operator=(AudioStreamLock &&other) noexcept
Assignment operator.
Definition SDL3pp_audio.h:2955
void release()
Releases the lock without unlocking.
Definition SDL3pp_audio.h:2984
AudioStreamRef resource() const
Get the reference to locked resource.
Definition SDL3pp_audio.h:2981
AudioStreamLock(AudioStreamLock &&other) noexcept
Move constructor.
Definition SDL3pp_audio.h:2929
AudioStreamLock(const AudioStreamLock &other)=delete
Copy constructor.
~AudioStreamLock()
Unlock an audio stream for serialized access.
Definition SDL3pp_audio.h:2946
Optional-like shim for references.
Definition SDL3pp_optionalRef.h:20
Base class for SDL memory allocated array wrap.
Definition SDL3pp_ownPtr.h:44
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:57
friend constexpr void swap(ResourceBaseT &lhs, ResourceBaseT &rhs) noexcept
Definition SDL3pp_resource.h:65
constexpr RawPointer get() const noexcept
Definition SDL3pp_resource.h:54
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
Source byte stream.
Definition SDL3pp_strings.h:246
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition SDL3pp_strings.h:310
constexpr const char * data() const
Retrieves contained data.
Definition SDL3pp_strings.h:313
constexpr const T * data_as() const
Retrieves contained data.
Definition SDL3pp_strings.h:320
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:58
Target byte stream.
Definition SDL3pp_strings.h:332
constexpr char * data() const
Retrieves contained data.
Definition SDL3pp_strings.h:418
constexpr T * data_as() const
Retrieves contained data.
Definition SDL3pp_strings.h:422
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition SDL3pp_strings.h:415
#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:524
void SetAudioStreamInputChannelMap(AudioStreamRef stream, std::span< int > chmap)
Set the current input channel map of an audio stream.
Definition SDL3pp_audio.h:4144
void PutAudioStreamData(AudioStreamRef stream, SourceBytes buf)
Add data to the stream.
Definition SDL3pp_audio.h:4248
constexpr AudioFormat AUDIO_UNKNOWN
Unspecified audio format.
Definition SDL3pp_audio.h:402
void SetAudioStreamOutputChannelMap(AudioStreamRef stream, std::span< int > chmap)
Set the current output channel map of an audio stream.
Definition SDL3pp_audio.h:4210
constexpr bool IsLittleEndian() const
Determine if an AudioFormat represents littleendian data.
Definition SDL3pp_audio.h:570
constexpr bool IsBigEndian() const
Determine if an AudioFormat represents bigendian data.
Definition SDL3pp_audio.h:548
constexpr bool IsAudioInt(AudioFormatRaw x)
Determine if an AudioFormat represents integer data.
Definition SDL3pp_audio.h:606
bool IsAudioDevicePlayback(AudioDeviceRef devid)
Determine if an audio device is a playback device (instead of recording).
Definition SDL3pp_audio.h:3354
bool AudioDevicePaused(AudioDeviceRef devid)
Use this function to query if an audio device is paused.
Definition SDL3pp_audio.h:3450
void BindAudioStreams(AudioDeviceRef devid, std::span< AudioStreamRef > streams)
Bind a list of audio streams to an audio device.
Definition SDL3pp_audio.h:3594
AudioDevice OpenAudioDevice(AudioDeviceRef devid, OptionalRef< const AudioSpec > spec)
Open a specific audio device.
Definition SDL3pp_audio.h:3297
constexpr Uint32 AUDIO_MASK_SIGNED
Mask of bits in an AudioFormat that contain the signed data flag.
Definition SDL3pp_audio.h:192
constexpr Uint32 AUDIO_MASK_BITSIZE
Mask of bits in an AudioFormat that contains the format bit size.
Definition SDL3pp_audio.h:164
void BindAudioStream(AudioDeviceRef devid, AudioStreamRef stream)
Bind a single audio stream to an audio device.
Definition SDL3pp_audio.h:3626
void PutData(SourceBytes buf)
Add data to the stream.
Definition SDL3pp_audio.h:4254
constexpr AudioFormat AUDIO_S8
Signed 8-bit samples.
Definition SDL3pp_audio.h:407
constexpr Uint32 AUDIO_MASK_FLOAT
Mask of bits in an AudioFormat that contain the floating point flag.
Definition SDL3pp_audio.h:173
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:5511
float GetGain() const
Get the gain of an audio stream.
Definition SDL3pp_audio.h:3985
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:670
AudioStreamLock(AudioStreamRef resource)
Lock an audio stream for serialized access.
Definition SDL3pp_audio.h:4744
void GetAudioStreamFormat(AudioStreamRef stream, AudioSpec *src_spec, AudioSpec *dst_spec)
Query the current format of an audio stream.
Definition SDL3pp_audio.h:3839
constexpr bool IsAudioUnsigned(AudioFormatRaw x)
Determine if an AudioFormat represents unsigned data.
Definition SDL3pp_audio.h:625
int GetSilenceValueForFormat(AudioFormatRaw format)
Get the appropriate memset value for silencing an audio format.
Definition SDL3pp_audio.h:5560
void Pause()
Use this function to pause audio playback on a specified device.
Definition SDL3pp_audio.h:3397
constexpr AudioFormat AUDIO_S16
AUDIO_S16.
Definition SDL3pp_audio.h:425
int GetData(TargetBytes buf)
Get converted/resampled data from the stream.
Definition SDL3pp_audio.h:4479
bool IsAudioDevicePhysical(AudioDeviceRef devid)
Determine if an audio device is physical (instead of logical).
Definition SDL3pp_audio.h:3332
constexpr AudioFormat AUDIO_F32LE
32-bit floating point samples
Definition SDL3pp_audio.h:419
OwnArray< Uint8 > LoadWAV_IO(IOStreamParam src, AudioSpec *spec)
Load the audio data of a WAVE file into memory.
Definition SDL3pp_audio.h:5359
std::function< void(const void *buf, int buflen)> AudioStreamDataCompleteCB
A callback that fires for completed PutAudioStreamDataNoCopy() data.
Definition SDL3pp_audio.h:1563
void Clear()
Clear any pending data in the stream.
Definition SDL3pp_audio.h:4609
constexpr Uint16 GetByteSize() const
Retrieve the size, in bytes, from an AudioFormat.
Definition SDL3pp_audio.h:507
void PauseAudioStreamDevice(AudioStreamRef stream)
Use this function to pause audio playback on the audio device associated with an audio stream.
Definition SDL3pp_audio.h:4632
const char * GetCurrentAudioDriver()
Get the name of the current audio driver.
Definition SDL3pp_audio.h:3051
void BindAudioStreams(std::span< AudioStreamRef > streams)
Bind a list of audio streams to an audio device.
Definition SDL3pp_audio.h:3603
float GetAudioDeviceGain(AudioDeviceRef devid)
Get the gain of an audio device.
Definition SDL3pp_audio.h:3481
float GetAudioStreamGain(AudioStreamRef stream)
Get the gain of an audio stream.
Definition SDL3pp_audio.h:3980
constexpr bool IsAudioSigned(AudioFormatRaw x)
Determine if an AudioFormat represents signed data.
Definition SDL3pp_audio.h:587
void ResumeAudioStreamDevice(AudioStreamRef stream)
Use this function to unpause audio playback on the audio device associated with an audio stream.
Definition SDL3pp_audio.h:4662
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:3889
const char * GetAudioFormatName(AudioFormatRaw format)
Get the human readable name of an audio format.
Definition SDL3pp_audio.h:5537
const char * GetAudioDeviceName(AudioDeviceRef devid)
Get the human-readable name of a specific audio device.
Definition SDL3pp_audio.h:3143
void SetInputChannelMap(std::span< int > chmap)
Set the current input channel map of an audio stream.
Definition SDL3pp_audio.h:4151
void UnlockAudioStream(AudioStreamRef stream)
Unlock an audio stream for serialized access.
Definition SDL3pp_audio.h:4765
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:4604
OwnArray< int > GetChannelMap() const
Get the current channel map of an audio device.
Definition SDL3pp_audio.h:3222
AudioStream OpenStream(OptionalRef< const AudioSpec > spec, AudioStreamCallback callback, void *userdata)
Convenience function for straightforward audio init for the common case.
Definition SDL3pp_audio.h:5149
AudioDeviceRef GetDevice() const
Query an audio stream for its currently-bound device.
Definition SDL3pp_audio.h:3705
constexpr AudioFormat AUDIO_U8
Unsigned 8-bit samples.
Definition SDL3pp_audio.h:405
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:3896
int GetQueued() const
Get the number of bytes currently queued.
Definition SDL3pp_audio.h:4557
constexpr Uint16 AudioBitSize(AudioFormatRaw x)
Retrieve the size, in bits, from an AudioFormat.
Definition SDL3pp_audio.h:483
constexpr AudioFormat AUDIO_S32
AUDIO_S32.
Definition SDL3pp_audio.h:427
OwnArray< int > GetInputChannelMap() const
Get the current input channel map of an audio stream.
Definition SDL3pp_audio.h:4050
const char * GetName() const
Get the human-readable name of a specific audio device.
Definition SDL3pp_audio.h:3148
void Close()
Close a previously-opened audio device.
Definition SDL3pp_audio.h:3556
int GetSilenceValue() const
Get the appropriate memset value for silencing an audio format.
Definition SDL3pp_audio.h:5565
constexpr bool IsAudioLittleEndian(AudioFormatRaw x)
Determine if an AudioFormat represents littleendian data.
Definition SDL3pp_audio.h:565
constexpr AudioFormat AUDIO_S16LE
Signed 16-bit samples.
Definition SDL3pp_audio.h:409
void SetGain(float gain)
Change the gain of an audio stream.
Definition SDL3pp_audio.h:4017
constexpr Uint32 AUDIO_MASK_BIG_ENDIAN
Mask of bits in an AudioFormat that contain the bigendian flag.
Definition SDL3pp_audio.h:183
float GetAudioStreamFrequencyRatio(AudioStreamRef stream)
Get the frequency ratio of an audio stream.
Definition SDL3pp_audio.h:3916
void SetAudioStreamGain(AudioStreamRef stream, float gain)
Change the gain of an audio stream.
Definition SDL3pp_audio.h:4012
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:4579
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:4427
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:753
void BindAudioStream(AudioStreamRef stream)
Bind a single audio stream to an audio device.
Definition SDL3pp_audio.h:3631
PropertiesRef GetAudioStreamProperties(AudioStreamRef stream)
Get the properties associated with an audio stream.
Definition SDL3pp_audio.h:3791
void UnbindAudioStream(AudioStreamRef stream)
Unbind a single audio stream from its audio device.
Definition SDL3pp_audio.h:3675
OwnArray< AudioDeviceRef > GetAudioRecordingDevices()
Get a list of currently-connected audio recording devices.
Definition SDL3pp_audio.h:3112
void GetFormat(AudioSpec *src_spec, AudioSpec *dst_spec) const
Query the current format of an audio stream.
Definition SDL3pp_audio.h:3846
void SetGain(float gain)
Change the gain of an audio device.
Definition SDL3pp_audio.h:3528
void PauseAudioDevice(AudioDeviceRef devid)
Use this function to pause audio playback on a specified device.
Definition SDL3pp_audio.h:3392
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:709
void reset()
Unlock an audio stream for serialized access.
Definition SDL3pp_audio.h:4776
SDL_AudioSpec AudioSpec
Format specifier for audio data.
Definition SDL3pp_audio.h:201
constexpr AudioFormat AUDIO_S32BE
As above, but big-endian byte order.
Definition SDL3pp_audio.h:416
void SetGetCallback(AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is requested from an audio stream.
Definition SDL3pp_audio.h:4876
void Flush()
Tell the stream that you're done sending data, and anything being buffered should be converted/resamp...
Definition SDL3pp_audio.h:4584
const char * GetAudioDriver(int index)
Use this function to get the name of a built in audio driver.
Definition SDL3pp_audio.h:3032
bool Paused() const
Use this function to query if an audio device is paused.
Definition SDL3pp_audio.h:3455
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:5215
constexpr AudioDeviceID AUDIO_DEVICE_DEFAULT_RECORDING
A value used to request a default recording audio device.
Definition SDL3pp_audio.h:1482
void Resume()
Use this function to unpause audio playback on a specified device.
Definition SDL3pp_audio.h:3428
constexpr AudioFormat DefineAudioFormat(bool sign, bool bigendian, bool flt, Uint16 size)
Define an AudioFormat value.
Definition SDL3pp_audio.h:454
AudioDeviceRef GetAudioStreamDevice(AudioStreamRef stream)
Query an audio stream for its currently-bound device.
Definition SDL3pp_audio.h:3700
constexpr AudioDeviceID AUDIO_DEVICE_DEFAULT_PLAYBACK
A value used to request a default playback audio device.
Definition SDL3pp_audio.h:1470
constexpr AudioFormat AUDIO_S32LE
32-bit integer samples
Definition SDL3pp_audio.h:414
void PutDataNoCopy(SourceBytes buf, AudioStreamDataCompleteCallback callback, void *userdata)
Add external data to an audio stream without copying it.
Definition SDL3pp_audio.h:4365
constexpr bool IsInt() const
Determine if an AudioFormat represents integer data.
Definition SDL3pp_audio.h:608
int GetAudioStreamQueued(AudioStreamRef stream)
Get the number of bytes currently queued.
Definition SDL3pp_audio.h:4552
void MixAudio(Uint8 *dst, SourceBytes src, AudioFormat format, float volume)
Mix audio data in a specified format.
Definition SDL3pp_audio.h:5435
AudioSpec GetAudioDeviceFormat(AudioDeviceRef devid, int *sample_frames=nullptr)
Get the current audio format of a specific audio device.
Definition SDL3pp_audio.h:3183
void(SDLCALL *)(void *userdata, const void *buf, int buflen) AudioStreamDataCompleteCallback
A callback that fires for completed PutAudioStreamDataNoCopy() data.
Definition SDL3pp_audio.h:1533
OwnArray< int > GetOutputChannelMap() const
Get the current output channel map of an audio stream.
Definition SDL3pp_audio.h:4083
AudioStream CreateAudioStream(OptionalRef< const AudioSpec > src_spec, OptionalRef< const AudioSpec > dst_spec)
Create a new audio stream.
Definition SDL3pp_audio.h:3737
OwnArray< Uint8 > LoadWAV(StringParam path, AudioSpec *spec)
Loads a WAV from a file path.
Definition SDL3pp_audio.h:5396
constexpr bool IsFloat() const
Determine if an AudioFormat represents floating point data.
Definition SDL3pp_audio.h:526
PropertiesRef GetProperties() const
Get the properties associated with an audio stream.
Definition SDL3pp_audio.h:3796
float GetFrequencyRatio() const
Get the frequency ratio of an audio stream.
Definition SDL3pp_audio.h:3921
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:5278
void SetFrequencyRatio(float ratio)
Change the frequency ratio of an audio stream.
Definition SDL3pp_audio.h:3956
void SetAudioDeviceGain(AudioDeviceRef devid, float gain)
Change the gain of an audio device.
Definition SDL3pp_audio.h:3523
bool IsPlayback() const
Determine if an audio device is a playback device (instead of recording).
Definition SDL3pp_audio.h:3359
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:4932
constexpr AudioFormat AUDIO_F32BE
As above, but big-endian byte order.
Definition SDL3pp_audio.h:422
constexpr AudioFormat AUDIO_F32
AUDIO_F32.
Definition SDL3pp_audio.h:429
int GetNumAudioDrivers()
Use this function to get the number of built-in audio drivers.
Definition SDL3pp_audio.h:3008
bool IsPhysical() const
Determine if an audio device is physical (instead of logical).
Definition SDL3pp_audio.h:3337
void UnbindAudioStreams(std::span< AudioStreamRef > streams)
Unbind a list of audio streams from their audio devices.
Definition SDL3pp_audio.h:3654
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:5081
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:4436
OwnArray< int > GetAudioDeviceChannelMap(AudioDeviceRef devid)
Get the current channel map of an audio device.
Definition SDL3pp_audio.h:3215
void SetPutCallback(AudioStreamCallback callback, void *userdata)
Set a callback that runs when data is added to an audio stream.
Definition SDL3pp_audio.h:4988
ResourceRefT< AudioStreamBase > AudioStreamRef
Reference for AudioStream.
Definition SDL3pp_audio.h:152
void ResumeDevice()
Use this function to unpause audio playback on the audio device associated with an audio stream.
Definition SDL3pp_audio.h:4667
void SetOutputChannelMap(std::span< int > chmap)
Set the current output channel map of an audio stream.
Definition SDL3pp_audio.h:4217
void DestroyAudioStream(AudioStreamRaw stream)
Free an audio stream.
Definition SDL3pp_audio.h:5017
constexpr bool IsSigned() const
Determine if an AudioFormat represents signed data.
Definition SDL3pp_audio.h:589
SDL_AudioDeviceID AudioDeviceID
Alias to raw representation for AudioDevice.
Definition SDL3pp_audio.h:129
constexpr bool IsAudioBigENDIAN(AudioFormatRaw x)
Determine if an AudioFormat represents bigendian data.
Definition SDL3pp_audio.h:543
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:799
void Unbind()
Unbind a single audio stream from its audio device.
Definition SDL3pp_audio.h:3680
bool DevicePaused() const
Use this function to query if an audio device associated with a stream is paused.
Definition SDL3pp_audio.h:4694
constexpr AudioFormat AUDIO_S16BE
As above, but big-endian byte order.
Definition SDL3pp_audio.h:411
OwnArray< int > GetAudioStreamOutputChannelMap(AudioStreamRef stream)
Get the current output channel map of an audio stream.
Definition SDL3pp_audio.h:4075
OwnArray< AudioDeviceRef > GetAudioPlaybackDevices()
Get a list of currently-connected audio playback devices.
Definition SDL3pp_audio.h:3080
OwnArray< int > GetAudioStreamInputChannelMap(AudioStreamRef stream)
Get the current input channel map of an audio stream.
Definition SDL3pp_audio.h:4042
ResourceRefT< AudioDeviceBase > AudioDeviceRef
Reference for AudioDevice.
Definition SDL3pp_audio.h:136
int GetAudioStreamAvailable(AudioStreamRef stream)
Get the number of converted/resampled bytes available.
Definition SDL3pp_audio.h:4507
void Destroy()
Free an audio stream.
Definition SDL3pp_audio.h:5022
constexpr Uint16 AudioByteSize(AudioFormatRaw x)
Retrieve the size, in bytes, from an AudioFormat.
Definition SDL3pp_audio.h:502
SDL_AudioStream * AudioStreamRaw
Alias to raw representation for AudioStream.
Definition SDL3pp_audio.h:145
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:4824
bool AudioStreamDevicePaused(AudioStreamRef stream)
Use this function to query if an audio device associated with a stream is paused.
Definition SDL3pp_audio.h:4689
void ResumeAudioDevice(AudioDeviceRef devid)
Use this function to unpause audio playback on a specified device.
Definition SDL3pp_audio.h:3423
AudioStreamLock Lock()
Lock an audio stream for serialized access.
Definition SDL3pp_audio.h:4739
void Unlock(AudioStreamLock &&lock)
Unlock an audio stream for serialized access.
Definition SDL3pp_audio.h:4770
void PutAudioStreamDataNoCopy(AudioStreamRef stream, SourceBytes buf, AudioStreamDataCompleteCallback callback, void *userdata)
Add external data to an audio stream without copying it.
Definition SDL3pp_audio.h:4304
float GetGain() const
Get the gain of an audio device.
Definition SDL3pp_audio.h:3486
const char * GetName() const
Get the human readable name of an audio format.
Definition SDL3pp_audio.h:5542
AudioSpec GetFormat(int *sample_frames=nullptr) const
Get the current audio format of a specific audio device.
Definition SDL3pp_audio.h:3191
void LockAudioStream(AudioStreamRef stream)
Lock an audio stream for serialized access.
Definition SDL3pp_audio.h:4734
int GetAvailable() const
Get the number of converted/resampled bytes available.
Definition SDL3pp_audio.h:4512
void CloseAudioDevice(AudioDeviceID devid)
Close a previously-opened audio device.
Definition SDL3pp_audio.h:3551
void SetAudioStreamFrequencyRatio(AudioStreamRef stream, float ratio)
Change the frequency ratio of an audio stream.
Definition SDL3pp_audio.h:3951
constexpr Uint16 GetBitSize() const
Retrieve the size, in bits, from an AudioFormat.
Definition SDL3pp_audio.h:485
void PauseDevice()
Use this function to pause audio playback on the audio device associated with an audio stream.
Definition SDL3pp_audio.h:4637
constexpr int AudioFrameSize(const AudioSpec &x)
Calculate the size of each audio frame (in bytes) from an AudioSpec.
Definition SDL3pp_audio.h:1500
int GetAudioStreamData(AudioStreamRef stream, TargetBytes buf)
Get converted/resampled data from the stream.
Definition SDL3pp_audio.h:4473
constexpr bool IsUnsigned() const
Determine if an AudioFormat represents unsigned data.
Definition SDL3pp_audio.h:630
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:199
ResourceRefT< PropertiesBase > PropertiesRef
Reference for Properties.
Definition SDL3pp_properties.h:56
::Uint16 Uint16
An unsigned 16-bit integer type.
Definition SDL3pp_stdinc.h:270
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition SDL3pp_stdinc.h:296
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition SDL3pp_stdinc.h:244
Properties for AudioStream.
Definition SDL3pp_audio.h:3815
constexpr auto AUTO_CLEANUP_BOOLEAN
Auto cleanup enabled.
Definition SDL3pp_audio.h:3817
Main include header for the SDL3pp library.
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition SDL3pp_stdinc.h:6262
Base class to AudioDevice.
Definition SDL3pp_audio.h:808
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
SDL Audio Device instance IDs.
Definition SDL3pp_audio.h:1356
~AudioDevice()
Destructor.
Definition SDL3pp_audio.h:1451
constexpr AudioDevice(AudioDeviceID resource) noexcept
Constructs from raw AudioDevice.
Definition SDL3pp_audio.h:1366
constexpr AudioDevice & operator=(AudioDevice &&other) noexcept
Assignment operator.
Definition SDL3pp_audio.h:1454
constexpr AudioDevice(AudioDevice &&other) noexcept
Move constructor.
Definition SDL3pp_audio.h:1372
Base class to AudioStream.
Definition SDL3pp_audio.h:1574
AudioSpec GetOutputFormat() const
Query the current output format of an audio stream.
Definition SDL3pp_audio.h:1652
void SetOutputFormat(const AudioSpec &spec)
Change the output format of an audio stream.
Definition SDL3pp_audio.h:1737
void SetInputFormat(const AudioSpec &spec)
Change the input format of an audio stream.
Definition SDL3pp_audio.h:1705
AudioSpec GetInputFormat() const
Query the current input format of an audio stream.
Definition SDL3pp_audio.h:1632
constexpr ResourceBaseT()=default
Default constructor, creates null/invalid resource.
The opaque handle that represents an audio stream.
Definition SDL3pp_audio.h:2672
~AudioStream()
Destructor.
Definition SDL3pp_audio.h:2843
constexpr AudioStream(AudioStream &&other) noexcept
Move constructor.
Definition SDL3pp_audio.h:2688
constexpr AudioStream(AudioStreamRaw resource) noexcept
Constructs from raw AudioStream.
Definition SDL3pp_audio.h:2682
constexpr AudioStream & operator=(AudioStream &&other) noexcept
Assignment operator.
Definition SDL3pp_audio.h:2846
Definition SDL3pp_callbackWrapper.h:20
Wrapper to be used as parameter to LoadFile_IO() and SaveFile_IO() and similar.
Definition SDL3pp_iostream.h:2243
IOStreamRef stream
The IOStream to read from or write to.
Definition SDL3pp_iostream.h:2244
bool closeio
Whether to close the IOStream after the operation.
Definition SDL3pp_iostream.h:2245
Definition SDL3pp_callbackWrapper.h:169
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:93