Repository navigation
fix(audio): skip a BGM transition effect when the track keeps playing - #382
Merged
Merged
Conversation
A line whose BGM action names a transition audio effect stopped the story with `Audio effect resource "..." has type "transition", but the BGM action only updates a retained sound` when the same track was already playing. That happens on the next line of the same section, and after a section transition or a reset story at section into a line that plays the same track. Whether a line keeps the track depends on how the player reached it, so the same line can start the music on one path and keep it on another, and an author cannot rule the error out. A transition now plays only on sounds that start, stop, or change source. A sound that keeps playing from the same source plays no transition and takes the line's mix at once, including the final `next` values that the transition writes into the persistent mix, so the line ends with the same mix on every path. Selections that are invalid on every path, such as an unknown resource, an unsupported effect type, or a bad playback speed, still throw. Update the audio channel docs and the audio effect resource schema description, and add resolver, engine and VT coverage.
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.
Why
A story stopped with this error when a line's BGM action named a transition audio effect and the same track was already playing:
[story.scenes["…"].sections["…"].lines["…"].actions.bgm.audioEffects] [resources.audioEffects.<id>] Audio effect resource "<id>" has type "transition", but the BGM action only updates a retained sound. Use an update resource.This happens on the next line of the same section. It also happens after a section transition or a reset story at section into a line that plays the same track.
resolveAudioEffectthrew whenever a transition met a sound that kept its source but changed its mix. The mix almost always changes there, because the transition's finalnextvalues are written into the line's persistent BGM mix. Whether a line keeps a sound depends on how the player reached it, so the same line can start the music on one path and keep it on another. An author or an editor cannot know this in general, so the data could not be changed to avoid the error.What changed
resolveAudioEffect, a transition on a sound that keeps its source returns no effect instead of throwing. The sound keeps playing and takes the line's mix at once, as it does for a BGM action withoutaudioEffects.nextvalues still set the line's BGM mix on every path, so the line ends with the same mix whether it started the music or kept it.resolveAudioEffectsstill resolves one kept sound, paired by id. An unknown resource, an unsupported effect type, or a bad playback speed still throws on that path. The old search for a changed kept sound only chose which sound to reject, so it is removed, together with the two helpers it used.docs/RouteEngine.mdand the description inaudioEffectResource.yamlnow state the rule.beginEffectandendEffectalready require an update resource on every path and are unchanged. Voice and SFX actions have no top-level audio effects.Testing
spec/resolveAudioEffects.test.js:nullfromresolveAudioEffectand[]fromresolveAudioEffects.[].spec/RouteEngine.audioEffects.test.js, newdescribeblock:audioEffects, the samebgm:mainsound and source, and the volume at the transition's final value.sectionTransitionand afterresetStoryAtSectioninto a line that keeps the music.vt/specs/audioChannels/audio-effects-transition-kept-music.yaml(assertions only, no screenshots): the next line, and then a section transition, keep the music with a transition. It checks the source, the new volume and that no audio effect is emitted. Run in the pinned VT container, it passes with this change and fails onmainwithexpected 100, got 70, because the line is never entered.bun run test(101 files, 2468 tests) andbun run lintpass.Not tested: listening to the result through Route Graphics on an audio device, and a client app using this engine version. All
audioChannelsVT specs were run in the VT container. All pass exceptaudio-effects-initial-entry.yaml, which fails the same way onmain(expected 70, got 100). This change does not touch it.Risks
nextvolume differs from the track's current volume, the volume jumps to it. On a path that starts the music, the transition fades to the same value.