TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.15k stars 381 forks source link

GBA audio briefly glitches out after loading a savestate in certain scenarios #2749

Closed InfoManiac742 closed 1 month ago

InfoManiac742 commented 3 years ago

Summary

Occasionally, loading savestates can glitch out the audio, causing high-pitched beeps and similar sounds. This appears to happen across many different GBA games, but it's very finicky to reproduce. The core is mGBA (the only GBA core for BizHawk).

Repro

As mentioned before, this is a very finicky bug to reproduce, but I found a way to reproduce it semi-consistently in Pokémon Emerald (SHA1:F3AE088181BF583E55DAF962A92BB46F4F1D07B7, although I don't think the version matters). Note that this has happened to me before in a lot of other scenarios and in other games - Pokémon Emerald is just the game I happen to be playing right now.

  1. Begin surfing such that the surfing music plays
  2. Save a state (I've provided a state that should work)
  3. Press the Start button to pause the game
  4. Unpause the game with the Start or B button
  5. Very shortly after unpausing the game (4 frames seems to always work for me, you can use frame advance), load the state made in Part 2.
  6. You should hear a high pitched beep for a bit.

Host env.

gba_audio_glitch.zip

Meerkov commented 2 years ago

More general bug:

Reproduces in 2.8. Tested on Castlevania Harmony of Dissonance

1) Play a game 2) Save a state 3) Open the Hex Editor 4) Start changing values around until you crash your game. 5) Load the savestate

You'll find that sometimes, the music remains corrupted (half the instruments missing, sounds distorted, etc). Loading a second time often clears the issue.

kalimag commented 1 year ago

You'll find that sometimes, the music remains corrupted (half the instruments missing, sounds distorted, etc). Loading a second time often clears the issue.

I'm aware of an mGBA core audio bug on that seems to mute certain channels when loading a state immediately after restarting the core, but I can't reproduce it on 2.9 anymore. I can consistently reproduce it on 2.6.2-2.8 by loading Mega Man Battle Network (USA) SHA1:A4FBAE389654A6611D0597B1E9109CBBD32A132F, making a state during the Capcom logo, turning on "Autload last Slot" and rebooting the core.

The previous comment doesn't mention any specific timing for when to load the states, so I don't know for sure if loading the state right after the core reboots just makes it more likely to happen, or if this is a different issue.

InfoManiac742 commented 1 year ago

I can try testing the newest version once I get around to it, but I find that Castlevania: Harmony of Dissonance is the game where this is the most noticeable, since the music ~is terrible~ primarily uses the Game Boy sound channels.

Edit: AppVeyor is giving me an error, and I'm too lazy to build BizHawk from source.

YoshiRulz commented 1 year ago

dev build for 0b7960ff0

InfoManiac742 commented 1 year ago

It seems to work perfectly on HoD at least, which is a good sign that this is probably fixed on 2.9.

InfoManiac742 commented 1 year ago

And never mind I spoke too soon: it looks like there's still some weirdness going on, even though the channels aren't muted.

Here are two examples of audio from Harmony of Dissonance: one is normal, the other is immediately after loading a savestate. https://user-images.githubusercontent.com/26778801/214214523-d4a91a56-9ca7-4210-a830-ed94e5cea761.mp4 https://user-images.githubusercontent.com/26778801/214214553-48bda8c6-2a9c-4bdc-a8b2-ec9da2a8cbf2.mp4

YoshiRulz commented 1 year ago

Is this still present in 2.9 RC3?

InfoManiac742 commented 1 year ago

I couldn't find the RC3 tag on Gitlab (I'm not very familiar with all of this), but the audio still glitches out for a short time on 10423abdf (mGBA: https://github.com/TASEmulators/mgba/tree/26ea5311797656a87ebfcabd55fe295a15e55535), which is the latest build I could find on GitLab.

Just as a clarification, there are/were two similar but slightly different problems with GBA audio and savestates:

  1. When loading a savestate immediately after resetting the core (it also happened to me randomly on other occassions, but resetting the core reproduces it all the time), a bunch of the audio channels either become extremely quiet or mute completely. The muted channels do not unmute; the problem is persistent. This problem was fixed, and is not present in the most recent master.
  2. When loading a savestate, some channels will not have the same pitch as when the savestate was saved, but instead the same pitch as just before the savestate was loaded. This is temporary, and the problem will go away as soon as the channel is updated normally by the game, lasting a few seconds at most. This problem was not fixed, and is still present in the most recent master.

Additionally, from my testing, it seems like the only channels that are affected by this are the four original Game Boy channels (Square, Wave, and Noise) and not the two new Direct Sound channels.

YoshiRulz commented 1 month ago

@InfoManiac742 Can you confirm the second bug is still present in a recent dev build?

InfoManiac742 commented 1 month ago

Issue appears to be fixed in latest dev as well as the 2.9 and 2.9.1 release versions.