GTcreyon / SM63Redux

Code base for Super Mario 63 Redux
https://sm63redux.com
Mozilla Public License 2.0
199 stars 28 forks source link

Reverb glitches out when entering water with SFX muted #168

Closed Koopa1018 closed 1 year ago

Koopa1018 commented 1 year ago

Describe the bug In certain cases, entering water when sound effects are muted will make a strange "garbage noise." It sounds like it may be the reverb tail of the "start game" sound. The repro steps require the game start sound to have played while the SFX bus was unmuted, hence the oddly specific repro steps. At least in Godot editor, once it's been done once, repeating the steps will not reproduce the bug again until the game is closed and restarted.

If music is enabled, similar garbage reverb sometimes plays very faintly whenever water is entered. (I suspect it's reverb from previous drum hits in the music?)

To Reproduce

  1. Open a fresh game window at the title screen, not inside a level.
  2. DO NOT mute the SFX bus using the main menu's settings page. (Muting music is fine.)
  3. Begin game.
  4. Mute the SFX bus using the pause menu's options page.
  5. Enter water.

Expected behavior No garbage reverb tails play ever, especially not when SFX are muted.

Screenshots Audio recording of the glitch

System Information

Additional context After thinking about it for a bit, I think I know the root cause.

The reverb bus probably begins the game activated. When the game begins, the player object begins activating and deactivating the bus depending on whether it's in water. Since the player always starts on land, the bus gets deactivated while it's still filled with reverb from the game-start sound, and since it's no longer updating, it never has a chance to "drain."

Consequently, when the player hits the water and the bus reactivates, the stored reverb immediately spills out, bypassing the SFX muting because it comes after the muted buses in the signal chain.

So why does it only happen once per window opening? Because when quitting to title, the reverb bus gets forcibly muted, Consequently, the start-game sound never gets a second chance to fill up the reverb buffer. The reverb bus is instead left filled with audio from the previous session--I've been able to confirm this by unmuting underwater, quitting to title and restarting, then re-muting both music and sound. It's just that audio from the previous session tends to be quiet enough that you can't hear it.

So why doesn't it happen when the SFX are unmuted? Yeah...about that. (Listen closely!)

AidenBeresford commented 1 year ago

After messing around for a bit I figured out that if you remove and then add back the "~Water Verb:" reverb effect on player _ready(): it clears(?) the garbage noise or something. I'm not really sure what the hell I'm talking about because this is my first time playing around with AudioServer and audio busses, but what I do know is that it works great. I'll open a branch in a second and upload my code for review.

Koopa1018 commented 1 year ago

Nice, thought that might work.

AidenBeresford commented 1 year ago

For future use, I've added a reset_bus_effect function to the Singleton. I'm not sure if it will ever be used again, but it's there just in case.