-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Ramp audio parameter values to avoid audible discontinuities #16364
Ramp audio parameter values to avoid audible discontinuities #16364
Conversation
Audio parameter changes are currently performed at the graphics frame rate, which is too slow to avoid audible discontinuities in the audio output stream. This results in audio artifacts like "crackles", "zippers" and "pops", which lower the quality of the audio output and damage audio hardware over time. To avoid these issues, this change uses linear ramps when changing audio parameter values so they are performed at the audio sample rate, typically 48000 times per second or higher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a mechanism to apply smooth, sample-rate–based ramps to audio parameter transitions in order to eliminate audible artifacts such as crackles and pops. Key changes include adding a new parameter (parameterRampDuration) to the audio engine options, updating the audio node setter methods to use a linear ramp function, and consistently applying these changes across multiple audio subnodes.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
packages/dev/core/src/AudioV2/abstractAudio/audioEngineV2.ts | Adds parameterRampDuration to engine options and state |
packages/dev/core/src/AudioV2/webAudio/subNodes/volumeWebAudioSubNode.ts | Updates volume setter to use ramping via engine._setAudioParam |
packages/dev/core/src/AudioV2/webAudio/subNodes/stereoWebAudioSubNode.ts | Updates pan setter to use ramping via engine._setAudioParam |
packages/dev/core/src/AudioV2/webAudio/webAudioMainOut.ts | Updates main output volume setter to use ramping via engine._setAudioParam |
packages/dev/core/src/AudioV2/webAudio/subNodes/spatialWebAudioSubNode.ts | Replaces direct assignment with _setAudioParam calls for position and orientation |
packages/dev/core/src/AudioV2/webAudio/webAudioEngine.ts | Adjusts constructor to pass options and adds the _setAudioParam method |
packages/dev/core/src/AudioV2/webAudio/webAudioStaticSound.ts | Updates detune and playbackRate setters to use _setAudioParam |
packages/dev/core/src/AudioV2/webAudio/subProperties/spatialWebAudioListener.ts | Updates listener property setters to use ramping via engine._setAudioParam |
Comments suppressed due to low confidence (1)
packages/dev/core/src/AudioV2/abstractAudio/audioEngineV2.ts:63
- Consider validating that the provided parameterRampDuration is non-negative to avoid potential audio ramping issues. You might add a condition to either clamp negative values to 0 or throw an error.
if (typeof options.parameterRampDuration === "number") {
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/16364/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/16364/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/16364/merge#BCU1XR#0 |
Visualization tests for WebGPU |
WebGL2 visualization test reporter: |
Audio parameter changes are currently performed at the graphics frame rate, which is too slow to avoid audible discontinuities in the audio output stream. This results in audio artifacts like "crackles", "zippers" and "pops", which lower the quality of the audio output and damage audio hardware over time.
To avoid these issues, this change uses linear ramps when changing audio parameter values so they are performed at the audio sample rate, typically 48000 times per second or higher.