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.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/crepe/facade/SoundContext.cpp b/src/crepe/facade/SoundContext.cpp
new file mode 100644
index 0000000..5091e07
--- /dev/null
+++ b/src/crepe/facade/SoundContext.cpp
@@ -0,0 +1,36 @@
+#include "../util/dbg.h"
+
+#include "SoundContext.h"
+
+using namespace crepe;
+
+SoundContext::SoundContext() {
+ dbg_trace();
+ this->engine.init();
+ this->engine.setMaxActiveVoiceCount(this->config.audio.voices);
+}
+
+SoundContext::~SoundContext() {
+ dbg_trace();
+ 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);
+}