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

Noisy sample audio in mahjong GBC games by Studio Saizensen #241

Closed
Thelypody opened this issue May 2, 2023 · 6 comments
Closed

Noisy sample audio in mahjong GBC games by Studio Saizensen #241

Thelypody opened this issue May 2, 2023 · 6 comments

Comments

@Thelypody
Copy link

Thelypody commented May 2, 2023

First of all, huge thanks for all recent improvements in the core related to sample playback in GBC games.
I've noticed that even with the latest core (20230501) some games still have noticeable noise over played voice samples. All of those I found are, perhaps not coincidentally, from the same developer's titles.

Dejiko no Mahjong Party (Japan).gbc
Kidou Senkan Nadesico - Ruri Ruri Mahjong (Japan).gbc
Shinseiki Evangelion - Mahjong Hokan Keikaku (Japan).gbc

These three games are all licensed mahjong games developed by Studio Saizensen and published by King Records. All of them feature voice samples during gameplay. They also play samples on title screens so they can be quickly tested. Unfortunately I have no actual Game Boy hardware to test with, so my only point of reference is emulation.
I've attached two recordings from the Evangelion mahjong title screen. The first is from Sameboy v0.15.8. The second is captured from Analog IO board's optical port connected to an external DAC and normalized to have the same volume level as the first recording.

Evangelion Sameboy.zip
Evangelion MiSTer (-12.6 db).wav.zip

@paulb-nl
Copy link
Collaborator

paulb-nl commented May 3, 2023

These games seem to somehow be using the noise channel for the voices.

Kidou Senkan Nadesico sets
$FF20=$FF
$FF21=$F8
$FF22=$C7
$FF23=$BF

The game then alternates writing $88 and $00 to $FF25 to enable/disable the mixing of the noise channel.

@maij
Copy link
Contributor

maij commented May 10, 2023

A few more observations:

  • The artefacts are purely in the noise channel as expected from @paulb-nl's post (if I disable the other audio channels during the "voice sample" the noise persists, and if I disable the noise channel alone there is no audio, i.e. muted)
  • Timer interrupts are used throughout the menu music, but they are disabled (IME disabled) during the "voice sample", which means that this shouldn't be related to Timer Obscure Behaviour Missing #101.
  • Modifying the DAC emulation properties in Sameboy doesn't introduce artefacts on the noise channel. So it's probably not the analogue emulation component (as well as the fact that this issue appears to have been prevalent through all the recent audio changes)
  • NR50 is set to 0x77, so there is no weird VIN mixing happening (AFAIK there is no commercial game that used it)
  • It shouldn't be zombie mode related since the $ff21 (NR42) is not written to during the sample.

The sound panning is done after all the logic on the 'analogue' side, so it may need to be addressed there, however it could still be a sync issue between the APU logic and the CPU writes, but not sure.

Edit:
I am leaning towards this being a register write synchronisation issue between the APU and CPU.

@maij
Copy link
Contributor

maij commented May 20, 2023

I've found the problem and it's actually just a bug in the noise channel implementation. This issue only crops up when you want extremely low frequency clocking of the LFSR, which most games don't appear to use. The bug is in the period counter not being wide enough for these low frequencies.

Here's a build that fixes the problem in at least Dejiko No Mahjong Party
Gameboy_noi_period_20230520.zip


EDIT: Uploaded the right build this time!

@Thelypody
Copy link
Author

I tried the attached build, but unfortunately it did not fix the issue for me. Voice samples in these games now sound very quiet compared to music, making them almost inaudible. At least the blaring random noise is not as present.

@maij
Copy link
Contributor

maij commented May 21, 2023

Sorry about that, I uploaded the wrong file! Please give the updated link a try.

@Thelypody
Copy link
Author

The new build works great! Played a few hands in Dejiko and Evangelion mahjong games, all voice samples are clear without background noise. Thank you very much!

maij added a commit to maij/Gameboy_MiSTer that referenced this issue May 23, 2023
Tidy up noise channel implementation
theypsilon pushed a commit to MiSTer-unstable-nightlies/Gameboy_MiSTer that referenced this issue May 23, 2023
Tidy up noise channel implementation
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

3 participants