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

Media audio can be very loud on room entry and scene changes #5550

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

rawnsley
Copy link
Contributor

When you enter a room with audio or video media there can be a short period of very load audio output. The principle reason for this is that when the HTML Audio and Video elements are created there can be a delay before the various audio systems adopt them and start controlling their volumes. This has been addressed by setting the volume to zero by default and then reseting it to one once control has been passed over.

A secondary issue is that the default audio gain for the THREE sources is one and volume is interpolated to it's proper value over time using setTargetAtTime. If the gain is set to zero by default then the audio will fade up rather than down, which is less jarring.

The last issue is that before the room is entered, the player is positioned at the scene preview camera position and the audio will be set accordingly. This PR does not address this issue because it is not clear what the desired behaviour is.

Here is a test room that demonstrates all of these elements: https://dev.reticulum.io/2D9w2Y4. Without the PR applied you will hear a loud blast on first load, followed by the volume decreasing because the preview position in near the audio source, then on scene entry the volume will drop to being low. With the PR you will not have the initial blast of sound and instead jump straight to the volume of the preview sound.

Note that you might need to click the page a bit during load to tell the browser you are happy to hear audio at all. While this would appear to make the PR less relevant, remember that this approval is already given in the case of scene changes or fast room switching, where the sound blast can be significant.

I'm happy to take advice on whether I'm using the right properties in the right places, but I hope the underlying principles are sound.

@rawnsley
Copy link
Contributor Author

Fixes #2599 and #2814,

@keianhzo keianhzo self-requested a review July 18, 2022 13:50
Copy link
Contributor

@keianhzo keianhzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, it looks good to me. This is a small simple patch and I can see the benefit of it.

Related to this and the last issue that you pointed out is the preview + audio zones case where we are currently not applying the audio zones if the avatar is not yet spawned. We should probably apply it to the preview point so the behavior is more consistent. I opened an issue a while ago for this: #4739

@keianhzo keianhzo merged commit 84a1901 into Hubs-Foundation:master Jul 26, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants