From b95bbb2ace6a240da8b6ee54ceb66c6ab2484ab7 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 9 Aug 2011 23:57:22 +0200 Subject: CMS: Do proper clipping of the sound data on generation. This fixes some overflows/underflows which resulted in crackling. --- audio/softsynth/cms.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/softsynth/cms.cpp b/audio/softsynth/cms.cpp index 67eacd1a41..889f19a6f9 100644 --- a/audio/softsynth/cms.cpp +++ b/audio/softsynth/cms.cpp @@ -244,8 +244,8 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) { } } /* write sound data to the buffer */ - buffer[j*2] += output_l / 6; - buffer[j*2+1] += output_r / 6; + buffer[j*2+0] = CLIP(buffer[j*2+0] + output_l / 6, -32768, 32767); + buffer[j*2+1] = CLIP(buffer[j*2+1] + output_r / 6, -32768, 32767); } } -- cgit v1.2.3