4#include "SDL3pp_audio.h"
5#include "SDL3pp_version.h"
7#if defined(SDL3PP_ENABLE_MIXER) || defined(SDL3PP_DOC)
9#include <SDL3_mixer/SDL_mixer.h>
289 :
Mixer(other.release())
701 bool closeio =
false);
779 bool free_when_done);
1436 : m_lock(std::move(other.m_lock))
1467 std::swap(m_lock, other.m_lock);
1472 constexpr operator bool()
const {
return bool(m_lock); }
1540 :
Audio(other.release())
1723 bool closeio =
false);
2127 :
Track(other.release())
2395 bool closeio =
false);
3511 :
Group(other.release())
3647#define SDL_MIXER_MAJOR_VERSION
3656#define SDL_MIXER_MINOR_VERSION
3665#define SDL_MIXER_MICRO_VERSION
3674#define SDL_MIXER_VERSION \
3676 SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_MICRO_VERSION)
3683#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
3684 ((SDL_MIXER_MAJOR_VERSION >= X) && \
3685 (SDL_MIXER_MAJOR_VERSION > X || SDL_MIXER_MINOR_VERSION >= Y) && \
3686 (SDL_MIXER_MAJOR_VERSION > X || SDL_MIXER_MINOR_VERSION > Y || \
3687 SDL_MIXER_MICRO_VERSION >= Z))
3709inline int Version() {
return MIX_Version(); }
3729inline void Init() {
CheckError(MIX_Init()); }
3765inline void Quit() { MIX_Quit(); }
3822 return MIX_GetAudioDecoder(index);
3873 return Mixer(devid, spec);
3961 return CheckError(MIX_GetMixerProperties(mixer));
3976constexpr auto DEVICE_NUMBER = MIX_PROP_MIXER_DEVICE_NUMBER;
4098 std::move(lock).reset();
4103 if (!m_lock)
return;
4167 bool closeio =
false)
4169 return Audio(mixer, io, predecode, closeio);
4174 return Audio(
get(), io, predecode, closeio);
4181 :
Audio(MIX_LoadAudio_IO(mixer, io, predecode, closeio))
4186 :
Audio(MIX_LoadAudio(mixer, path, predecode))
4205 MIX_LoadRawAudio(mixer, data.data(), data.size_bytes(), &spec)))
4239 return Audio(mixer, std::move(path), predecode);
4244 return Audio(
get(), std::move(path), predecode);
4305 bool free_when_done)
4364 return Audio(props);
4375 MIX_PROP_AUDIO_LOAD_IOSTREAM_POINTER;
4378 MIX_PROP_AUDIO_LOAD_CLOSEIO_BOOLEAN;
4381 MIX_PROP_AUDIO_LOAD_PREDECODE_BOOLEAN;
4384 MIX_PROP_AUDIO_LOAD_PREFERRED_MIXER_POINTER;
4388 MIX_PROP_AUDIO_LOAD_SKIP_METADATA_TAGS_BOOLEAN;
4392 MIX_PROP_AUDIO_DECODER_STRING;
4433 bool closeio =
false)
4435 return Audio(mixer, io, spec, closeio);
4442 return Audio(
get(), io, spec, closeio);
4483 return Audio(mixer, std::move(data), spec);
4488 return Audio(
get(), std::move(data), spec);
4534 bool free_when_done)
4542 bool free_when_done)
4588 return Audio(
CheckError(MIX_CreateSineWaveAudio(mixer, hz, amplitude, ms)));
4643 return CheckError(MIX_GetAudioProperties(audio));
4659 MIX_PROP_METADATA_TITLE_STRING;
4662 MIX_PROP_METADATA_ARTIST_STRING;
4665 MIX_PROP_METADATA_ALBUM_STRING;
4668 MIX_PROP_METADATA_COPYRIGHT_STRING;
4671 MIX_PROP_METADATA_TRACK_NUMBER;
4674 MIX_PROP_METADATA_TOTAL_TRACKS_NUMBER;
4677 MIX_PROP_METADATA_YEAR_NUMBER;
4680 MIX_PROP_METADATA_DURATION_FRAMES_NUMBER;
4683 MIX_PROP_METADATA_DURATION_INFINITE_BOOLEAN;
4721 return MIX_GetAudioDuration(audio);
4854 return CheckError(MIX_GetTrackProperties(track));
4965 CheckError(MIX_SetTrackAudioStream(track, stream));
5022 bool closeio =
false)
5024 CheckError(MIX_SetTrackIOStream(track, io, closeio));
5083 bool closeio =
false)
5085 CheckError(MIX_SetTrackRawIOStream(track, io, &spec, closeio));
5157 MIX_UntagTrack(track, tag);
5181 auto result =
CheckError(MIX_GetTrackTags(track, &count));
5204 auto result =
CheckError(MIX_GetTaggedTracks(mixer, tag, &count));
5250 CheckError(MIX_SetTrackPlaybackPosition(track, frames));
5283 return MIX_GetTrackPlaybackPosition(track);
5315 return MIX_GetTrackFadeFrames(track);
5380 CheckError(MIX_SetTrackLoops(track, num_loops));
5410 return MIX_GetTrackAudio(track);
5438 return MIX_GetTrackAudioStream(track);
5473 return MIX_GetTrackRemaining(track);
5502 return MIX_TrackMSToFrames(track, ms.count());
5537 return Milliseconds(MIX_TrackFramesToMS(track, frames));
5566 return MIX_AudioMSToFrames(audio, ms.count());
5598 return Milliseconds(MIX_AudioFramesToMS(audio, frames));
5624 return MIX_MSToFrames(sample_rate, ms.count());
5650 return Milliseconds(MIX_FramesToMS(sample_rate, frames));
5783 MIX_PROP_PLAY_MAX_FRAME_NUMBER;
5786 MIX_PROP_PLAY_MAX_MILLISECONDS_NUMBER;
5789 MIX_PROP_PLAY_START_FRAME_NUMBER;
5792 MIX_PROP_PLAY_START_MILLISECOND_NUMBER;
5795 MIX_PROP_PLAY_LOOP_START_FRAME_NUMBER;
5798 MIX_PROP_PLAY_LOOP_START_MILLISECOND_NUMBER;
5802 MIX_PROP_PLAY_FADE_IN_FRAMES_NUMBER;
5805 MIX_PROP_PLAY_FADE_IN_MILLISECONDS_NUMBER;
5809 MIX_PROP_PLAY_FADE_IN_START_GAIN_FLOAT;
5812 MIX_PROP_PLAY_APPEND_SILENCE_FRAMES_NUMBER;
5816 MIX_PROP_PLAY_APPEND_SILENCE_MILLISECONDS_NUMBER;
5820 MIX_PROP_PLAY_HALT_WHEN_EXHAUSTED_BOOLEAN;
5861 CheckError(MIX_PlayTag(mixer, tag, options));
5901 return MIX_PlayAudio(mixer, audio);
5943 return MIX_StopTrack(track, fade_out_frames);
5982 CheckError(MIX_StopAllTracks(mixer, fade_out_ms));
6023 CheckError(MIX_StopTag(mixer, tag, fade_out_ms));
6402 CheckError(MIX_SetTagGain(mixer, tag, gain));
6439 CheckError(MIX_SetMixerFrequencyRatio(mixer, ratio));
6465 return MIX_GetMixerFrequencyRatio(mixer);
6498 CheckError(MIX_SetTrackFrequencyRatio(track, ratio));
6533 return MIX_GetTrackFrequencyRatio(track);
6579 MIX_SetTrackOutputChannelMap(track, chmap.data(),
narrowS32(chmap.size())));
6619 CheckError(MIX_SetTrackStereo(track, &gains));
6671 CheckError(MIX_SetTrack3DPosition(track, &position));
6698 CheckError(MIX_GetTrack3DPosition(track, &position));
6779 return CheckError(MIX_GetGroupProperties(group));
6873 CheckError(MIX_SetTrackStoppedCallback(track, cb, userdata));
6951 CheckError(MIX_SetTrackRawCallback(track, cb, userdata));
7032 CheckError(MIX_SetTrackCookedCallback(track, cb, userdata));
7109 CheckError(MIX_SetGroupPostMixCallback(group, cb, userdata));
7172 CheckError(MIX_SetPostMixCallback(mixer, cb, userdata));
7388 bool closeio =
false,
7526 :
AudioDecoder(MIX_CreateAudioDecoder_IO(io, closeio, props))
7566 bool closeio =
false,
7585 MIX_DestroyAudioDecoder(audiodecoder);
7615 return CheckError(MIX_GetAudioDecoderProperties(audiodecoder));
7641 CheckError(MIX_GetAudioDecoderFormat(audiodecoder, spec));
Lock a mixer by obtaining its internal mutex.
Definition SDL3pp_mixer.h:1382
MixerRef resource() const
Get the reference to locked resource.
Definition SDL3pp_mixer.h:1497
MixerLock(MixerLock &&other) noexcept
Move constructor.
Definition SDL3pp_mixer.h:1435
void release()
Releases the lock without unlocking.
Definition SDL3pp_mixer.h:1500
~MixerLock()
Unlock a mixer previously locked by a call to Mixer.Lock().
Definition SDL3pp_mixer.h:1460
MixerLock(const MixerLock &other)=delete
Copy constructor.
MixerLock & operator=(MixerLock &&other) noexcept
Assignment operator.
Definition SDL3pp_mixer.h:1465
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 get() const noexcept
Definition SDL3pp_resource.h:53
constexpr RawPointer release() noexcept
Definition SDL3pp_resource.h:56
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
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
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 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
ResourceRef< AudioStream > AudioStreamRef
Reference for AudioStream.
Definition SDL3pp_audio.h:146
ResourceRef< AudioDevice > AudioDeviceRef
Reference for AudioDevice.
Definition SDL3pp_audio.h:133
SDL_AudioSpec AudioSpec
Format specifier for audio data.
Definition SDL3pp_audio.h:198
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:199
ResourceRef< IOStream > IOStreamRef
Reference for IOStream.
Definition SDL3pp_iostream.h:34
void Quit()
Clean up all initialized subsystems.
Definition SDL3pp_init.h:329
ResourceRef< Properties > PropertiesRef
Reference for Properties.
Definition SDL3pp_properties.h:54
void SetRawIOStream(IOStreamRef io, const AudioSpec &spec, bool closeio=false)
Set a Track's input to an IOStream providing raw PCM data.
Definition SDL3pp_mixer.h:5088
void(SDLCALL *)(void *userdata, TrackRaw track) TrackStoppedCallback
A callback that fires when a Track is stopped.
Definition SDL3pp_mixer.h:1985
MakeFrontCallback< void(TrackRaw track)> TrackStoppedCB
A callback that fires when a Track is stopped.
Definition SDL3pp_mixer.h:2009
Audio LoadRawAudio(MixerRef mixer, SourceBytes data, const AudioSpec &spec)
Load raw PCM data from a memory buffer.
Definition SDL3pp_mixer.h:4479
void SetTrackStereo(TrackRef track, const StereoGains &gains)
Force a track to stereo output, with optionally left/right panning.
Definition SDL3pp_mixer.h:6617
void ResumeAllTracks()
Resume all currently-paused tracks.
Definition SDL3pp_mixer.h:6171
void SetTrackIOStream(TrackRef track, IOStreamRef io, bool closeio=false)
Set a Track's input to an IOStream.
Definition SDL3pp_mixer.h:5020
Audio LoadAudioWithProperties(PropertiesRef props)
Load audio for playback through a collection of properties.
Definition SDL3pp_mixer.h:4362
Audio LoadAudio(StringParam path, bool predecode)
Load audio for playback from a file.
Definition SDL3pp_mixer.h:4242
void Destroy()
Free a mixer.
Definition SDL3pp_mixer.h:3940
void SetTrackCookedCallback(TrackRef track, TrackMixCallback cb, void *userdata)
Set a callback that fires when the mixer has transformed a track's audio.
Definition SDL3pp_mixer.h:7028
MixerRef GetMixer()
Get the Mixer that owns a Group.
Definition SDL3pp_mixer.h:6805
ResourceRef< Group > GroupRef
Reference for Group.
Definition SDL3pp_mixer.h:158
PropertiesRef GetAudioDecoderProperties(AudioDecoderRef audiodecoder)
Get the properties associated with a AudioDecoder.
Definition SDL3pp_mixer.h:7613
void SetPlaybackPosition(Sint64 frames)
Seek a playing track to a new position in its input.
Definition SDL3pp_mixer.h:5253
float GetTrackFrequencyRatio(TrackRef track)
Query the frequency ratio of a track.
Definition SDL3pp_mixer.h:6531
void GetMixerFormat(MixerRef mixer, AudioSpec *spec)
Get the audio format a mixer is generating.
Definition SDL3pp_mixer.h:4008
MakeFrontCallback< void(GroupRaw group, const AudioSpec *spec, float *pcm, int samples)> GroupMixCB
A callback that fires when a Group has completed mixing.
Definition SDL3pp_mixer.h:3470
void SetPostMixCallback(GroupMixCallback cb, void *userdata)
Set a callback that fires when a mixer group has completed mixing.
Definition SDL3pp_mixer.h:7140
MIX_Group * GroupRaw
Alias to raw representation for Group.
Definition SDL3pp_mixer.h:151
void SetTagGain(MixerRef mixer, StringParam tag, float gain)
Set the gain control of all tracks with a specific tag.
Definition SDL3pp_mixer.h:6400
void SetStoppedCallback(TrackStoppedCallback cb, void *userdata)
Set a callback that fires when a Track is stopped.
Definition SDL3pp_mixer.h:6908
void SetTrackPlaybackPosition(TrackRef track, Sint64 frames)
Seek a playing track to a new position in its input.
Definition SDL3pp_mixer.h:5248
void UntagTrack(TrackRef track, StringParam tag)
Remove an arbitrary tag from a track.
Definition SDL3pp_mixer.h:5155
float GetFrequencyRatio()
Query the frequency ratio of a track.
Definition SDL3pp_mixer.h:6536
void(SDLCALL *)(void *userdata, TrackRaw track, const AudioSpec *spec, float *pcm, int samples) TrackMixCallback
A callback that fires when a Track is mixing at various stages.
Definition SDL3pp_mixer.h:2047
void Unlock(MixerLock &&lock)
Unlock a mixer previously locked by a call to Mixer.Lock().
Definition SDL3pp_mixer.h:4095
Milliseconds FramesToMS(int sample_rate, Sint64 frames)
Convert sample frames, at a specific sample rate, to milliseconds.
Definition SDL3pp_mixer.h:5648
void PauseTag(MixerRef mixer, StringParam tag)
Pause all tracks with a specific tag.
Definition SDL3pp_mixer.h:6110
int DecodeAudio(TargetBytes buffer, const AudioSpec &spec)
Decode more audio from a AudioDecoder.
Definition SDL3pp_mixer.h:7679
void PlayTrack(TrackRef track, PropertiesRef options=nullptr)
Start (or restart) mixing a track for playback.
Definition SDL3pp_mixer.h:5763
Sint64 TrackMSToFrames(TrackRef track, Milliseconds ms)
Convert milliseconds to sample frames for a track's current format.
Definition SDL3pp_mixer.h:5500
void Untag(StringParam tag)
Remove an arbitrary tag from a track.
Definition SDL3pp_mixer.h:5160
OwnArray< char * > GetTrackTags(TrackRef track)
Get the tags currently associated with a track.
Definition SDL3pp_mixer.h:5178
void ResumeTag(MixerRef mixer, StringParam tag)
Resume all tracks with a specific tag.
Definition SDL3pp_mixer.h:6198
Audio CreateSineWaveAudio(MixerRef mixer, int hz, float amplitude, Sint64 ms)
Create a Audio that generates a sinewave.
Definition SDL3pp_mixer.h:4583
void SetTrackStoppedCallback(TrackRef track, TrackStoppedCallback cb, void *userdata)
Set a callback that fires when a Track is stopped.
Definition SDL3pp_mixer.h:6869
Sint64 GetPlaybackPosition()
Get the current input position of a playing track.
Definition SDL3pp_mixer.h:5286
const char * GetAudioDecoder(int index)
Report the name of a specific audio decoders.
Definition SDL3pp_mixer.h:3820
void GetAudioDecoderFormat(AudioDecoderRef audiodecoder, AudioSpec *spec)
Query the initial audio format of a AudioDecoder.
Definition SDL3pp_mixer.h:7639
Sint64 GetFadeFrames()
Query whether a given track is fading.
Definition SDL3pp_mixer.h:5318
MixerRef GetMixer()
Get the Mixer that owns a Track.
Definition SDL3pp_mixer.h:4880
void DestroyAudioDecoder(AudioDecoderRaw audiodecoder)
Destroy the specified audio decoder.
Definition SDL3pp_mixer.h:7583
void UnlockMixer(MixerRef mixer)
Unlock a mixer previously locked by a call to Mixer.Lock().
Definition SDL3pp_mixer.h:4093
Track CreateTrack(MixerRef mixer)
Create a new track on a mixer.
Definition SDL3pp_mixer.h:4804
MakeFrontCallback< void(TrackRaw track, const AudioSpec *spec, float *pcm, int samples)> TrackMixCB
A callback that fires when a Track is mixing at various stages.
Definition SDL3pp_mixer.h:2089
bool Resume()
Resume a currently-paused track.
Definition SDL3pp_mixer.h:6144
void SetGroupPostMixCallback(GroupRef group, GroupMixCallback cb, void *userdata)
Set a callback that fires when a mixer group has completed mixing.
Definition SDL3pp_mixer.h:7105
void SetFrequencyRatio(float ratio)
Set a mixer's master frequency ratio.
Definition SDL3pp_mixer.h:6442
MixerLock(MixerRef resource)
Lock a mixer by obtaining its internal mutex.
Definition SDL3pp_mixer.h:4065
void SetTrackAudioStream(TrackRef track, AudioStreamRef stream)
Set a Track's input to an AudioStream.
Definition SDL3pp_mixer.h:4963
void SetGain(float gain)
Set a mixer's master gain control.
Definition SDL3pp_mixer.h:6292
Audio LoadRawAudio_IO(MixerRef mixer, IOStreamRef io, const AudioSpec &spec, bool closeio=false)
Load raw PCM data from an IOStream.
Definition SDL3pp_mixer.h:4430
bool Playing()
Query if a track is currently playing.
Definition SDL3pp_mixer.h:6233
bool PlayAudio(AudioRef audio)
Play a Audio from start to finish without any management.
Definition SDL3pp_mixer.h:5904
OwnArray< TrackRef > GetTaggedTracks(StringParam tag)
Get all tracks with a specific tag.
Definition SDL3pp_mixer.h:5208
int Generate(MixerRef mixer, TargetBytes buffer)
Generate mixer output when not driving an audio device.
Definition SDL3pp_mixer.h:7262
void SetTrackOutputChannelMap(TrackRef track, std::span< const int > chmap)
Set the current output channel map of a track.
Definition SDL3pp_mixer.h:6576
AudioRef GetAudio()
Query the Audio assigned to a track.
Definition SDL3pp_mixer.h:5413
Audio LoadAudio_IO(MixerRef mixer, IOStreamRef io, bool predecode, bool closeio=false)
Load audio for playback from an IOStream.
Definition SDL3pp_mixer.h:4164
MIX_AudioDecoder * AudioDecoderRaw
Alias to raw representation for AudioDecoder.
Definition SDL3pp_mixer.h:164
void DestroyMixer(MixerRaw mixer)
Free a mixer.
Definition SDL3pp_mixer.h:3938
AudioStreamRef GetTrackAudioStream(TrackRef track)
Query the AudioStream assigned to a track.
Definition SDL3pp_mixer.h:5436
void SetGroup(GroupRef group)
Assign a track to a mixing group.
Definition SDL3pp_mixer.h:6835
Milliseconds FramesToMS(Sint64 frames)
Convert sample frames for a Audio's format to milliseconds.
Definition SDL3pp_mixer.h:5601
void SetTrackRawCallback(TrackRef track, TrackMixCallback cb, void *userdata)
Set a callback that fires when a Track has initial decoded audio.
Definition SDL3pp_mixer.h:6947
void Play(PropertiesRef options=nullptr)
Start (or restart) mixing a track for playback.
Definition SDL3pp_mixer.h:5768
Milliseconds AudioFramesToMS(AudioRef audio, Sint64 frames)
Convert sample frames for a Audio's format to milliseconds.
Definition SDL3pp_mixer.h:5596
TrackRef CreateTrack()
Create a new track on a mixer.
Definition SDL3pp_mixer.h:4806
void SetTrackAudio(TrackRef track, AudioRef audio)
Set a Track's input to a Audio.
Definition SDL3pp_mixer.h:4913
Audio LoadRawAudio(SourceBytes data, const AudioSpec &spec)
Load raw PCM data from a memory buffer.
Definition SDL3pp_mixer.h:4486
void StopTag(MixerRef mixer, StringParam tag, Sint64 fade_out_ms)
Halt all tracks with a specific tag, possibly fading out over time.
Definition SDL3pp_mixer.h:6021
void SetFrequencyRatio(float ratio)
Change the frequency ratio of a track.
Definition SDL3pp_mixer.h:6501
void(SDLCALL *)(void *userdata, MixerRaw mixer, const AudioSpec *spec, float *pcm, int samples) PostMixCallback
A callback that fires when all mixing has completed.
Definition SDL3pp_mixer.h:209
void PauseAllTracks()
Pause all currently-playing tracks.
Definition SDL3pp_mixer.h:6082
float GetGain()
Get a track's gain control.
Definition SDL3pp_mixer.h:6364
PropertiesRef GetProperties()
Get the properties associated with a Audio.
Definition SDL3pp_mixer.h:4646
void SetTagGain(StringParam tag, float gain)
Set the gain control of all tracks with a specific tag.
Definition SDL3pp_mixer.h:6405
float GetGain()
Get a mixer's master gain control.
Definition SDL3pp_mixer.h:6312
Sint64 MSToFrames(int sample_rate, Milliseconds ms)
Convert milliseconds to sample frames at a specific sample rate.
Definition SDL3pp_mixer.h:5622
float GetFrequencyRatio()
Get a mixer's master frequency ratio.
Definition SDL3pp_mixer.h:6468
constexpr Sint64 DURATION_INFINITE
Infinite duration, when the audio never runs out of sound to generate.
Definition SDL3pp_mixer.h:4730
void SetStereo(const StereoGains &gains)
Force a track to stereo output, with optionally left/right panning.
Definition SDL3pp_mixer.h:6622
bool ResumeTrack(TrackRef track)
Resume a currently-paused track.
Definition SDL3pp_mixer.h:6142
void DestroyAudio(AudioRaw audio)
Destroy the specified audio.
Definition SDL3pp_mixer.h:4778
PropertiesRef GetProperties()
Get the properties associated with a mixer.
Definition SDL3pp_mixer.h:3964
bool StopTrack(TrackRef track, Sint64 fade_out_frames)
Halt a currently-playing track, possibly fading out over time.
Definition SDL3pp_mixer.h:5941
void SetTrackRawIOStream(TrackRef track, IOStreamRef io, const AudioSpec &spec, bool closeio=false)
Set a Track's input to an IOStream providing raw PCM data.
Definition SDL3pp_mixer.h:5080
bool PauseTrack(TrackRef track)
Pause a currently-playing track.
Definition SDL3pp_mixer.h:6053
float GetTrackGain(TrackRef track)
Get a track's gain control.
Definition SDL3pp_mixer.h:6362
void SetPostMixCallback(MixerRef mixer, PostMixCallback cb, void *userdata)
Set a callback that fires when all mixing has completed.
Definition SDL3pp_mixer.h:7168
void Destroy()
Destroy a mixing group.
Definition SDL3pp_mixer.h:6758
PropertiesRef GetTrackProperties(TrackRef track)
Get the properties associated with a track.
Definition SDL3pp_mixer.h:4852
Sint64 GetRemaining()
Return the number of sample frames remaining to be mixed in a track.
Definition SDL3pp_mixer.h:5476
ResourceRef< Audio > AudioRef
Reference for Audio.
Definition SDL3pp_mixer.h:132
MakeFrontCallback< void(MixerRaw mixer, const AudioSpec *spec, float *pcm, int samples)> PostMixCB
A callback that fires when all mixing has completed.
Definition SDL3pp_mixer.h:249
void Destroy()
Destroy the specified audio decoder.
Definition SDL3pp_mixer.h:7588
MIX_Track * TrackRaw
Alias to raw representation for Track.
Definition SDL3pp_mixer.h:138
void SetAudio(AudioRef audio)
Set a Track's input to a Audio.
Definition SDL3pp_mixer.h:4918
Audio LoadRawAudioNoCopy(SourceBytes data, const AudioSpec &spec, bool free_when_done)
Load raw PCM data from a memory buffer without making a copy.
Definition SDL3pp_mixer.h:4540
float GetMixerGain(MixerRef mixer)
Get a mixer's master gain control.
Definition SDL3pp_mixer.h:6310
int GetNumAudioDecoders()
Report the number of audio decoders available for use.
Definition SDL3pp_mixer.h:3789
void SetCookedCallback(TrackMixCallback cb, void *userdata)
Set a callback that fires when the mixer has transformed a track's audio.
Definition SDL3pp_mixer.h:7070
Sint64 GetAudioDuration(AudioRef audio)
Get the length of a Audio's playback in sample frames.
Definition SDL3pp_mixer.h:4719
PropertiesRef GetProperties()
Get the properties associated with a track.
Definition SDL3pp_mixer.h:4857
Mixer CreateMixerDevice(AudioDeviceRef devid, OptionalRef< const AudioSpec > spec=std::nullopt)
Create a mixer that plays sound directly to an audio device.
Definition SDL3pp_mixer.h:3870
void StopTag(StringParam tag, Sint64 fade_out_ms)
Halt all tracks with a specific tag, possibly fading out over time.
Definition SDL3pp_mixer.h:6026
void StopAllTracks(MixerRef mixer, Sint64 fade_out_ms)
Halt all currently-playing tracks, possibly fading out over time.
Definition SDL3pp_mixer.h:5980
Sint64 GetTrackRemaining(TrackRef track)
Return the number of sample frames remaining to be mixed in a track.
Definition SDL3pp_mixer.h:5471
void TagTrack(TrackRef track, StringParam tag)
Assign an arbitrary tag to a track.
Definition SDL3pp_mixer.h:5122
ResourceRef< AudioDecoder > AudioDecoderRef
Reference for AudioDecoder.
Definition SDL3pp_mixer.h:171
PropertiesRef GetAudioProperties(AudioRef audio)
Get the properties associated with a Audio.
Definition SDL3pp_mixer.h:4641
Audio LoadAudio(MixerRef mixer, StringParam path, bool predecode)
Load audio for playback from a file.
Definition SDL3pp_mixer.h:4237
void PauseAllTracks(MixerRef mixer)
Pause all currently-playing tracks.
Definition SDL3pp_mixer.h:6077
ResourceRef< Mixer > MixerRef
Reference for Mixer.
Definition SDL3pp_mixer.h:119
void GetFormat(AudioSpec *spec)
Query the initial audio format of a Audio.
Definition SDL3pp_mixer.h:4753
void GetFormat(AudioSpec *spec)
Query the initial audio format of a AudioDecoder.
Definition SDL3pp_mixer.h:7644
void Tag(StringParam tag)
Assign an arbitrary tag to a track.
Definition SDL3pp_mixer.h:5127
int GetLoops()
Query how many loops remain for a given track.
Definition SDL3pp_mixer.h:5348
AudioDecoder CreateAudioDecoder_IO(IOStreamRef io, bool closeio=false, PropertiesRef props=nullptr)
Create a AudioDecoder from an IOStream.
Definition SDL3pp_mixer.h:7565
Audio LoadAudioNoCopy(MixerRef mixer, SourceBytes data, bool free_when_done)
Load audio for playback from a memory buffer without making a copy.
Definition SDL3pp_mixer.h:4303
Audio LoadAudio_IO(IOStreamRef io, bool predecode, bool closeio=false)
Load audio for playback from an IOStream.
Definition SDL3pp_mixer.h:4172
Sint64 AudioMSToFrames(AudioRef audio, Milliseconds ms)
Convert milliseconds to sample frames for a Audio's format.
Definition SDL3pp_mixer.h:5564
void LockMixer(MixerRef mixer)
Lock a mixer by obtaining its internal mutex.
Definition SDL3pp_mixer.h:4061
PropertiesRef GetMixerProperties(MixerRef mixer)
Get the properties associated with a mixer.
Definition SDL3pp_mixer.h:3959
float GetMixerFrequencyRatio(MixerRef mixer)
Get a mixer's master frequency ratio.
Definition SDL3pp_mixer.h:6463
void SetTrackFrequencyRatio(TrackRef track, float ratio)
Change the frequency ratio of a track.
Definition SDL3pp_mixer.h:6496
bool Stop(Sint64 fade_out_frames)
Halt a currently-playing track, possibly fading out over time.
Definition SDL3pp_mixer.h:5946
bool TrackPlaying(TrackRef track)
Query if a track is currently playing.
Definition SDL3pp_mixer.h:6231
Milliseconds TrackFramesToMS(TrackRef track, Sint64 frames)
Convert sample frames for a track's current format to milliseconds.
Definition SDL3pp_mixer.h:5535
void reset()
Unlock a mixer previously locked by a call to Mixer.Lock().
Definition SDL3pp_mixer.h:4101
bool Paused()
Query if a track is currently paused.
Definition SDL3pp_mixer.h:6260
AudioDecoder CreateAudioDecoder(StringParam path, PropertiesRef props=nullptr)
Create a AudioDecoder from a path on the filesystem.
Definition SDL3pp_mixer.h:7512
Group CreateGroup(MixerRef mixer)
Create a mixing group.
Definition SDL3pp_mixer.h:6733
Sint64 GetTrackFadeFrames(TrackRef track)
Query whether a given track is fading.
Definition SDL3pp_mixer.h:5313
MixerLock Lock()
Lock a mixer by obtaining its internal mutex.
Definition SDL3pp_mixer.h:4063
Audio LoadAudioNoCopy(SourceBytes data, bool free_when_done)
Load audio for playback from a memory buffer without making a copy.
Definition SDL3pp_mixer.h:4311
PropertiesRef GetGroupProperties(GroupRef group)
Get the properties associated with a group.
Definition SDL3pp_mixer.h:6777
void SetRawCallback(TrackMixCallback cb, void *userdata)
Set a callback that fires when a Track has initial decoded audio.
Definition SDL3pp_mixer.h:6986
void SetMixerFrequencyRatio(MixerRef mixer, float ratio)
Set a mixer's master frequency ratio.
Definition SDL3pp_mixer.h:6437
constexpr Sint64 DURATION_UNKNOWN
Unknown duration, when the length of the audio can't be determined.
Definition SDL3pp_mixer.h:4727
Audio LoadRawAudioNoCopy(MixerRef mixer, SourceBytes data, const AudioSpec &spec, bool free_when_done)
Load raw PCM data from a memory buffer without making a copy.
Definition SDL3pp_mixer.h:4531
void SetTrack3DPosition(TrackRef track, const Point3D &position)
Set a track's position in 3D space.
Definition SDL3pp_mixer.h:6669
MIX_Point3D Point3D
3D coordinates for Track.Set3DPosition.
Definition SDL3pp_mixer.h:1962
MIX_Audio * AudioRaw
Alias to raw representation for Audio.
Definition SDL3pp_mixer.h:125
bool PlayAudio(MixerRef mixer, AudioRef audio)
Play a Audio from start to finish without any management.
Definition SDL3pp_mixer.h:5899
void ResumeAllTracks(MixerRef mixer)
Resume all currently-paused tracks.
Definition SDL3pp_mixer.h:6166
void DestroyGroup(GroupRaw group)
Destroy a mixing group.
Definition SDL3pp_mixer.h:6756
void SetTrackGroup(TrackRef track, GroupRef group)
Assign a track to a mixing group.
Definition SDL3pp_mixer.h:6830
Milliseconds FramesToMS(Sint64 frames)
Convert sample frames for a track's current format to milliseconds.
Definition SDL3pp_mixer.h:5540
MixerRef GetTrackMixer(TrackRef track)
Get the Mixer that owns a Track.
Definition SDL3pp_mixer.h:4875
MIX_Mixer * MixerRaw
Alias to raw representation for Mixer.
Definition SDL3pp_mixer.h:112
Audio CreateSineWaveAudio(int hz, float amplitude, Sint64 ms)
Create a Audio that generates a sinewave.
Definition SDL3pp_mixer.h:4591
void PlayTag(MixerRef mixer, StringParam tag, PropertiesRef options)
Start (or restart) mixing all tracks with a specific tag for playback.
Definition SDL3pp_mixer.h:5859
void Set3DPosition(const Point3D &position)
Set a track's position in 3D space.
Definition SDL3pp_mixer.h:6674
void SetPostMixCallback(PostMixCallback cb, void *userdata)
Set a callback that fires when all mixing has completed.
Definition SDL3pp_mixer.h:7201
ResourceRef< Track > TrackRef
Reference for Track.
Definition SDL3pp_mixer.h:145
int Generate(TargetBytes buffer)
Generate mixer output when not driving an audio device.
Definition SDL3pp_mixer.h:7268
PropertiesRef GetProperties()
Get the properties associated with a group.
Definition SDL3pp_mixer.h:6782
MixerRef GetGroupMixer(GroupRef group)
Get the Mixer that owns a Group.
Definition SDL3pp_mixer.h:6800
bool TrackPaused(TrackRef track)
Query if a track is currently paused.
Definition SDL3pp_mixer.h:6258
void SetMixerGain(MixerRef mixer, float gain)
Set a mixer's master gain control.
Definition SDL3pp_mixer.h:6287
void PlayTag(StringParam tag, PropertiesRef options)
Start (or restart) mixing all tracks with a specific tag for playback.
Definition SDL3pp_mixer.h:5864
void GetFormat(AudioSpec *spec)
Get the audio format a mixer is generating.
Definition SDL3pp_mixer.h:4013
void SetTrackGain(TrackRef track, float gain)
Set a track's gain control.
Definition SDL3pp_mixer.h:6339
Audio LoadRawAudio_IO(IOStreamRef io, const AudioSpec &spec, bool closeio=false)
Load raw PCM data from an IOStream.
Definition SDL3pp_mixer.h:4438
AudioStreamRef GetAudioStream()
Query the AudioStream assigned to a track.
Definition SDL3pp_mixer.h:5441
int GetTrackLoops(TrackRef track)
Query how many loops remain for a given track.
Definition SDL3pp_mixer.h:5346
Sint64 GetDuration()
Get the length of a Audio's playback in sample frames.
Definition SDL3pp_mixer.h:4724
Sint64 MSToFrames(Milliseconds ms)
Convert milliseconds to sample frames for a Audio's format.
Definition SDL3pp_mixer.h:5569
OwnArray< char * > GetTags()
Get the tags currently associated with a track.
Definition SDL3pp_mixer.h:5185
void SetIOStream(IOStreamRef io, bool closeio=false)
Set a Track's input to an IOStream.
Definition SDL3pp_mixer.h:5027
Sint64 GetTrackPlaybackPosition(TrackRef track)
Get the current input position of a playing track.
Definition SDL3pp_mixer.h:5281
void DestroyTrack(TrackRaw track)
Destroy the specified track.
Definition SDL3pp_mixer.h:4831
void SetTrackLoops(TrackRef track, int num_loops)
Change the number of times a currently-playing track will loop.
Definition SDL3pp_mixer.h:5378
void PauseTag(StringParam tag)
Pause all tracks with a specific tag.
Definition SDL3pp_mixer.h:6115
Point3D GetTrack3DPosition(TrackRef track)
Get a track's current position in 3D space.
Definition SDL3pp_mixer.h:6695
Mixer CreateMixer(const AudioSpec &spec)
Create a mixer that generates audio to a memory buffer.
Definition SDL3pp_mixer.h:3913
void SetLoops(int num_loops)
Change the number of times a currently-playing track will loop.
Definition SDL3pp_mixer.h:5383
void StopAllTracks(Sint64 fade_out_ms)
Halt all currently-playing tracks, possibly fading out over time.
Definition SDL3pp_mixer.h:5985
void GetAudioFormat(AudioRef audio, AudioSpec *spec)
Query the initial audio format of a Audio.
Definition SDL3pp_mixer.h:4748
PropertiesRef GetProperties()
Get the properties associated with a AudioDecoder.
Definition SDL3pp_mixer.h:7618
MIX_StereoGains StereoGains
A set of per-channel gains for tracks using Track.SetStereo().
Definition SDL3pp_mixer.h:1950
OwnArray< TrackRef > GetTaggedTracks(MixerRef mixer, StringParam tag)
Get all tracks with a specific tag.
Definition SDL3pp_mixer.h:5201
void SetOutputChannelMap(std::span< const int > chmap)
Set the current output channel map of a track.
Definition SDL3pp_mixer.h:6582
bool Pause()
Pause a currently-playing track.
Definition SDL3pp_mixer.h:6055
void Destroy()
Destroy the specified audio.
Definition SDL3pp_mixer.h:4780
void ResumeTag(StringParam tag)
Resume all tracks with a specific tag.
Definition SDL3pp_mixer.h:6203
Point3D Get3DPosition()
Get a track's current position in 3D space.
Definition SDL3pp_mixer.h:6702
GroupRef CreateGroup()
Create a mixing group.
Definition SDL3pp_mixer.h:6735
void SetGain(float gain)
Set a track's gain control.
Definition SDL3pp_mixer.h:6344
void Destroy()
Destroy the specified track.
Definition SDL3pp_mixer.h:4833
int DecodeAudio(AudioDecoderRef audiodecoder, TargetBytes buffer, const AudioSpec &spec)
Decode more audio from a AudioDecoder.
Definition SDL3pp_mixer.h:7669
void(SDLCALL *)(void *userdata, GroupRaw group, const AudioSpec *spec, float *pcm, int samples) GroupMixCallback
A callback that fires when a Group has completed mixing.
Definition SDL3pp_mixer.h:3431
void SetAudioStream(AudioStreamRef stream)
Set a Track's input to an AudioStream.
Definition SDL3pp_mixer.h:4968
Sint64 MSToFrames(Milliseconds ms)
Convert milliseconds to sample frames for a track's current format.
Definition SDL3pp_mixer.h:5505
AudioRef GetTrackAudio(TrackRef track)
Query the Audio assigned to a track.
Definition SDL3pp_mixer.h:5408
::Sint64 Sint64
A signed 64-bit integer type.
Definition SDL3pp_stdinc.h:305
std::chrono::milliseconds Milliseconds
Duration in Miliseconds (Uint32).
Definition SDL3pp_stdinc.h:335
Properties for configuring audio loading.
Definition SDL3pp_mixer.h:4372
constexpr auto DECODER_STRING
String for decoder.
Definition SDL3pp_mixer.h:4391
constexpr auto LOAD_CLOSEIO_BOOLEAN
Load closeio enabled.
Definition SDL3pp_mixer.h:4377
constexpr auto LOAD_IOSTREAM_POINTER
Pointer to load iostream.
Definition SDL3pp_mixer.h:4374
constexpr auto LOAD_PREDECODE_BOOLEAN
Load predecode enabled.
Definition SDL3pp_mixer.h:4380
constexpr auto LOAD_SKIP_METADATA_TAGS_BOOLEAN
Enable load skip metadata tags.
Definition SDL3pp_mixer.h:4387
constexpr auto LOAD_PREFERRED_MIXER_POINTER
Pointer to load preferred mixer.
Definition SDL3pp_mixer.h:4383
Properties for Mixer.
Definition SDL3pp_mixer.h:3974
Properties that can be used in the options parameter of Track.Play().
Definition SDL3pp_mixer.h:5778
constexpr auto START_MILLISECOND_NUMBER
Number for start millisecond.
Definition SDL3pp_mixer.h:5791
constexpr auto LOOPS_NUMBER
Number for loops.
Definition SDL3pp_mixer.h:5780
constexpr auto MAX_FRAME_NUMBER
Number for max frame.
Definition SDL3pp_mixer.h:5782
constexpr auto HALT_WHEN_EXHAUSTED_BOOLEAN
Halt when exhausted enabled.
Definition SDL3pp_mixer.h:5819
constexpr auto LOOP_START_FRAME_NUMBER
Number for loop start frame.
Definition SDL3pp_mixer.h:5794
constexpr auto FADE_IN_START_GAIN_FLOAT
Float for fade in start gain.
Definition SDL3pp_mixer.h:5808
constexpr auto APPEND_SILENCE_FRAMES_NUMBER
Number for append silence frames.
Definition SDL3pp_mixer.h:5811
constexpr auto FADE_IN_MILLISECONDS_NUMBER
Number for fade in milliseconds.
Definition SDL3pp_mixer.h:5804
constexpr auto FADE_IN_FRAMES_NUMBER
Number for fade in frames.
Definition SDL3pp_mixer.h:5801
constexpr auto START_FRAME_NUMBER
Number for start frame.
Definition SDL3pp_mixer.h:5788
constexpr auto MAX_MILLISECONDS_NUMBER
Number for max milliseconds.
Definition SDL3pp_mixer.h:5785
constexpr auto APPEND_SILENCE_MILLISECONDS_NUMBER
Number for append silence milliseconds.
Definition SDL3pp_mixer.h:5815
constexpr auto LOOP_START_MILLISECOND_NUMBER
Number for loop start millisecond.
Definition SDL3pp_mixer.h:5797
Main include header for the SDL3pp library.
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition SDL3pp_stdinc.h:6257
An opaque object that represents an audio decoder.
Definition SDL3pp_mixer.h:7289
constexpr AudioDecoder(AudioDecoderRaw resource) noexcept
Constructs from raw AudioDecoder.
Definition SDL3pp_mixer.h:7299
constexpr AudioDecoder & operator=(AudioDecoder &&other) noexcept
Assignment operator.
Definition SDL3pp_mixer.h:7395
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
~AudioDecoder()
Destructor.
Definition SDL3pp_mixer.h:7392
AudioDecoder & operator=(const AudioDecoder &other)=delete
Assignment operator.
constexpr AudioDecoder(AudioDecoder &&other) noexcept
Move constructor.
Definition SDL3pp_mixer.h:7308
constexpr AudioDecoder(const AudioDecoder &other)=delete
Copy constructor.
An opaque object that represents audio data.
Definition SDL3pp_mixer.h:1520
constexpr Audio(Audio &&other) noexcept
Move constructor.
Definition SDL3pp_mixer.h:1539
constexpr Audio(AudioRaw resource) noexcept
Constructs from raw Audio.
Definition SDL3pp_mixer.h:1530
constexpr Audio(const Audio &other)=delete
Copy constructor.
Audio & operator=(const Audio &other)=delete
Assignment operator.
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
constexpr Audio & operator=(Audio &&other) noexcept
Assignment operator.
Definition SDL3pp_mixer.h:1765
~Audio()
Destructor.
Definition SDL3pp_mixer.h:1762
An opaque object that represents a grouping of tracks.
Definition SDL3pp_mixer.h:3491
constexpr Group(const Group &other)=delete
Copy constructor.
~Group()
Destructor.
Definition SDL3pp_mixer.h:3552
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
constexpr Group & operator=(Group &&other) noexcept
Assignment operator.
Definition SDL3pp_mixer.h:3555
Group & operator=(const Group &other)=delete
Assignment operator.
constexpr Group(GroupRaw resource) noexcept
Constructs from raw Group.
Definition SDL3pp_mixer.h:3501
constexpr Group(Group &&other) noexcept
Move constructor.
Definition SDL3pp_mixer.h:3510
Definition SDL3pp_callbackWrapper.h:169
An opaque object that represents a mixer.
Definition SDL3pp_mixer.h:269
constexpr Mixer(MixerRaw resource) noexcept
Constructs from raw Mixer.
Definition SDL3pp_mixer.h:279
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
constexpr Mixer(Mixer &&other) noexcept
Move constructor.
Definition SDL3pp_mixer.h:288
Mixer & operator=(const Mixer &other)=delete
Assignment operator.
~Mixer()
Destructor.
Definition SDL3pp_mixer.h:375
constexpr Mixer(const Mixer &other)=delete
Copy constructor.
constexpr Mixer & operator=(Mixer &&other) noexcept
Assignment operator.
Definition SDL3pp_mixer.h:378
A non-owning reference wrapper for a given resource.
Definition SDL3pp_resource.h:156
An opaque object that represents a source of sound output to be mixed.
Definition SDL3pp_mixer.h:2107
constexpr Track & operator=(Track &&other) noexcept
Assignment operator.
Definition SDL3pp_mixer.h:2165
constexpr Track(TrackRaw resource) noexcept
Constructs from raw Track.
Definition SDL3pp_mixer.h:2117
constexpr ResourceBase(RawPointer resource)
Constructs from resource pointer.
Definition SDL3pp_resource.h:29
constexpr Track(Track &&other) noexcept
Move constructor.
Definition SDL3pp_mixer.h:2126
~Track()
Destructor.
Definition SDL3pp_mixer.h:2162
constexpr Track(const Track &other)=delete
Copy constructor.
Track & operator=(const Track &other)=delete
Assignment operator.