Browse Source

UI: Fix low value of std::clamp gets greater than high value

`std::clamp` was introduced at 60a45d3aa3 but it caused a runtime
assertion failure on Windows that checks the low value of `std::clamp`
is not greater than the high value.
Norihiro Kamae 1 year ago
parent
commit
06642fdee4
1 changed files with 1 additions and 1 deletions
  1. 1 1
      UI/volume-control.cpp

+ 1 - 1
UI/volume-control.cpp

@@ -1008,7 +1008,7 @@ VolumeMeter::calculateBallisticsForChannel(int channelNr, uint64_t ts,
 		float decay = float(peakDecayRate * timeSinceLastRedraw);
 		float decay = float(peakDecayRate * timeSinceLastRedraw);
 		displayPeak[channelNr] =
 		displayPeak[channelNr] =
 			std::clamp(displayPeak[channelNr] - decay,
 			std::clamp(displayPeak[channelNr] - decay,
-				   currentPeak[channelNr], 0.f);
+				   std::min(currentPeak[channelNr], 0.f), 0.f);
 	}
 	}
 
 
 	if (currentPeak[channelNr] >= displayPeakHold[channelNr] ||
 	if (currentPeak[channelNr] >= displayPeakHold[channelNr] ||