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(-) (limited to 'audio') 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 From 3635efd92cdc48661abd23780520626a12be09d4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 9 Aug 2011 23:59:31 +0200 Subject: CMS: Simplify code a tiny bit. --- audio/softsynth/cms.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'audio') diff --git a/audio/softsynth/cms.cpp b/audio/softsynth/cms.cpp index 889f19a6f9..a675da3f03 100644 --- a/audio/softsynth/cms.cpp +++ b/audio/softsynth/cms.cpp @@ -163,19 +163,15 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) { struct SAA1099 *saa = &_saa1099[chip]; int j, ch; + if (chip == 0) { + memset(buffer, 0, sizeof(int16)*length*2); + } + /* if the channels are disabled we're done */ if (!saa->all_ch_enable) { - /* init output data */ - if (chip == 0) { - memset(buffer, 0, sizeof(int16)*length*2); - } return; } - if (chip == 0) { - memset(buffer, 0, sizeof(int16)*length*2); - } - for (ch = 0; ch < 2; ch++) { switch (saa->noise_params[ch]) { case 0: saa->noise[ch].freq = 31250.0 * 2; break; -- cgit v1.2.3 From bb3d1f2738ccd3fd5a06a2570d23c27a11589288 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 12 Aug 2011 03:22:01 +0200 Subject: AUDIO: Replace macro in emumidi code with enum. --- audio/softsynth/emumidi.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'audio') diff --git a/audio/softsynth/emumidi.h b/audio/softsynth/emumidi.h index f3d7645f87..f72dad7eaf 100644 --- a/audio/softsynth/emumidi.h +++ b/audio/softsynth/emumidi.h @@ -26,8 +26,6 @@ #include "audio/mididrv.h" #include "audio/mixer.h" -#define FIXP_SHIFT 16 - class MidiDriver_Emulated : public Audio::AudioStream, public MidiDriver { protected: bool _isOpen; @@ -38,6 +36,10 @@ private: Common::TimerManager::TimerProc _timerProc; void *_timerParam; + enum { + FIXP_SHIFT = 16 + }; + int _nextTick; int _samplesPerTick; -- cgit v1.2.3