21#include <spdlog/spdlog.h>
38 alGenSources((ALuint)1, &
channel);
40 alSourcef(
channel, AL_PITCH, 1);
43 alSource3f(
channel, AL_POSITION, 0, 0, 0);
44 alSource3f(
channel, AL_VELOCITY, 0, 0, 0);
45 alSourcei(
channel, AL_LOOPING, AL_FALSE);
52 void SetLooping(
bool looping) { alSourcei(
channel, AL_LOOPING, looping ? AL_TRUE : AL_FALSE); }
66 alGetSourcei(
channel, AL_SOURCE_STATE, &source_state);
67 return (source_state == AL_STOPPED || source_state == AL_PAUSED);
72 alGetSourcei(
channel, AL_SOURCE_STATE, &source_state);
73 return (source_state == AL_PLAYING);
107 void Pause(
bool to_pause)
override;
123 std::unique_ptr<cqsp::asset::AudioAsset>
LoadWav(std::ifstream &input);
136 std::unique_ptr<cqsp::asset::AudioAsset>
LoadNextFile();
137 std::map<std::string, cqsp::asset::AudioAsset *>
assets;
138 std::vector<std::unique_ptr<AudioChannel>>
channels;
Definition: audioasset.h:23
Definition: audiointerface.h:99
std::unique_ptr< cqsp::asset::AudioAsset > LoadNextFile()
Definition: audiointerface.cpp:253
void OnFrame() override
Definition: audiointerface.cpp:102
static const int UI_CHANNEL
Definition: audiointerface.h:143
void RequestPlayAudio() override
Definition: audiointerface.cpp:72
std::shared_ptr< spdlog::logger > logger
Definition: audiointerface.h:126
std::string GetAudioVersion() override
Definition: audiointerface.cpp:57
void Initialize() override
Definition: audiointerface.cpp:33
void StartWorker() override
Definition: audiointerface.cpp:67
~AudioInterface()
Definition: audiointerface.cpp:141
static const int MUSIC_CHANNEL
Definition: audiointerface.h:142
AudioInterface()
Definition: audiointerface.cpp:31
ALboolean enumeration
Definition: audiointerface.h:104
std::unique_ptr< cqsp::asset::AudioAsset > LoadWav(std::ifstream &input)
Definition: audiointerface.cpp:177
void PrintInformation()
Definition: audiointerface.cpp:218
void SetChannelVolume(int channel, float gain) override
Definition: audiointerface.cpp:98
std::future< std::unique_ptr< cqsp::asset::AudioAsset > > audio_future
Async load audio files
Definition: audiointerface.h:148
ALCdevice * device
Definition: audiointerface.h:102
void InitALContext()
Definition: audiointerface.cpp:233
float music_volume
Definition: audiointerface.h:140
void InitListener()
Definition: audiointerface.cpp:225
void Destruct() override
Definition: audiointerface.cpp:59
std::atomic_bool to_quit
Definition: audiointerface.h:128
ALCcontext * context
Definition: audiointerface.h:103
Hjson::Value playlist
Definition: audiointerface.h:130
void PauseMusic(bool to_pause) override
Definition: audiointerface.cpp:55
std::map< std::string, cqsp::asset::AudioAsset * > assets
Definition: audiointerface.h:137
void SetMusicVolume(float volume) override
Definition: audiointerface.cpp:74
void Pause(bool to_pause) override
Definition: audiointerface.cpp:53
void PlayAudioClip(const std::string &key) override
Definition: audiointerface.cpp:85
std::vector< std::unique_ptr< AudioChannel > > channels
Definition: audiointerface.h:138
void AddAudioClip(const std::string &key, cqsp::asset::AudioAsset *asset) override
Definition: audiointerface.cpp:81
std::unique_ptr< cqsp::asset::AudioAsset > music_asset
Definition: audiointerface.h:124
Definition: iaudiointerface.h:29
Definition: audiointerface.h:34
Definition: audiointerface.h:35
void SetLooping(bool looping)
Definition: audiointerface.h:52
float PlayPosition()
Definition: audiointerface.h:76
void EmptyBuffer()
Definition: audiointerface.h:82
void Resume()
Definition: audiointerface.h:58
void Play()
Definition: audiointerface.h:54
void Pause()
Definition: audiointerface.h:60
ALuint channel
Definition: audiointerface.h:96
bool IsStopped()
Definition: audiointerface.h:64
~AudioChannel()
Definition: audiointerface.h:87
bool IsPlaying()
Definition: audiointerface.h:70
void Rewind()
Definition: audiointerface.h:62
void SetBuffer(cqsp::asset::AudioAsset *buffer)
Definition: audiointerface.cpp:274
float length
Definition: audiointerface.h:85
void SetGain(float gain)
Definition: audiointerface.h:48
AudioChannel()
Definition: audiointerface.h:37
void Stop()
Definition: audiointerface.h:56
void SetPitch(float pitch)
Definition: audiointerface.h:50