Synchronize channels playing the same frequency. This prevents

interference effects.

svn-id: r8318
This commit is contained in:
Jochen Hoenicke 2003-06-05 08:45:24 +00:00
parent d510447d05
commit 9533f5605a

View File

@ -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;