MiSTer-devel / GBA_MiSTer

GBA for MiSTer
GNU General Public License v2.0
143 stars 44 forks source link

Inaccurate Music Balance #143

Open DarthPidgey opened 9 months ago

DarthPidgey commented 9 months ago

In several cases I've found inaccurate music in games, for lack of a better term as a am not technically sound at GBA processing, the balance in instruments seems to be off or nearly gone? Notable examples include Game Corner (Pokemon Ruby Sapphire Emerald) Ever Grande City (Pokemon Ruby Sapphire Emerald) Trainer Battle (Pokemon Firered LeafGreen) Pokedex (Pokemon Pinball Ruby and Sapphire) Hot Crater Act 1 (Sonic Advance 2) A common thread seems to be static noise used as percussion or an instrument between all these songs? I have more song recordings but the upload limit seems to be a problem so I chose Hot Crater as the most noticeable example, around halfway through the song the static instrument seems to be nearly if not missing on MiSTer? It's missing through both HDMI and IO board. Music Comparison.zip

birdybro commented 8 months ago

I hear the difference, it's the little shaking sand like instrument a few seconds in after the 3-2-1 countdown. That one instrument is heavily de-emphasized in the MiSTer core compared to whatever recording you have.

Just making sure regarding the recording off of your real GBA, is that a sound-modded GBA at all?

DarthPidgey commented 8 months ago

No, it's a stock original model gba from 2002, to my ears the balance is the same on all the other real hardware examples I have like micro, gb player, sp, though ideally gba would get something like mdfourier to help this issue

birdybro commented 8 months ago

Robert confirmed it can be fixed, he linked me to the relevant code in NanoBoyAdvance and the mentioned issue above has the details. The equivalent code from this section of the APU of that emulator needs to be implemented:

sample[channel] += psg_sample * psg_volume * psg.master[channel] / 28;

for(int fifo = 0; fifo < 2; fifo++) {
  if(dma[fifo].enable[channel]) {
    sample[channel] += latch[fifo] * dma_volume_tab[dma[fifo].volume];
  }
}

sample[channel] += mmio.bias.level;
sample[channel]  = std::clamp(sample[channel], s16(0), s16(0x3FF));
sample[channel] -= 0x200;

Division operators should generally be avoided at all costs in hardware design languages and multipliers will infer DSP blocks to be used. Trying to do it all with bit shifts and adds/subtracts would probably not be very precise and could lead to longer chains, so I think using a LUT might be preferred, checking resource usage of the GBA2P core to see what is best to do.

Yup, plenty of BRAM in GBA2P, limited DSP available in it though, so BRAM would probably be best.

birdybro commented 8 months ago

@DarthPidgey Can you please try this attached build for me and see if it's fixed?

Thank you!

GBA.zip

DarthPidgey commented 8 months ago

It's not fixed but also unless i'm doing something wrong, everything sounds completely wrong now. like entire parts of the song are just missing now, like several channels are completely missing instead of just being too quiet, making for an even more flat sound

DarthPidgey commented 8 months ago

Let me add a recording of your build as well for hot crater act 1 experimental build hot crater act 1.zip

birdybro commented 8 months ago

Yup, figured it wouldn't be that easy :p

birdybro commented 8 months ago

Try this one out and see how it sounds to you for me please. It's not complete, but more to make sure I'm hearing it correctly.

GBA.zip

DarthPidgey commented 8 months ago

I'm not a programmer in the slightest but I'd say what you have done is absolutely on the right track here, compared to the latest official core i can here the missing sound and the quiet sound is now more balanced. In one of my mentioned songs, the Pokemon Fire red Leaf green trainer battle song at the beginning there is a bit of sound corruption but without that it still sounds considerably closer to the real GBA. And Hot Crater act 1 seems pretty close already.

birdybro commented 8 months ago

GBA.zip

How about this one, is it better?

DarthPidgey commented 8 months ago

there's still the oddly loud sound in pokemon FRLG and i think Hot Crater Act 1 is still too quiet, i have at least another recording of your current build running Hot Crater Act 1. experimental build 3.zip

DarthPidgey commented 8 months ago

And here's a recording of the beginning of the Pokemon FRLG Trainer Battle. Notice the sudden sharp noise? That's normally a lot quieter on real hardware and the official mister builds. How vexing now that there's something that's too loud. Experimental build 3 Pokemon FRLG Trainer Battle.zip

birdybro commented 8 months ago

Does that take awhile to get to the point of that sound in Pokemon? Do you have a save file?

DarthPidgey commented 8 months ago

I am using one of the debug roms floating around cause it has a sound test. The sound test doesn't change the music as my real hardware recordings are also from the sound test. But i'll also make a save file in a stock rom in just a moment.

DarthPidgey commented 8 months ago

Here. just walk down out of the lab and the rival will automatically challenge you and the trainer battle theme will start after the dialogue. Pokemon Firered Save.zip

DarthPidgey commented 8 months ago

In the meantime I have also redone my recording of the Pokemon FRLG Trainer Battle theme on a real GBA to get it under the upload limit Pokemon FRLG Trainer Battle Real GBA.zip

birdybro commented 8 months ago

Thanks to test roms I received and some advice from Robert, it looks like this is probably a bit deeper of a problem than just any volume balance. I'm gonna try and keep working on this, but the hack test example core i gave is not how it should be fixed unfortunately. I'll get back to you if I figure something out. Thanks for testing!

DarthPidgey commented 6 months ago

the march 17th build didn't fix this

birdybro commented 6 months ago

It wasn't supposed to, they were just framework changes.