diff --git a/include/amuse/Engine.hpp b/include/amuse/Engine.hpp index 1ece7d6..14f0de9 100644 --- a/include/amuse/Engine.hpp +++ b/include/amuse/Engine.hpp @@ -49,6 +49,7 @@ class Engine std::unordered_map> m_sfxLookup; std::linear_congruential_engine m_random; int m_nextVid = 0; + float m_masterVolume = 1.f; AudioGroup* _addAudioGroup(const AudioGroupData& data, std::unique_ptr&& grp); std::pair _findSongGroup(int groupId) const; diff --git a/lib/Engine.cpp b/lib/Engine.cpp index f43f546..c5bada3 100644 --- a/lib/Engine.cpp +++ b/lib/Engine.cpp @@ -388,7 +388,7 @@ std::shared_ptr Engine::seqPlay(int groupId, int songId, const unsign /** Set total volume of engine */ void Engine::setVolume(float vol) { - m_backend.setVolume(vol); + m_masterVolume = vol; } /** Find voice from VoiceId */ diff --git a/lib/Voice.cpp b/lib/Voice.cpp index 62ca6c9..42bc254 100644 --- a/lib/Voice.cpp +++ b/lib/Voice.cpp @@ -192,7 +192,7 @@ std::list>::iterator Voice::_destroyVoice(std::list static T ApplyVolume(float vol, T samp) { - return samp * 0.5f * vol; + return samp * 0.7f * vol; } void Voice::_procSamplePre(int16_t& samp) @@ -219,7 +219,7 @@ void Voice::_procSamplePre(int16_t& samp) float l = clamp(0.f, m_lastLevel * (1.f - t) + m_nextLevel * t, 1.f); /* Apply total volume to sample using decibel scale */ - samp = ApplyVolume(l, samp); + samp = ApplyVolume(l * m_engine.m_masterVolume, samp); return; } @@ -313,7 +313,7 @@ void Voice::_procSamplePre(int16_t& samp) m_nextLevel = clamp(0.f, m_nextLevel, 1.f); /* Apply total volume to sample using decibel scale */ - samp = ApplyVolume(m_nextLevel, samp); + samp = ApplyVolume(m_nextLevel * m_engine.m_masterVolume, samp); } template