预览音频跟随音量包络 + 淡入淡出#174
Merged
Merged
Conversation
…yback Preview audio ignored volume automation and fades — it set a static, clamped clip.volume once per tick. Upstream drives live preview through an AVAudioMix whose volume ramps sample Clip.volumeAt (static × dB-keyframe gain × fade) per clip (CompositionBuilder.emitVolumeEnvelope → AVPlayerItem.audioMix). Port that at the browser's limit: sample volumeAt(clip, frame) every rAF tick. - timelinePlayback.ts: clipVolumeAt(track, clip, frame) — muted → 0, else the true (unclamped) volumeAt envelope; non-finite → 1. 6 tests (mute, static passthrough, dB keyframe via linearFromDb, fade-in ramp, >1 boost preserved, NaN guard). - previewEngine.ts: syncFollowers samples clipVolumeAt at the loop's frame; the linked-audio-dedup mute is unchanged; el.volume = Math.min(1, gain) clamps at the assignment (HTMLMediaElement.volume throws above 1). Scrub/seek paths (which only touch currentTime) are untouched. Deferred: >0 dB boost (gain > 1) needs a Web Audio GainNode — el.volume is browser-capped at 1. That path needs Tauri-asset CORS handling (a tainted MediaElementSource would silence all preview audio) + real-machine audio verification, so it is marked TODO(>0dB) and the true gain is kept available. Verified: pnpm build (tsc) clean; pnpm test 215 passed (+6).
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.
概要
预览播放时音频现在跟随音量关键帧自动化 + 淡入淡出。此前是每 tick 设静态 clamp[0,1] 的
clip.volume,忽略自动化与淡变。变更
timelinePlayback.ts:新增clipVolumeAt(track, clip, frame)——muted→0,否则真实volumeAt包络(static × dB 关键帧 × fade),非有限→1,不封顶。previewEngine.ts:syncFollowers(每 rAF tick)按当前帧采样,el.volume = Math.min(1, gain)在赋值处 clamp(HTMLMediaElement.volume>1 抛 RangeError);linked-audio 去重静音 + scrub/seek 路径未动。上游对齐
上游经
CompositionBuilder.emitVolumeEnvelope采样Clip.volumeAt建AVAudioMix挂到AVPlayerItem驱动真预览——本 PR 在浏览器 [0,1] 限内 1:1 复刻该行为。延后(非本 PR)
>0dB 增益(gain >1)需 Web Audio GainNode(
el.volume被浏览器限 1)。该路径需处理 tauri asset 协议的 CORS(污染的MediaElementSource会静音全部预览音频)+ 真机音频验证(无法 headless 验),故留TODO(>0dB),真实 gain 已在 pure 函数里备用。测试
clipVolumeAt6 单测(muted→0 / 静态透传 / dB 关键帧 linearFromDb / fade-in 斜坡 0→0.5→1 / >1 boost 预 clamp 保留 / NaN 守卫)。pnpm build(tsc)绿;pnpm test215 通过(+6)。