From d59054bc7e258c511200ad22b070bb8fd897c158 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 20 Mar 2022 10:14:37 -0400 Subject: [PATCH] cwAudioDeviceAlsa.cpp : Prevent wrapping on 32 bit audio output. --- cwAudioDeviceAlsa.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cwAudioDeviceAlsa.cpp b/cwAudioDeviceAlsa.cpp index a528e3b..f369fc8 100644 --- a/cwAudioDeviceAlsa.cpp +++ b/cwAudioDeviceAlsa.cpp @@ -605,7 +605,11 @@ namespace cw int* dp = (int*)obuf; while( sp < ep ) - *dp++ = (int)(*sp++ * 0x7fffffff); + { + device::sample_t v = *sp++; + v = ((v > 1 ? 1 : v) < -1 ? -1 : v); + *dp++ = (int)(v * 0x7fffffff); + } //*dp++ = (rand() - (RAND_MAX/2)) * 2; }