diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-09-28 17:07:56 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-09-28 17:07:56 +0200 |
commit | 3cb7227c3c9678141ff74915331b706265c380cb (patch) | |
tree | d47d662b4d26908b3d3d83f4a4df32a0cc489b72 /src/crepe/Sound.cpp | |
parent | 506090032a07f2f3a74a44d8c8774cbdd252c947 (diff) |
more WIP audio facade
Diffstat (limited to 'src/crepe/Sound.cpp')
-rw-r--r-- | src/crepe/Sound.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/crepe/Sound.cpp b/src/crepe/Sound.cpp index f45a697..d48393c 100644 --- a/src/crepe/Sound.cpp +++ b/src/crepe/Sound.cpp @@ -1,9 +1,24 @@ #include "Sound.h" +#include "SoundSystem.h" using namespace crepe; -Sound::Sound(std::unique_ptr<api::Resource> res) { - _res = std::move(res); +Sound::Sound(std::unique_ptr<api::Resource> res, SoundSystem & system) : system(system) { + this->res = std::move(res); } +void Sound::play() { + if (this->system.engine.getPause(this->handle)) { + // resume if paused + this->system.engine.setPause(this->handle, false); + } else { + // or start new sound + this->handle = this->system.engine.play(this->sample); + } +} + +void Sound::pause() { + if (this->system.engine.getPause(this->handle)) return; + this->system.engine.setPause(this->handle, true); +} |