aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/facade/SoundContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/facade/SoundContext.cpp')
-rw-r--r--src/crepe/facade/SoundContext.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/crepe/facade/SoundContext.cpp b/src/crepe/facade/SoundContext.cpp
index deb2b62..3ae5956 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();
+}
+
+Sound::Handle SoundContext::play(Sound & resource) {
+ return {
+ .handle = this->engine.play(resource.sample, this->default_volume),
+ };
+}
+
+void SoundContext::stop(Sound::Handle & handle) {
+ this->engine.stop(handle.handle);
}
+
+void SoundContext::set_volume(Sound & resource, Sound::Handle & handle, float volume) {
+ this->engine.setVolume(handle.handle, volume);
+ this->default_volume = volume;
+}
+
+void SoundContext::set_loop(Sound & resource, Sound::Handle & handle, bool loop) {
+ this->engine.setLooping(handle.handle, loop);
+}
+