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

Sound through walls. Audio source settings freezes after moving to another room. #193

Open
Larzone24 opened this issue Nov 28, 2023 · 6 comments

Comments

@Larzone24
Copy link

Larzone24 commented Nov 28, 2023

For some reason audio is still heard through walls. However, the main issue seams to be that the audio stops updating or something when I move to another room. It doesn't matter if I change settings in the Acoustics Adjust script, the sounds plays the same way from the first room.

For example, if I go to the other room with the audio source placed to my left ear, it will continoue playing on the left ear even if I turn around. Its now stuck in this position. See video below.

The audio fixes itself when walking back to the first room. This is the same in multiple locations in my house.

Edit: Ignore the Wetness (db) setting. It is usally set to default and I just tried changing it to see if it affected the audio when in the other room and then forgot to change it back. The issue was the same even when it was default.

https://youtu.be/foaywb2oof8

@Larzone24
Copy link
Author

Also, the yellow debug line from player to source dissaperas when this happens, even though the audio keeps playing.

@NoelCross
Copy link
Contributor

@Larzone24 This is an interesting case that you present.

The first clue about what's going on here is the values coming from the acoustic queries. The value of -3,402823E+38 indicates that the query failed for the source location. This is due to the sound source being unreachable and during the acoustic simulation, the simulator will not produce values for those unreachable locations.

The Unity plugin which does the acoustic queries needs to decide how to treat the error code coming back from the acoustics system. Many times when a sound source is unreachable, it is close a wall that was voxelized (i.e. expanded) and the policy is to retain the last query value and apply that cached value for sources that are now failing. This policy is not a great policy for the circumstances that you desire in your scenario.

Unfortunately, the only workaround that I can recommend for this particular scenario where the rooms aren't connected by a portal/doorway is to detect that the player is in a new room and disable the sound sources from the room that is unreachable acoustically. This should provide the desired effect, although it requires some manual work on your part.

The Unreal plugin has a bit more flexibility given that the source code is accessible so the policy for caching the last value can be replaced with a heuristic that matches your scenario better. Also, the Unreal plugin supports dynamic openings like doors, whereas the Unity plugin does not have that support.

I hope that helps explain what's going on a little better. Thanks for providing the question.

Best regards,
Noel

@Larzone24
Copy link
Author

Okay, if I understand you correctly it seams that my design won't work out of the box, i.e. that having closed rooms won't work. However, the strang thing is that PA behaves correctly (as I would expect) for me on the front door. On the front door the audio just cuts of when going outside (see new video below).

https://youtu.be/8cfhOGG88qY

I was aware that PA didn't support opening of doors in Unity, but my plan was to maybe lower the occlution multiplier so a little sound goes through walls and doors all the time (if this is how it would work).

Note, right now I don't use NavMesh since this would lead to PA baking my whole scene which would take days, so i instead have Acoustics Navigation scripts on all floor game objects so PA only need to bake the house. This wouldn't cause any problems, right?

If my current design won't work I guess I have the following options:

  1. Remove all the doors, at least for the baking. I can then choose to either have no doors or have doors but that doesn't affect sounds in any way (might be weird?). However, would still need front doors to the house so unclear how this would work. Right now the front door is working but don't know if this is a bug or feature/luck?
  2. Disable audio sources from unreachable rooms. Unclear how I would program this in a way that holds up and don't cause issues in many edge cases. If -3,402823E+38 means that the query failed for the source location, maybe I could check this value and disable the audio source if the audio source have this value? Or would this cause other issues? The main downside would be that sound just cut off when somebody goes into the other room. I'm making a multiplayer/coop game.

@NoelCross
Copy link
Contributor

@Larzone24 the reason why the front door case is working as shown in the video is because there must be, however minimal, a pathway from the listener to the source in that case. If you send us the ACE file, we could inspect it to see where the gap is. Regardless, this "reachability" behavior might be something that you could take advantage of by having at least a bit of the enclosed room having access to the main corridor. This won't be 100% accurate as the portal you create will likely lead to some bleedthrough in a direction that you don't want. If this piercing is done in a spot that results in a long reachability path, then the sound will be attenuated by quite a bit and probably won't be a problem, but you'd have to play with it.

As far as treatment for doors are concerned, yes, we typically recommend baking with the doors open and then doing some real-time hit testing to determine if the door is opened or closed. Since the PA Unity plugin binary handles all of the underlying queries to the acoustics runtime, you don't have the ability to intercept the calls for rendering. The only control that you'd have is either disabling sources dynamically or adjusting the occlusion multiplier for those sources based on the door states and proximity tests. It does require some housekeeping regarding the location and state of each collection of sources which is not ideal.

Handling dynamic doors is a challenging problem with a baked acoustics solution and it is one that we've been working on for some time now with research still ongoing for an optimal solution.

@Larzone24
Copy link
Author

I found that there was a pathway through the second floor. However, in another closed room with front door it somettimes works, and sometimes fails depending on if the audio source if moved up or down inside the room. Closer to the floor, it works. Can't send the ace file hear since it is 35 mb and 26 compressed fully with 7-zip. Github limit is 25 mb in coments (so close 😂).

  1. I guess I can try to make small invisable pathways through the doors. Does the bake include disabled game object? Thought I could create a disabled child object to the door and add the Geometry script to that instead, and make that mesh have gaps at the top and bottom of door (or something similar).

Also, in the process of testing if PA can be used in my game so have some more questions. Hope that's fine.

  1. In my horror game you need to be able to hide under beds and in closets (would need to make hiden pathways here as well). When testing right now, the bed over the player does not occlude the audio source placed over the bed. Makes no different it seams that the bed is over the player. I should of course hear the sound, which i do, but feels like it should come more from the sides or me a bit more muted. Would this require me to have more probe placements, e.g. one probe under the bed? Not sure if I understand exacly what the probes do.

  2. Maybe goes hand in hand with question 2 but I'm afraid that the voxels will be too big and will interfer when hiding in smaller areas, e.g. voxels from the floor and bed would make the area under the bed without geomerty too small so the audio listener will go inside the geomerty voxels. Right now i'm using Couarse but are baking Fine to test, but not done yet. Can the voxel side be tweaked and how would that effect the bake time?

  3. Does PA have vertical positioning (unsure of the correct terms). But can I notice if a sound comes from above or below. Have tested a bit and to me it's not obvious if the audio source is above or below me.

  4. Lastly, how should I manage forest area. Does PA have much affect on audio inside an forest, enough to be worth baking it? If I where to bake my whole terrain it would take forever. Right now, if I want to bake my 4 floor house on fine, it will take 8 days and 5 hours accourding to Estimated Compute Cost (1240 probe counts). Or is there a better/simpler way of handling forests? I would guess that occlusion from tress isn't that important and that there isn't much reverb. But I'm no sound expert. :)

@Larzone24
Copy link
Author

@NoelCross Just a kind reminder that i'm still waiting on some answers on the questions above. :)

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

No branches or pull requests

2 participants