From 7e52772413ecb0ccbb96a36691211de4c43a1914 Mon Sep 17 00:00:00 2001 From: mcfnord Date: Sat, 25 Jul 2026 02:03:32 +0000 Subject: [PATCH 1/2] Clamp Input Boost instead of letting it wrap around The Input Boost setting (2x..10x) multiplied each sample and narrowed the int result back to int16_t with a plain cast, so any sample boosted past full scale wrapped to the opposite polarity rather than clipping. Use Float2Short, the same saturating helper already used twice in this function, so boosted peaks clip instead of inverting. Co-Authored-By: Claude Opus 5 --- src/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index fb9bab5478..03d57ed817 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1429,8 +1429,8 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) // apply a general gain boost to all audio input: for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 ) { - vecsStereoSndCrd[j + 1] = static_cast ( iInputBoost * vecsStereoSndCrd[j + 1] ); - vecsStereoSndCrd[j] = static_cast ( iInputBoost * vecsStereoSndCrd[j] ); + vecsStereoSndCrd[j + 1] = Float2Short ( static_cast ( iInputBoost ) * vecsStereoSndCrd[j + 1] ); + vecsStereoSndCrd[j] = Float2Short ( static_cast ( iInputBoost ) * vecsStereoSndCrd[j] ); } } From ce288f39644e6602f262d59d023db51ad17fc163 Mon Sep 17 00:00:00 2001 From: jrd Date: Sat, 5 Sep 2026 07:01:15 +0000 Subject: [PATCH 2/2] Drop the redundant static_cast in the Input Boost clamp Float2Short() takes a const float, so the int product converts at the call; the cast changed nothing. Checked exhaustively (every int16_t sample x boost 1..10: 655,360 cases, 0 differences) and end-to-end with the rig (server-side WAV clips, 0 wrapped sample steps). Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01S8KACM96jgMTGCLbqqta9Z --- src/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 03d57ed817..b0a9bc0cbe 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1429,8 +1429,8 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) // apply a general gain boost to all audio input: for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 ) { - vecsStereoSndCrd[j + 1] = Float2Short ( static_cast ( iInputBoost ) * vecsStereoSndCrd[j + 1] ); - vecsStereoSndCrd[j] = Float2Short ( static_cast ( iInputBoost ) * vecsStereoSndCrd[j] ); + vecsStereoSndCrd[j + 1] = Float2Short ( iInputBoost * vecsStereoSndCrd[j + 1] ); + vecsStereoSndCrd[j] = Float2Short ( iInputBoost * vecsStereoSndCrd[j] ); } }