all repos — mgba @ 539e63d49b86c097d149c4e6b003783db53d2422

mGBA Game Boy Advance Emulator

GB Audio: Make audio unsigned with bias (fixes #749)
Vicki Pfau vi@endrift.com
Sat, 08 Jul 2017 21:32:51 -0700
commit

539e63d49b86c097d149c4e6b003783db53d2422

parent

15d66422a9d9404066a143298f092163834c2725

2 files changed, 7 insertions(+), 6 deletions(-)

jump to
M CHANGESCHANGES

@@ -1,6 +1,7 @@

0.7.0: (Future) Bugfixes: - GB Audio: Fix zombie mode bit masking + - GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749) Misc: - GBA Timer: Use global cycles for timers
M src/gb/audio.csrc/gb/audio.c

@@ -620,8 +620,9 @@ sampleRight += audio->ch4.sample;

} } - *left = sampleLeft * (1 + audio->volumeLeft); - *right = sampleRight * (1 + audio->volumeRight); + int dcOffset = audio->style == GB_AUDIO_GBA ? 0 : 0x1FC; + *left = (sampleLeft - dcOffset) * (1 + audio->volumeLeft); + *right = (sampleRight - dcOffset) * (1 + audio->volumeRight); } static void _sample(struct mTiming* timing, void* user, uint32_t cyclesLate) {

@@ -710,7 +711,7 @@ return (envelope->initialVolume || envelope->direction) && envelope->dead != 2;

} static void _updateSquareSample(struct GBAudioSquareChannel* ch) { - ch->sample = (ch->control.hi * 2 - 1) * ch->envelope.currentVolume * 0x8; + ch->sample = ch->control.hi * ch->envelope.currentVolume * 0x8; } static int32_t _updateSquareChannel(struct GBAudioSquareChannel* ch) {

@@ -861,8 +862,7 @@ }

ch->sample = bitsCarry >> 4; break; } - ch->sample -= 8; - ch->sample *= volume * 4; + ch->sample *= volume * 2; audio->ch3.readable = true; if (audio->style == GB_AUDIO_DMG) { mTimingDeschedule(audio->timing, &audio->ch3Fade);

@@ -889,7 +889,7 @@ int32_t cycles = 0;

do { int lsb = ch->lfsr & 1; - ch->sample = lsb * 0x10 - 0x8; + ch->sample = lsb * 0x8; ch->sample *= ch->envelope.currentVolume; ch->lfsr >>= 1; ch->lfsr ^= (lsb * 0x60) << (ch->power ? 0 : 8);