From ac7458f91608d89c5921f0de6581ac1f139c68bd Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Sat, 9 Jan 2010 02:17:17 +0000 Subject: SCI: Fix handling of output rate in PCJr driver svn-id: r47193 --- engines/sci/sound/softseq/pcjr.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/engines/sci/sound/softseq/pcjr.cpp b/engines/sci/sound/softseq/pcjr.cpp index 8b3df58737..3dc5af3be5 100644 --- a/engines/sci/sound/softseq/pcjr.cpp +++ b/engines/sci/sound/softseq/pcjr.cpp @@ -27,7 +27,6 @@ namespace Sci { -#define FREQUENCY 44100 #define VOLUME_SHIFT 3 #define BASE_NOTE 129 // A10 @@ -163,6 +162,7 @@ void MidiDriver_PCJr::generateSamples(int16 *data, int len) { int i; int chan; int freq[kMaxChannels]; + int frequency = getRate(); for (chan = 0; chan < _channels_nr; chan++) freq[chan] = get_freq(_notes[chan]); @@ -176,20 +176,20 @@ void MidiDriver_PCJr::generateSamples(int16 *data, int len) { >> VOLUME_SHIFT; _freq_count[chan] += freq[chan]; - while (_freq_count[chan] >= (FREQUENCY << 1)) - _freq_count[chan] -= (FREQUENCY << 1); + while (_freq_count[chan] >= (frequency << 1)) + _freq_count[chan] -= (frequency << 1); if (_freq_count[chan] - freq[chan] < 0) { /* Unclean rising edge */ int l = volume << 1; result += -volume + (l * _freq_count[chan]) / freq[chan]; - } else if (_freq_count[chan] >= FREQUENCY - && _freq_count[chan] - freq[chan] < FREQUENCY) { + } else if (_freq_count[chan] >= frequency + && _freq_count[chan] - freq[chan] < frequency) { /* Unclean falling edge */ int l = volume << 1; - result += volume - (l * (_freq_count[chan] - FREQUENCY)) / freq[chan]; + result += volume - (l * (_freq_count[chan] - frequency)) / freq[chan]; } else { - if (_freq_count[chan] < FREQUENCY) + if (_freq_count[chan] < frequency) result += volume; else result += -volume; -- cgit v1.2.3