7#if defined(MXVK_WITH_MIXER) || defined(WITH_MIXER)
10#include <SDL3_mixer/SDL_mixer.h>
48 int loadWav(
const std::string &filename);
55 int loadMusic(
const std::string &filename);
72 int playWav(
int id,
int value = 0,
int channel = -1);
79 [[nodiscard]]
bool isPlaying(
int channel)
const;
95 using MixerHandle = std::unique_ptr<MIX_Mixer,
decltype(&MIX_DestroyMixer)>;
96 using AudioHandle = std::unique_ptr<MIX_Audio,
decltype(&MIX_DestroyAudio)>;
97 using TrackHandle = std::unique_ptr<MIX_Track,
decltype(&MIX_DestroyTrack)>;
99 bool initialized =
false;
100 MixerHandle mixer{
nullptr, MIX_DestroyMixer};
101 std::vector<AudioHandle> music_files{};
102 std::vector<AudioHandle> wav_files{};
103 std::vector<TrackHandle> music_tracks{};
104 std::vector<TrackHandle> wav_tracks{};
106 [[nodiscard]]
static std::size_t toIndex(
int value);
SDL3_mixer-based audio manager.
int loadWav(const std::string &filename)
Load a WAV file as a sound effect chunk.
int playWav(int id, int value=0, int channel=-1)
Play a previously loaded WAV chunk.
void stopMusic()
Stop background music playback immediately.
void cleanup()
Free all loaded audio chunks and music tracks.
bool isPlaying(int channel) const
Query whether a sound track is currently playing.
void init()
Open the audio device (called automatically by constructor).
int loadMusic(const std::string &filename)
Load an audio file as streaming background music.
VK_Mixer(VK_Mixer &&)=delete
bool isMusicPlaying(int id) const
Query whether a loaded music track is currently playing.
VK_Mixer & operator=(VK_Mixer &&)=delete
VK_Mixer()
Initialise SDL3_mixer and open the audio device.
VK_Mixer & operator=(const VK_Mixer &)=delete
int playMusic(int id, int value=0)
Start playing a previously loaded music track.
VK_Mixer(const VK_Mixer &)=delete
~VK_Mixer() noexcept
Halt all playback and free all loaded audio resources.
Utilities for loading and saving PNG images.