diff --git a/src/AudioLib/MaSoundInstance.cpp b/src/AudioLib/MaSoundInstance.cpp index 1038064..d08d5c1 100644 --- a/src/AudioLib/MaSoundInstance.cpp +++ b/src/AudioLib/MaSoundInstance.cpp @@ -70,8 +70,8 @@ void MaSoundInstance::Destroy() } m_Initialized = false; m_Identity = ""; - m_FadeTargetVolume = 0; - m_FadeRatePerFrame = 0; + m_FadeTargetVolume = 0.0f; + m_FadeRatePerFrame = 0.0f; } bool MaSoundInstance::IsInitialized() const @@ -149,21 +149,21 @@ void MaSoundInstance::Fade(float toVolume, float secDurationFromMinMax) void MaSoundInstance::StopFading() { - m_FadeRatePerFrame = 0; + m_FadeRatePerFrame = 0.0f; } bool MaSoundInstance::IsFading() const { - return m_FadeRatePerFrame != 0; + return m_FadeRatePerFrame != 0.0f; } void MaSoundInstance::Update(float volumeFactor) // volume factor is the user's volume { - if (m_FadeRatePerFrame != 0) + if (m_FadeRatePerFrame != 0.0f) { float targetVolume = std::clamp(m_FadeTargetVolume * volumeFactor, 0.0f, 1.0f); float volume = std::clamp(GetVolume() + (m_FadeRatePerFrame * volumeFactor), 0.0f, 1.0f); - if ((m_FadeRatePerFrame > 0 && volume >= targetVolume) || (m_FadeRatePerFrame < 0 && volume <= targetVolume)) + if ((m_FadeRatePerFrame > 0.0f && volume >= targetVolume) || (m_FadeRatePerFrame < 0.0f && volume <= targetVolume)) { volume = m_FadeTargetVolume * volumeFactor; m_FadeRatePerFrame = 0.0f; diff --git a/src/AudioLib/SoundEngine.cpp b/src/AudioLib/SoundEngine.cpp index 923c1c6..87af183 100644 --- a/src/AudioLib/SoundEngine.cpp +++ b/src/AudioLib/SoundEngine.cpp @@ -171,7 +171,7 @@ void SoundEngine::SaveVolume(bool isMinimized) if (m_MasterVolume <= outOfFocusVolume) outOfFocusVolume = m_MasterVolume; - m_MasterVolumeFadeTarget = isMinimized ? 0 : outOfFocusVolume; + m_MasterVolumeFadeTarget = isMinimized ? 0.0f : outOfFocusVolume; m_MasterVolumeFadeRatePerFrame = -ratePerSecond / durationOnFullVolume; } @@ -216,7 +216,7 @@ void SoundEngine::Update() if (m_MasterVolumeFadeRatePerFrame) { float volume = ma_engine_get_volume(&m_Engine) + m_MasterVolumeFadeRatePerFrame; - if ((m_MasterVolumeFadeRatePerFrame > 0 && volume >= m_MasterVolumeFadeTarget) || (m_MasterVolumeFadeRatePerFrame < 0 && volume <= m_MasterVolumeFadeTarget)) + if ((m_MasterVolumeFadeRatePerFrame > 0.0f && volume >= m_MasterVolumeFadeTarget) || (m_MasterVolumeFadeRatePerFrame < 0.0f && volume <= m_MasterVolumeFadeTarget)) { volume = m_MasterVolumeFadeTarget; m_MasterVolumeFadeRatePerFrame = 0.0f; diff --git a/src/AudioLib/SoundEngine.h b/src/AudioLib/SoundEngine.h index fc51f37..acf2fc5 100644 --- a/src/AudioLib/SoundEngine.h +++ b/src/AudioLib/SoundEngine.h @@ -89,10 +89,10 @@ private: // One song at a time, but holding both current and previous for graceful fading std::array m_Music; int m_CurrentMusicIndex{}; - float m_MusicVolume{ 1.0 }; - float m_SoundVolume{ 1.0 }; + float m_MusicVolume{ 1.0f }; + float m_SoundVolume{ 1.0f }; - float m_MasterVolume{ 1.0 }; + float m_MasterVolume{ 1.0f }; float m_MasterVolumeFadeTarget{}; float m_MasterVolumeFadeRatePerFrame{}; };