all repos — mgba @ ca80e5f32b913bdfd1309f769b744d21910e4f11

mGBA Game Boy Advance Emulator

Add l/r channel scaling
Jeffrey Pfau jeffrey@endrift.com
Sun, 20 Oct 2013 01:58:52 -0700
commit

ca80e5f32b913bdfd1309f769b744d21910e4f11

parent

cc8eeb4353246cceb598e2de2829a1ce965d5281

1 files changed, 12 insertions(+), 9 deletions(-)

jump to
M src/gba/gba-audio.csrc/gba/gba-audio.c

@@ -450,39 +450,42 @@

static void _sample(struct GBAAudio* audio) { int32_t sampleLeft = 0; int32_t sampleRight = 0; - int psgShift = 2 - audio->volume; + int psgShift = 1 + audio->volume; if (audio->ch1Left) { - sampleLeft += audio->ch1.sample >> psgShift; + sampleLeft += audio->ch1.sample; } if (audio->ch1Right) { - sampleRight += audio->ch1.sample >> psgShift; + sampleRight += audio->ch1.sample; } if (audio->ch2Left) { - sampleLeft += audio->ch2.sample >> psgShift; + sampleLeft += audio->ch2.sample; } if (audio->ch2Right) { - sampleRight += audio->ch2.sample >> psgShift; + sampleRight += audio->ch2.sample; } if (audio->ch3Left) { - sampleLeft += audio->ch3.sample >> psgShift; + sampleLeft += audio->ch3.sample; } if (audio->ch3Right) { - sampleRight += audio->ch3.sample >> psgShift; + sampleRight += audio->ch3.sample; } if (audio->ch4Left) { - sampleLeft += audio->ch4.sample >> psgShift; + sampleLeft += audio->ch4.sample; } if (audio->ch4Right) { - sampleRight += audio->ch4.sample >> psgShift; + sampleRight += audio->ch4.sample; } + + sampleLeft = (sampleLeft * (1 + audio->volumeLeft)) >> psgShift; + sampleRight = (sampleRight * (1 + audio->volumeRight)) >> psgShift; if (audio->chALeft) { sampleLeft += (audio->chA.sample << 2) >> !audio->volumeChA;