From c3136b914e6577610019ae52c872b03028eb81c4 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 9 Jul 2014 03:52:58 -0700 Subject: [PATCH] Fix sampling order of sound channel 3 --- src/gba/gba-audio.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gba/gba-audio.c b/src/gba/gba-audio.c index 5e3f70076..184cc9797 100644 --- a/src/gba/gba-audio.c +++ b/src/gba/gba-audio.c @@ -563,15 +563,17 @@ static int32_t _updateChannel3(struct GBAAudioChannel3* ch) { start = 3; end = 0; } - uint32_t bitsCarry = ch->wavedata[end] & 0xF0000000; + uint32_t bitsCarry = ch->wavedata[end] & 0x0F000000; uint32_t bits; for (i = start; i >= end; --i) { - bits = ch->wavedata[i] & 0xF0000000; - ch->wavedata[i] <<= 4; - ch->wavedata[i] |= bitsCarry >> 28; + bits = ch->wavedata[i] & 0x0F000000; + ch->wavedata[i] = ((ch->wavedata[i] & 0xF0F0F0F0) >> 4) | ((ch->wavedata[i] & 0x000F0F0F) << 12); + ch->wavedata[i] |= bitsCarry >> 20; bitsCarry = bits; } - ch->sample = ((bitsCarry >> 26) - 0x20) * volume; + ch->sample = (bitsCarry >> 20); + ch->sample >>= 2; + ch->sample *= volume; return 8 * (2048 - ch->control.rate); }