From 60a45d3aa3b5900216f0e069e5af901d93013307 Mon Sep 17 00:00:00 2001 From: Norihiro Kamae Date: Wed, 21 Aug 2024 21:12:13 +0900 Subject: [PATCH] UI: Use std::clamp instead of macro --- UI/volume-control.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/UI/volume-control.cpp b/UI/volume-control.cpp index db994b3c0..0111858ab 100644 --- a/UI/volume-control.cpp +++ b/UI/volume-control.cpp @@ -15,7 +15,6 @@ using namespace std; -#define CLAMP(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x))) #define FADER_PRECISION 4096.0 // Size of the audio indicator in pixels @@ -1004,8 +1003,9 @@ VolumeMeter::calculateBallisticsForChannel(int channelNr, uint64_t ts, // 20 dB / 1.7 seconds for Medium Profile (Type I PPM) // 24 dB / 2.8 seconds for Slow Profile (Type II PPM) float decay = float(peakDecayRate * timeSinceLastRedraw); - displayPeak[channelNr] = CLAMP(displayPeak[channelNr] - decay, - currentPeak[channelNr], 0); + displayPeak[channelNr] = + std::clamp(displayPeak[channelNr] - decay, + currentPeak[channelNr], 0.f); } if (currentPeak[channelNr] >= displayPeakHold[channelNr] || @@ -1060,8 +1060,8 @@ VolumeMeter::calculateBallisticsForChannel(int channelNr, uint64_t ts, (timeSinceLastRedraw / magnitudeIntegrationTime) * 0.99); displayMagnitude[channelNr] = - CLAMP(displayMagnitude[channelNr] + attack, - (float)minimumLevel, 0); + std::clamp(displayMagnitude[channelNr] + attack, + (float)minimumLevel, 0.f); } }