fix: spatial panning gain match to mono + click prevention - #66
Merged
Conversation
🔗 Merge Alignment ReminderIf this PR targets Both repos should be merged in coordination to avoid breaking changes. Do not merge one without the other being ready. |
popuz
marked this pull request as ready for review
May 5, 2026 11:42
24 tasks
NickKhalow
approved these changes
May 8, 2026
| Subtle, // α=1.2, ≈ −8 dB at 90° — average across voice band | ||
| Moderate, // α=1.5, ≈ −10 dB at 90° — slightly emphasized | ||
| Strong, // α=2.0, ≈ −13 dB at 90° — high-freq end of natural ILD | ||
| } |
There was a problem hiding this comment.
Let's create a method AsAlpha() to keep the locality
popuz
added a commit
to decentraland/unity-explorer
that referenced
this pull request
May 8, 2026
…lls (#8610) ## Summary Spatial audio panning fixes for voice chat: - **Loudness:** Spatial mode no longer attenuates the signal at center position. Both channels reach unity gain when the speaker is in front, matching Mono / Community Voice Chat loudness (was −3 dB due to equal-power 0.707 floor). - **Clicks:** Click artifacts on rapid camera rotation eliminated via a short gain ramp (~5 ms) at the start of each audio buffer. Ramp is skipped automatically when gain change is below audible threshold (saves CPU when source is stationary). - **Smooth FP↔TP audio:** Removed the FirstPerson-only optimization in `NearbyAudioPositionSystem`. Reprojection is now mode-independent (always uses the player head as anchor), so the source position stays continuous through the Cinemachine FirstPerson↔ThirdPerson camera blend instead of jumping at the moment of mode switch. Main logic change is in LiveKit PR: decentraland/client-sdk-unity#66 ## What changed (technical) - Replaced equal-power `cos/sin` panning law with exponential ILD curve: `gainFar = exp(-α·|pan|)`, `gainNear = 1.0` - Default `α = 2.0` (`Strong` profile) → far ear at 90° ≈ −13 dB - Added click-free linear ramp at buffer start; auto-bypass via `Δgain` threshold - Inspector knobs added (build-irrelevant): `IldProfile` enum, `panningRampMs`, `gainDeltaThreshold` - `NearbyAudioPositionSystem` no longer branches on `isFirstPerson`. Source position is always computed as `listener.position + (remoteHead − playerHead)` with `playerHead = PlayerComponent.CameraFocus.position`. In FirstPerson the camera and the head are nearly collocated, so the formula degenerates to the previous FP behavior; during the FP↔TP blend, both `listener.position` (camera) and the listener-local frame change smoothly, eliminating the audible jump that the previous mode-gated branch produced.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Spatial audio panning fixes for voice chat:
Companion PR: decentraland/unity-explorer#8610
What changed (technical)