From 9533f5605aa9203dc3f10d3f638685a74f347795 Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Thu, 5 Jun 2003 08:45:24 +0000 Subject: Synchronize channels playing the same frequency. This prevents interference effects. svn-id: r8318 --- scumm/player_v2.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'scumm') diff --git a/scumm/player_v2.cpp b/scumm/player_v2.cpp index 30176759aa..cc4f67a7ca 100644 --- a/scumm/player_v2.cpp +++ b/scumm/player_v2.cpp @@ -35,7 +35,6 @@ #define FB_WNOISE 0x12000 /* feedback for white noise */ #define FB_PNOISE 0x08000 /* feedback for periodic noise */ - const uint8 note_lengths[] = { 0, 0, 0, 2, @@ -884,12 +883,32 @@ void Player_V2::generateSpkSamples(int16 *data, int len) { } void Player_V2::generatePCjrSamples(int16 *data, int len) { - int i; + int i, j; int freq, vol; memset(data, 0, sizeof(int16) * len); bool hasdata = false; + for (i = 1; i < 3; i++) { + freq = channels[i].d.freq >> 6; + if (channels[i].d.volume && channels[i].d.time_left) { + for (j = 0; j < i; j++) { + if (channels[j].d.volume + && channels[j].d.time_left + && freq == (channels[j].d.freq >> 6)) { + /* HACK: this channel is playing at + * the same frequency as another. + * Synchronize it to the same phase to + * prevent interference. + */ + _timer_count[i] = _timer_count[j]; + _timer_output ^= (1 << i) & + (_timer_output ^ _timer_output << (i - j)); + } + } + } + } + for (i = 0; i < 4; i++) { freq = channels[i].d.freq >> 6; vol = (65535 - channels[i].d.volume) >> 12; -- cgit v1.2.3