From c63d900a9383b74fbd8a5fa7209a0b2a6364a913 Mon Sep 17 00:00:00 2001 From: OBattler Date: Thu, 3 Apr 2025 06:35:53 +0200 Subject: [PATCH] CMS: Divide SAA samples by 2 so that the sum remains within the -32767 to 32768 range and avoids clipping. --- src/sound/snd_cms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound/snd_cms.c b/src/sound/snd_cms.c index c6591b1fc..9491e3076 100644 --- a/src/sound/snd_cms.c +++ b/src/sound/snd_cms.c @@ -34,7 +34,7 @@ cms_get_buffer(int32_t *buffer, int len, void *priv) cms_update(cms); for (int c = 0; c < len * 2; c++) - buffer[c] += cms->buffer[c]; + buffer[c] += (cms->buffer[c] / 2); cms->pos = 0; } @@ -47,7 +47,7 @@ cms_get_buffer_2(int32_t *buffer, int len, void *priv) cms_update(cms); for (int c = 0; c < len * 2; c++) - buffer[c] += cms->buffer2[c]; + buffer[c] += (cms->buffer2[c] / 2); cms->pos2 = 0; }