Skip to content

Commit

Permalink
[Fix] I3DL2Reverb: Avoid NaNs in room filter calculation. Found with …
Browse files Browse the repository at this point in the history
…afl++ + ubsan.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22232 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Nov 18, 2024
1 parent c03c5c9 commit d5de303
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion soundlib/plugins/dmo/I3DL2Reverb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ void I3DL2Reverb::RecalculateI3DL2ReverbParams()
m_roomFilter = 0.0f;
} else
{
float freq = std::cos(HFReference() * (2.0f * mpt::numbers::pi_v<float>) / m_effectiveSampleRate);
float freq = std::min(std::cos(HFReference() * (2.0f * mpt::numbers::pi_v<float>) / m_effectiveSampleRate), 0.9999f);
float roomFilter = (freq * (roomHF + roomHF) - 2.0f + std::sqrt(freq * (roomHF * roomHF * freq * 4.0f) + roomHF * 8.0f - roomHF * roomHF * 4.0f - roomHF * freq * 8.0f)) / (roomHF + roomHF - 2.0f);
m_roomFilter = Clamp(roomFilter, 0.0f, 1.0f);
}
Expand Down

0 comments on commit d5de303

Please sign in to comment.