Audio engine: small bug(see desc)

The music wouldn't play if the sound was 0 and you changed the song because it would be stopped by the fade during the next frame.
This commit is contained in:
Amun
2025-10-08 21:34:43 +03:00
parent 01f4417d80
commit 7caf9639e0

View File

@@ -140,11 +140,12 @@ void MaSoundInstance::Config3D(bool toggle, float minDist, float maxDist)
void MaSoundInstance::Fade(float toVolume, float secDurationFromMinMax) void MaSoundInstance::Fade(float toVolume, float secDurationFromMinMax)
{ {
toVolume = std::clamp<float>(toVolume, 0.0f, 1.0f); m_FadeTargetVolume = std::clamp<float>(toVolume, 0.0f, 1.0f);
m_FadeTargetVolume = toVolume; if (m_FadeTargetVolume != GetVolume())
{
float rate = 1.0f / CS_CLIENT_FPS / secDurationFromMinMax; const float rate = 1.0f / CS_CLIENT_FPS / secDurationFromMinMax;
m_FadeRatePerFrame = GetVolume() > toVolume ? -rate : rate; m_FadeRatePerFrame = GetVolume() > m_FadeTargetVolume ? -rate : rate;
}
} }
void MaSoundInstance::StopFading() void MaSoundInstance::StopFading()