Removed my clamp function to use the C++17 one.
Removed my clamp function to use the C++17 one.

(This time correctly, it doesn't clamp in-place like mine did.)

--- a/src/in_ncsf/SSEQPlayer/Channel.cpp
+++ b/src/in_ncsf/SSEQPlayer/Channel.cpp
@@ -563,7 +563,7 @@
 			if (bModulation && this->modType == 1)
 				totalVol += modParam;
 			totalVol += AMPL_K;
-			clamp(totalVol, 0, AMPL_K);
+			totalVol = std::clamp(totalVol, 0, AMPL_K);
 
 			cr &= ~(SOUND_VOL(0x7F) | SOUND_VOLDIV(3));
 			cr |= SOUND_VOL(static_cast<int>(getvoltbl[totalVol]));
@@ -587,7 +587,7 @@
 			if (bModulation && this->modType == 2)
 				realPan += modParam;
 			realPan += 64;
-			clamp(realPan, 0, 127);
+			realPan = std::clamp(realPan, 0, 127);
 
 			cr &= ~SOUND_PAN(0x7F);
 			cr |= SOUND_PAN(realPan);

--- a/src/in_xsf_framework/XSFCommon.h
+++ b/src/in_xsf_framework/XSFCommon.h
@@ -51,15 +51,6 @@
 	return value + 1;
 }
 
-// Clamp a value between a minimum and maximum value
-template<typename T1, typename T2> inline void clamp(T1 &valueToClamp, const T2 &minValue, const T2 &maxValue)
-{
-	if (valueToClamp < minValue)
-		valueToClamp = minValue;
-	else if (valueToClamp > maxValue)
-		valueToClamp = maxValue;
-}
-
 inline void CopyToString(const std::wstring &src, wchar_t *dst)
 {
 	std::wcscpy(dst, src.c_str());

--- a/src/in_xsf_framework/XSFPlayer.cpp
+++ b/src/in_xsf_framework/XSFPlayer.cpp
@@ -167,8 +167,8 @@
 			double s1 = bufLong[2 * ofs] * scale, s2 = bufLong[2 * ofs + 1] * scale;
 			if (!this->uses32BitSamplesClampedTo16Bit)
 			{
-				clamp(s1, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
-				clamp(s2, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
+				s1 = std::clamp<double>(s1, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
+				s2 = std::clamp<double>(s2, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
 			}
 			bufLong[2 * ofs] = static_cast<std::int32_t>(s1);
 			bufLong[2 * ofs + 1] = static_cast<std::int32_t>(s2);
@@ -181,8 +181,8 @@
 		for (unsigned ofs = 0; ofs < bufsize; ++ofs)
 		{
 			std::int32_t s1 = bufLong[2 * ofs], s2 = bufLong[2 * ofs + 1];
-			clamp(s1, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
-			clamp(s2, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
+			s1 = std::clamp<std::int32_t>(s1, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
+			s2 = std::clamp<std::int32_t>(s2, std::numeric_limits<std::int16_t>::min(), std::numeric_limits<std::int16_t>::max());
 			bufShort[2 * ofs] = static_cast<std::int16_t>(s1);
 			bufShort[2 * ofs + 1] = static_cast<std::int16_t>(s2);
 		}