From dcea685f9ed721e7d2afb64387795aecb20c2671 Mon Sep 17 00:00:00 2001 From: apistol78 Date: Tue, 13 Feb 2024 15:37:44 +0100 Subject: [PATCH] Traktor: Able to set volume through SoundComponent. --- code/Spray/SoundComponent.cpp | 7 ++++++- code/Spray/SoundComponent.h | 2 ++ code/Spray/SprayClassFactory.cpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/Spray/SoundComponent.cpp b/code/Spray/SoundComponent.cpp index 65faca8b87..be21c6f208 100644 --- a/code/Spray/SoundComponent.cpp +++ b/code/Spray/SoundComponent.cpp @@ -22,7 +22,6 @@ SoundComponent::SoundComponent(sound::ISoundPlayer* soundPlayer, const resource: { } - void SoundComponent::destroy() { stop(); @@ -66,6 +65,12 @@ void SoundComponent::stop() m_handle = nullptr; } +void SoundComponent::setVolume(float volume) +{ + if (m_handle != nullptr) + m_handle->setVolume(volume); +} + void SoundComponent::setPitch(float pitch) { if (m_handle != nullptr) diff --git a/code/Spray/SoundComponent.h b/code/Spray/SoundComponent.h index 90da24f729..17f25ecaaa 100644 --- a/code/Spray/SoundComponent.h +++ b/code/Spray/SoundComponent.h @@ -55,6 +55,8 @@ class T_DLLCLASS SoundComponent : public world::IEntityComponent void stop(); + void setVolume(float volume); + void setPitch(float pitch); void setParameter(int32_t id, float parameter); diff --git a/code/Spray/SprayClassFactory.cpp b/code/Spray/SprayClassFactory.cpp index a180aeef92..a7ad72727f 100644 --- a/code/Spray/SprayClassFactory.cpp +++ b/code/Spray/SprayClassFactory.cpp @@ -29,6 +29,7 @@ void SprayClassFactory::createClasses(IRuntimeClassRegistrar* registrar) const auto classSoundComponent = new AutoRuntimeClass< SoundComponent >(); classSoundComponent->addMethod("play", &SoundComponent::play); classSoundComponent->addMethod("stop", &SoundComponent::stop); + classSoundComponent->addMethod("setVolume", &SoundComponent::setVolume); classSoundComponent->addMethod("setPitch", &SoundComponent::setPitch); classSoundComponent->addMethod("setParameter", &SoundComponent::setParameter); registrar->registerClass(classSoundComponent);