henkelmax / sound-physics-remastered

A Minecraft mod that provides realistic sound attenuation, reverberation, and absorption through blocks.
GNU General Public License v3.0
76 stars 24 forks source link

Jukebox sound with "Update moving sounds" gets stuck in doorway even when it is no longer behind a wall #248

Closed neonmoe closed 1 month ago

neonmoe commented 1 month ago

Bug description

If the "Update moving sounds" option is turned on, and a jukebox sound is coming from another room, returning to the room with the jukebox does not reset the position of the sound back to the jukebox.

I searched for duplicates, but I'm pretty sure this isn't one. I don't think this is a dupe of #95 since that seemed to be more of a misunderstanding about the way to sound is actually supposed to move to the doorway when going between rooms.

Love the mod by the way! Thanks for maintaining it :pray:

EDIT: For anyone searching for this issue, if this hasn't been fixed in the future, the workaround is to turn off "Redirect non occluded sounds" (which actually does the opposite, see my later comments for the explanation).

Minecraft version

1.21.1

Mod version

1.21.1-1.4.6

Mod loader and version

Fabric Loader 0.15.11

Steps to reproduce

  1. Enable the "Update moving sounds" option.
  2. Build two rooms connected by a doorway.
  3. Put a jukebox in one, put in a record.
  4. Move to the room without a jukebox.
  5. Observe the sound coming in from the doorway.
  6. Move back to the room with the jukebox.
  7. Observe the sound still coming from the doorway (or the wall across the doorway), not the jukebox.

Expected behavior

I would expect the jukebox playback to sound like it's coming from the jukebox, if I'm in the same room.

Log files

https://gist.github.com/neonmoe/00bfaad5a1a296a635ee5be2d24260d3

Videos

2024-09-07_17-21-50-attempt3.webm

The logs are from the session on the video (though the video is quite a short part of it, due to file size issues, but I think it still demonstrates the issue well). I keep turning my head to demonstrate where the sound is coming from, I hope it gets across.

henkelmax commented 1 month ago

This is an intended feature. It's called sound direction evaluation. It simulates the sound being reflected at a wall. You can disable it by setting sound_direction_evaluation to false.

neonmoe commented 1 month ago

Yes, I know why the sound moves. The problem is that when you return to the original room, you're in direct line of sight of the jukebox, and should be hearing it from the jukebox, not the wall.

neonmoe commented 1 month ago

Here's a diagram, I hope it clarifies what I mean. The lines show the path the sound appears to take.

image

The problematic scenario only happens if the player visits the bottom room first.

neonmoe commented 1 month ago

I decided to go ahead and fix this myself, so I discovered the bug: if you have sound_direction_evaluation = true and redirect_non_occluded_sounds = true (which actually means, skip redirecting non occluded sounds, apparently), the mod ends up moving the jukebox sound position when you go to the other room (since the sound gets occluded), but when you return, it doesn't move the jukebox sound position back (since the sound isn't occluded anymore, and redirect_non_occluded_sounds = true says that it shouldn't be moved, because it isn't occluded).

I'm guessing redirect_non_occluded_sounds = true is the default because of performance reasons, or that you'd rather just not mess with the audio position if it's not needed. However, with update_moving_sounds = true, this definitely needs an exception, since you'd definitely want to redirect when the update causes the sound to become non-occluded.

If you have an idea for how this should be fixed in general, and don't have the time, I'll gladly make a PR.