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

Implement a high-level emulation of the MP2K audio mixer. #170

Merged
merged 18 commits into from
Aug 1, 2021
Merged

Conversation

fleroviux
Copy link
Member

No description provided.

@fleroviux fleroviux merged commit 823cc5a into master Aug 1, 2021
@fleroviux fleroviux deleted the mp2k-hle branch August 1, 2021 19:59
@fleroviux fleroviux restored the mp2k-hle branch August 6, 2021 07:42
@fleroviux fleroviux deleted the mp2k-hle branch August 6, 2021 07:44
@birdybro
Copy link

birdybro commented Feb 2, 2024

Hi!

I'm looking into what the specific reasoning was for this formula in the apu:

sample[channel] += psg_sample * psg_volume * psg.master[channel] / (28.0 * 0x200);

Hopefully looking to help resolve this issue with the information --> MiSTer-devel/GBA_MiSTer#143

Thank you so much! :)

@fleroviux
Copy link
Member Author

@birdybro psg_volume can take values from 0 to 4 (see psg_volume_tab), psg.master[channel] can take values from 0 to 7. psg_sample iirc has a range of -0x1FC to 0x200 (because each channel has a range of -127 to +128). So dividing by 4 * 7 * 0x200 the mix of the channels is normalized to a roundabout -1.0f to +1.0f range.

However this is for the HQ mixer, which uses floating point math for the final mix. See https://github.com/nba-emu/NanoBoyAdvance/blob/master/src/nba/src/hw/apu/apu.cpp#L186-L196 for the more accurate implementation which has the 28 factor but not the 0x200 factor.

@birdybro
Copy link

birdybro commented Feb 2, 2024

Thank you! Much appreciated! :)

@birdybro
Copy link

birdybro commented Feb 2, 2024

After talking with the developer of that core when I noticed something different...

constexpr int psg_volume_tab[4] = { 1, 2, 4, 0 };

This ordering of the division factor is different than no$'s documentation (his would be represented as {4, 2, 1, 0} instead AFAICT). I am going to test making the MiSTer GBA core reflect your division factor since I suspect that's the root cause (and it's the easiest thing to test first lol).

https://github.com/MiSTer-devel/GBA_MiSTer/blob/master/rtl/gba_sound.vhd#L421-L427 - is the area I changed and am going test later...

Edit: nope, not the root cause.

@fleroviux
Copy link
Member Author

@birdybro this is what I'm seeing in GBATEK (see SOUNDCNT_H):

  0-1   R/W  Sound # 1-4 Volume   (0=25%, 1=50%, 2=100%, 3=Prohibited)

@birdybro
Copy link

birdybro commented Feb 4, 2024

Yeah I was just being stupid and not reading it right. The core is correct. Sorry.

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

Successfully merging this pull request may close these issues.

2 participants