Repository navigation
fix(audio): start voices and buses at their requested volume - #859
Merged
Merged
Conversation
Bundle ReportChanges will decrease total bundle size by 21.01MB (-37.05%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: site-server-esmAssets Changed:
App Routes Affected:
view changes for bundle: exo-iife-Exo-iifeAssets Changed:
Files in
view changes for bundle: exo-esm-esmAssets Changed:
Files in
view changes for bundle: exo-iife-min-Exo-iifeAssets Changed:
Files in
view changes for bundle: exo-full-iife-min-Exo-iifeAssets Changed:
Files in
view changes for bundle: exo-esm-modules-esmAssets Changed:
Files in
Files in
view changes for bundle: exo-full-iife-Exo-iifeAssets Changed:
Files in
|
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.
A new voice set its output gain with
setTargetAtTime(volume, now, 0.01), and so did a bus when its nodes were set up. A freshGainNodestarts at unity, so the gain only approached the requested volume over the first ~30 ms. For a one-shot, that window is exactly its loudest part, the attack:audio.play(sfx, { volume: 0.25 })peaked as high asvolume: 1.volume: 0, such as a crossfade target or an engine rumble, produced a full-level blip.The initial value is now set with
setValueAtTime. This cannot click:GainNode(Sound,AudioStream,AudioGenerator,AudioSystem.open), and nothing is pooled. The source has not started when the constructor runs.Later volume changes, fades and mutes are untouched and still ramp.
Measured in real Web Audio
Measured in Chromium 153 with a test-local AudioWorklet tap that records every render quantum reaching
destination. The same scenario ran against the engine built before and after this change. The source is a mono 40 ms 1 kHz one-shot at 0.8 with an instant attack. The centred stereo panner puts every value 3 dB below the nominal level.volume: 1volume: 0.25volume: 0.05volume: 0volume: 0.25voice.volume0.5 → 0.1fade(0, 0.5)In the playground, the trigger spam in
sound-poolwent from a −1.8 to a −7.0 dBFS sample peak, anddialog-systemfrom −3.7 to −14.9 dBFS. Neither example was changed.Tests
base-voice.test.ts: a voice played at 0, 0.05, 0.25 or 1 starts there without a ramp, and a later volume change still ramps.audio-bus.test.ts: a new bus starts at its volume, and a bus created muted starts silent.audio-generator.test.tscases now assert the initial volume throughsetValueAtTimeinstead of the old ramp.GainNodes inaudio-bus.test.tsgained thesetValueAtTimemethod that every real node has.#860 is stacked on this branch: its audio levels were measured with this change in place.