Repository navigation
fix(fx): synth-voice ADSR envelope — kill fit-to-region stretching - #23
Merged
Merged
Conversation
…ed during live hold
While the user holds an FX pad, tickFxHold keeps outS at
playhead+overshoot so the active-resolver's exclusive-end check
stays true. The envelope's holding branch then rescaled A and D
against this moving regionDurS, dynamically squeezing attack onto
the elapsed time — so localT/A returned ~1 within the first frame
regardless of slider. Vignette (and every other P-FX) appeared to
have no attack ramp at all on live recording.
Removed the rescaling inside `if (holding) { ... }`; the existing
phase logic at the bottom already handles attack/decay/sustain
correctly when A and D are left raw (release is short-circuited
out by the `if (holding) return S` guard). Non-holding fit-to-
region path is unchanged — that's the intended "release is the
protected slot" behavior pinned by the existing test suite.
Added a `holding` describe block in envelope.test.ts covering the
Vignette repro (A=2.0, regionDurS≈localT+overshoot), normal decay
during hold, sustain-after-A+D, no release while held, and no
zero-out at/past outS while held.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…attack amplitude Quick tap with a high attack value used to swell the effect to full peak and only then release. A real synth voice freezes attack mid- ramp on key-up and fades from whatever partial amplitude was reached. Old fit-to-region rescaling forced A+D into `regionDur - R`, so the attack always completed within the held window — wrong. Removed the fit-to-region scaling entirely (both holding-branch was already gone, now non-holding too). Release now samples the natural envelope at `regionDurS - R` and fades from that amplitude to 0 over R. Sub-R sliver (regionDurS < R, only reachable via manual trim with A>0) renders silent — the synth-correct answer. Tests: - Rewrote `compresses A+D to fit (region - R)` → now asserts synth- voice partial-attack release (50ms held + R=200ms, A=100ms peaks at 0.5, releases from there). - Rewrote `clamps R alone when even R exceeds the region` → now asserts silent for sub-R sliver with A>0. - Added boundary case: A=0 sub-R sliver still plays (sustain fades down across the available time). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Fixes two bugs in the P-FX ADSR envelope (
frontend/src/editor/fx/envelope.ts) where attack didn't behave like a real synth voice.1. Live-hold bug (commit a1aec2d): While the user held a pad,
tickFxHoldkeptoutS = playhead + overshootso the active-resolver's exclusive-end check stayed true. The envelope'sholding=truebranch then rescaledAandDagainst this movingregionDurS, dynamically squeezing attack onto the elapsed time →localT/Areturned ~1 within the first frame regardless of slider. Vignette (and every other P-FX) appeared to have no attack ramp on live recording.2. Quick-tap bug (commit cb2df2d): Non-holding fit-to-region rescaled
A+Dto fitregionDur - R, so a brief tap with high attack would complete the attack inside the held window and release from peak. A real synth freezes attack mid-ramp on key-up and fades from the partial amplitude.Changes
regionDurS - Rand fades from that amplitude — synth-voice semantics.A,D,Ralways reflect the user's slider exactly.regionDur < RwithA > 0, only reachable via manual trim) renders silent — synth analogue: tapped too briefly to make any sound.Affects all P-FX (Vign, Wear, RGB, Zoom, UV, Echo, Tape) since they share
envelopeAt.Test plan
npx vitest run --project=unit src/editor/fx/envelope.test.ts— 22/22 passing (rewrote 2 tests that pinned old fit-to-region behavior, added 4 new for synth-voice semantics + holding repro)npx vitest run --project=unit src/editor/— 553/553 passing, no regressions🤖 Generated with Claude Code