Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccurate Music Balance #143

Open
DarthPidgey opened this issue Dec 12, 2023 · 19 comments
Open

Inaccurate Music Balance #143

DarthPidgey opened this issue Dec 12, 2023 · 19 comments

Comments

@DarthPidgey
Copy link

DarthPidgey commented Dec 12, 2023

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
Copy link
Member

birdybro commented Feb 2, 2024

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
Copy link
Author

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
Copy link
Member

birdybro commented Feb 2, 2024

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
Copy link
Member

birdybro commented Feb 2, 2024

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

Thank you!

GBA.zip

@DarthPidgey
Copy link
Author

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
Copy link
Author

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

@birdybro
Copy link
Member

birdybro commented Feb 3, 2024

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

@birdybro
Copy link
Member

birdybro commented Feb 4, 2024

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
Copy link
Author

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
Copy link
Member

birdybro commented Feb 4, 2024

GBA.zip

How about this one, is it better?

@DarthPidgey
Copy link
Author

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
Copy link
Author

DarthPidgey commented Feb 4, 2024

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
Copy link
Member

birdybro commented Feb 4, 2024

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

@DarthPidgey
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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
Copy link
Member

birdybro commented Feb 4, 2024

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
Copy link
Author

the march 17th build didn't fix this

@birdybro
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants