diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-01 17:21:37 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-01 17:21:37 +0200 |
commit | 311e98572c26750e4a4695079fa80ca5648d109e (patch) | |
tree | f28e18a0df9f39932b0e2e4ec292bf01cc7a661f /src/crepe/Sound.cpp | |
parent | de288a859a631acf6aac10fad825cafaa3744dc9 (diff) |
implement remaining Sound functions
Diffstat (limited to 'src/crepe/Sound.cpp')
-rw-r--r-- | src/crepe/Sound.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/crepe/Sound.cpp b/src/crepe/Sound.cpp index 136a71d..20f1787 100644 --- a/src/crepe/Sound.cpp +++ b/src/crepe/Sound.cpp @@ -20,19 +20,42 @@ void Sound::load(std::unique_ptr<api::Resource> res) { } void Sound::play() { - SoundSystem & system = SoundSystem::instance(); + SoundSystem & system = SoundSystem::get_instance(); if (system.engine.getPause(this->handle)) { // resume if paused system.engine.setPause(this->handle, false); } else { // or start new sound - this->handle = system.engine.play(this->sample); + this->handle = system.engine.play(this->sample, this->volume); + system.engine.setLooping(this->handle, this->looping); } } void Sound::pause() { - SoundSystem & system = SoundSystem::instance(); + SoundSystem & system = SoundSystem::get_instance(); if (system.engine.getPause(this->handle)) return; system.engine.setPause(this->handle, true); } +void Sound::rewind() { + SoundSystem & system = SoundSystem::get_instance(); + if (!system.engine.isValidVoiceHandle(this->handle)) return; + system.engine.seek(this->handle, 0); +} + +void Sound::set_volume(float volume) { + this->volume = volume; + + SoundSystem & system = SoundSystem::get_instance(); + if (!system.engine.isValidVoiceHandle(this->handle)) return; + system.engine.setVolume(this->handle, this->volume); +} + +void Sound::set_looping(bool looping) { + this->looping = looping; + + SoundSystem & system = SoundSystem::get_instance(); + if (!system.engine.isValidVoiceHandle(this->handle)) return; + system.engine.setLooping(this->handle, this->looping); +} + |