45 lines
1.5 KiB
C++
45 lines
1.5 KiB
C++
#pragma once
|
|
#include <SDL3/SDL.h>
|
|
|
|
namespace audio
|
|
{
|
|
enum state { invalid, available, playing, paused, stopped, disabled };
|
|
|
|
struct sound;
|
|
struct music;
|
|
|
|
void init(const int freq, const SDL_AudioFormat format, const int num_channels);
|
|
void quit();
|
|
|
|
audio::music *loadMusic(const char* filename);
|
|
audio::music *loadMusic(Uint8* buffer, Uint32 length);
|
|
void playMusic(audio::music *music, const int loop = -1);
|
|
void loadAndPlayMusic(const char* filename, const bool force_reinit=false);
|
|
char *getMusicFilename(audio::music *music = nullptr);
|
|
void pauseMusic();
|
|
void resumeMusic();
|
|
void stopMusic();
|
|
void fadeOutMusic(const int milliseconds=250);
|
|
audio::state getMusicState();
|
|
void deleteMusic(audio::music *music);
|
|
float setMusicVolume(float volume);
|
|
void setMusicPosition(float value);
|
|
float getMusicPosition();
|
|
void enableMusic(const bool value);
|
|
|
|
audio::sound *newSound(Uint8* buffer, Uint32 length);
|
|
audio::sound *loadSound(Uint8* buffer, Uint32 length);
|
|
audio::sound *loadSound(const char* filename);
|
|
int playSound(audio::sound *sound, const int loop = 0);
|
|
int playSoundOnChannel(audio::sound *sound, const int channel, const int loop = 0);
|
|
void pauseChannel(const int channel);
|
|
void resumeChannel(const int channel);
|
|
void stopChannel(const int channel);
|
|
audio::state getChannelState(const int channel);
|
|
void deleteSound(audio::sound *sound);
|
|
float setSoundVolume(float volume);
|
|
void enableSound(const bool value);
|
|
|
|
float setVolume(float volume);
|
|
}
|