aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorJochen Hoenicke2003-06-05 08:45:24 +0000
committerJochen Hoenicke2003-06-05 08:45:24 +0000
commit9533f5605aa9203dc3f10d3f638685a74f347795 (patch)
tree93a0a584d8bd4f26b82bfd6cc60fa544b40d6446 /scumm
parentd510447d0505915bd11535137b8382db72a5c460 (diff)
downloadscummvm-rg350-9533f5605aa9203dc3f10d3f638685a74f347795.tar.gz
scummvm-rg350-9533f5605aa9203dc3f10d3f638685a74f347795.tar.bz2
scummvm-rg350-9533f5605aa9203dc3f10d3f638685a74f347795.zip
Synchronize channels playing the same frequency. This prevents
interference effects. svn-id: r8318
Diffstat (limited to 'scumm')
-rw-r--r--scumm/player_v2.cpp23
1 files changed, 21 insertions, 2 deletions
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;