diff options
author | max-001 <maxsmits21@kpnmail.nl> | 2024-12-11 13:21:19 +0100 |
---|---|---|
committer | max-001 <maxsmits21@kpnmail.nl> | 2024-12-11 13:21:19 +0100 |
commit | 357ebfc3eac1d39b02875e1bd78ae6f58b10f824 (patch) | |
tree | 7d79435fa764c0fedcc912ddaf876ff03ef8be5e /src/crepe/facade/SoundContext.cpp | |
parent | 6eef90e9ffb1d8fc25161e912bc5d8aa8e4024da (diff) | |
parent | c45b60941b82dec2097d958b396a117b1634eada (diff) |
Merge remote-tracking branch 'origin/master' into max/AI
Diffstat (limited to 'src/crepe/facade/SoundContext.cpp')
-rw-r--r-- | src/crepe/facade/SoundContext.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/crepe/facade/SoundContext.cpp b/src/crepe/facade/SoundContext.cpp index deb2b62..b1f8cb3 100644 --- a/src/crepe/facade/SoundContext.cpp +++ b/src/crepe/facade/SoundContext.cpp @@ -4,17 +4,33 @@ using namespace crepe; -SoundContext & SoundContext::get_instance() { - static SoundContext instance; - return instance; -} - SoundContext::SoundContext() { dbg_trace(); - engine.init(); + this->engine.init(); + this->engine.setMaxActiveVoiceCount(this->config.audio.voices); } SoundContext::~SoundContext() { dbg_trace(); - engine.deinit(); + this->engine.deinit(); +} + +SoundHandle SoundContext::play(Sound & resource) { + SoLoud::handle real_handle = this->engine.play(resource.sample, 1.0f); + SoundHandle handle = this->next_handle; + this->registry[handle] = real_handle; + this->next_handle++; + return handle; +} + +void SoundContext::stop(const SoundHandle & handle) { + this->engine.stop(this->registry[handle]); +} + +void SoundContext::set_volume(const SoundHandle & handle, float volume) { + this->engine.setVolume(this->registry[handle], volume); +} + +void SoundContext::set_loop(const SoundHandle & handle, bool loop) { + this->engine.setLooping(this->registry[handle], loop); } |