From 5a0e4e7a2d23cb5736b792c4e985ac950ca5587d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 23 Nov 2014 00:23:37 -0800 Subject: [PATCH] GBA Audio: Fix integer overflow sampling of channel 3 --- src/gba/gba-audio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gba/gba-audio.c b/src/gba/gba-audio.c index 0121d2159..83d7125d3 100644 --- a/src/gba/gba-audio.c +++ b/src/gba/gba-audio.c @@ -655,9 +655,9 @@ static int32_t _updateChannel3(struct GBAAudioChannel3* ch) { ch->wavedata[i] |= bitsCarry >> 20; bitsCarry = bits; } - ch->sample = (bitsCarry >> 20); - ch->sample >>= 2; - ch->sample *= volume; + ch->sample = bitsCarry >> 24; + ch->sample -= 8; + ch->sample *= volume * 4; return 8 * (2048 - ch->control.rate); }