Repository navigation
feat(fx): uniform Punch-In modulation — envelope ⊗ LFO|sidechain, 2 macros/effect, Ableton-style sidechain scope - #61
Merged
Conversation
…rever A persistent (recording) FX hold whose pad pointer-up never arrived — window blur, tab switch, or the auto-stop at song end — stayed in `fxHolds` forever: its `outS` kept growing on the next play and clearAllFx couldn't remove it (clear-all preserves live recordings by design, which is correct). The pad deliberately skips setPointerCapture for multi-touch, so a lost pointer-up is realistic. - store.setPlaying(false) now finalizes every persistent hold via the normal release path → it becomes an ordinary committed capsule (erasable/clearable). - FxPad adds an off-pad release guard (window pointerup/pointercancel/blur) and an unmount cleanup, both ending only persistent holds — preview holds latch by design. - clearAllFx left unchanged (the inverted-filter diagnosis was wrong; its filter matches the X-hold-to-clear contract). Tests cover finalize-on-stop, post-finalize deletability, and that clear-all still preserves a genuinely live recording. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tested
New `fx/modulation.ts` — the single source of truth for P-FX intensity:
- intensity = envelope (always on) ⊗ one time-modulator (LFO XOR sidechain),
blended by `depth`; returns { level, phase }.
- Beat divisions derive from the REAL bpm (60/bpm·beats), not a hardcoded
120. `bipolarRateLabel` and `bipolarRatePeriodS` share one table, so the
displayed division can never disagree with what renders (kills the old
UI↔backend inversion). TE direction: near-centre = slowest, far = fastest.
- beat-synced LFO is grid-anchored in master-time → pulses land on the song
beats with a crisp onset, independent of where the punch started.
- LFO shapes (sine/triangle/saw/ramp/square) peak on the beat at phase 0.
- sidechain follower: threshold → normalize → asymmetric one-pole
(attack/release) → invert, as a reusable curve so renderer and the
preview band agree exactly.
Pure module, no store/DOM/time-source deps. 15 unit tests. Not yet wired
into the render path (next commits).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…y-safe) Wire `computeIntensity` into the live descriptor so P-FX intensity is the unified envelope ⊗ (lfo|sidechain). Legacy fx (only an `envelope`) are wrapped as a depth-0 modulation → identical render (all 38 existing build-descriptor tests pass unchanged). - PunchFx gains optional `modulation`; FrameFx gains optional `phase` (centralized cycle phase for effects with internal geometry). - buildFx now takes tMaster and reads bpm/beatPhaseS/beatsPerBar/audioEnv from the snapshot; sidechain follower curves are memoized per (audio-env, config). - defaultReadSnapshot threads real bpm + grid phase (selectors/timing) and the new store `audioEnv` field (+ setAudioEnv; null until Part D fills it from decoded PCM). New tests prove the live path: beat-synced LFO modulates on/off the beat at the real BPM, sidechain follows the master envelope (loud→stronger, culled below threshold), and legacy fx stay bit-identical. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…chain data, export Wires the engine into every effect and both render paths. Catalog: each effect now exposes exactly 2 opinionated linear macros (no bipolar). Removed bipolarPeriodS/lfoPhase/oneShotPhase/BEAT_STOPS_S — no effect runs its own LFO; intensity arrives centrally via applyWetness. Per effect: VIGN DEPTH/EDGE · RGB SPLIT/ANGLE · UV GLOW/TINT · WEAR AGE/ROLL (tracking-bar drift now from master-time) · ZOOM PUNCH/PUSH · ECHO SPREAD/FEED · TAPE STOP/WARP. 3-backend parity kept (shader uniforms fed from t / macros / wetness, no .wgsl/.frag source changes). Store: per-kind `fxModulations` (ModConfig = timeMod+depth+lfo+side) with setFxTimeMod/setFxModDepth/setFxLfo/setFxSidechain; beginFxHold freezes the full Modulation (envelope ⊗ modulator) into each new capsule. Persisted via PunchFxRecord.modulation so it round-trips. New `audioEnv` (master-loudness curve) computed at load from the already-decoded PCM (buildLoudnessEnvelope). Descriptor: the selected kind's live ModConfig drives the preview (recording-head); committed fx keep their baked modulation. legacyModulation + followerFor centralized in modulation.ts and shared by preview + export. Export parity: compositor runs the same computeIntensity; bpm/beatPhase + the sidechain audioEnv thread jobs.ts → worker → edit.ts → compositor (audioEnv only built when an fx actually uses sidechain). DEFAULT_MODULATION depth 0 → new fx are envelope-only until the user engages the modulator. Engine/store/descriptor/export tests green (179). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…hain scope Adds the modulation control surface to the FX hardware panel, reusing the existing TE chrome (LCD phosphor/scanlines, screws, brushed metal, JetBrains Mono, SegmentedControl). - ScreenModeColumn gains a third "M" button (P/E/M); ScreenMode is now params|env|mod. Lcd renders LcdModView in mod mode (LFO/SIDE readout: shape glyph + rate label, or THR%, plus DEPTH and SYNC/GATE state). - ModControls in the encoder slot: SegmentedControl LFO|SIDE → setFxTimeMod. LFO branch = shape cycler (∿△◺◹⊓) + RATE knob (shows bipolarRateLabel — note division on the synced half, Hz on the free half) + DEPTH + SYNC toggle. SIDE branch = ATK/REL/DEPTH knobs + INV toggle. - SidechainScope.tsx (new): phosphor-LCD widget drawing the master audioEnv as a filled loudness curve, a draggable dashed THRESHOLD line (window pointerup/blur drag guard → setFxSidechain), and the resulting effect-strength preview band via buildFollowerCurve tinted in the kind's capsuleColor, plus a playhead line. "NO AUDIO" placeholder when audioEnv is null. The panel grows only in mod+SIDE so the scope gets a strip under the controls; every other panel state stays pixel-identical. - New mini primitives (MiniKnob/MiniToggle/ShapeButton) for the modulator controls (the existing Encoder is bound to fxDefaults). Full suite green (1119 tests), tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…t before The master-loudness envelope was computed and stored before loadJob ran, but loadJob resets per-job state (including audioEnv) to null — so the value was immediately clobbered and the sidechain scope always read empty. Move the setAudioEnv call to after loadJob completes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…on-engine # Conflicts: # frontend/src/pages/Editor.tsx
The M-screen modulation controls were bespoke MiniKnobs that didn't match the FX macro knobs. Extract a shared presentational `EncoderKnob` from `Encoder` (etched scale, the #58 active-range arc, body/cap/indicator, drag + click-on-scale + double-click reset + off-window release guard; props value/min/max/kind/tint/label/onChange/onReset/size). `Encoder` is now a thin fxDefaults-bound wrapper (macro knobs unchanged); ModControls renders RATE/DEPTH (LFO) and ATK/REL/DEPTH (sidechain) via EncoderKnob at size 36. MiniKnob deleted. SYNC/INV reuse MiniToggle, SHAPE the ShapeButton — same hardware family. tsc clean, 1149 unit tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The scope drew the whole song squashed to ~270 buckets — individual hits were unreadable, so you couldn't tune a threshold to the kick. Replace it with an Ableton-style zoomed window: - ~8 beats wide, playhead-centred, scrolls with playback; sampled per-pixel so each kick/snare is a clear separate peak. - faint beat grid-lines (downbeats brighter) from bpm/beatPhase so you can see exactly where the beats fall and tune the threshold against them. - master loudness fill + the tinted effect-strength band (memoized follower curve, sampled in the window) responding live; threshold line + readout. Also: the SIDE-mode LCD now shows the actual knob values (THR / DEP / A ms / R ms) so ATK/REL/DEPTH aren't opaque. tsc clean, 696 editor tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…h timeline) The scope drew the loudness in raw master-audio time centred on the master playhead (currentTime), while the timeline's MASTER·AUDIO lane draws in arrangement/timeline time. In a long-form arrangement those are two different orderings of the same audio, so the peaks didn't line up. Now the scope is centred on timelineT and every window x is mapped arr→master (arrToMaster) before sampling the master-indexed loudness + follower curve; beat grid-lines use the arrangement beat anchor (arrBeatPhaseS). Same musical content as the timeline → peaks correspond. (It's still a zoomed ~8-beat detail view, so it shows fewer beats than the full timeline span; exact 1:1 would need the timeline's view range lifted to the store.) tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…, 120fps) The scope's peaks sat a beat-fraction off the timeline's audio peaks even on the same axis: the envelope was RMS with window-START placement, so it both read off the transient (energy lives in the note body) and led by up to a full window. The timeline draws a min/max PEAK waveform. Match it: build a PEAK (max-abs) envelope, window CENTRED on each timestamp, at 120 fps. The envelope's peaks now sit on the loudest samples — the kick transients — exactly where the timeline shows them, and the sidechain triggers on the transient (what you actually want to tune to). Arr→master mapping is unchanged (shared with the timeline audio lane), so multi-pill / long-form stays aligned. tsc clean; envelope + modulation tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…t, no wobble)
The scope had its own playhead-centred window in master time; the timeline
draws in arrangement time over a different, paged window — so even with the
same audio source the peaks landed off, and centring on the (per-frame)
playhead made the waveform shimmer ("wabern") while playing.
Now the scope reconstructs the timeline's EXACT visible window from the
shared ui.zoom + ui.scrollX + totalArrDuration(segments) (liveTimelineRange
is always [0, arrTotal]), maps every column arr→master before sampling the
amplitude envelope, and draws PEAK-bucketed columns (max per column) instead
of point samples. Result: peaks line up 1:1 with the timeline audio lane,
the playhead sits at its true position, and the waveform is stable as the
window pages. Long-form / multi-pill stays correct because the arr→master
mapping and the segment set are exactly the timeline's. tsc clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Root cause of the drift (peaks further off the deeper into the track): the amplitude envelope stored the REQUESTED fps (120) but hop is whole-sample rounded (22050/120 = 183.75 → 184), so the true rate is 22050/184 = 119.84. Sampling at index = t·120 read t·22080 instead of t·22050 — a 0.14% time scale error = ~0.4s off at 5 minutes. Store the true rate (sampleRate/hop). Hardening so it can't silently regress: - export `sampleEnv` from modulation (single sampler for follower/render/scope). - add `timelineVisibleWindow(arrTotal, zoom, scrollX)` to arrangement-time as the one source of the timeline's visible window; the scope uses it. - tests: envelope time-axis accuracy at 22.05/44.1/48 kHz at 300s (would have caught the drift); scope window == timeline window across zoom/scroll; arr→master == the timeline's inline projection in every segment incl. a duplicate; and an end-to-end check that a transient lands in the same column in scope and timeline deep in a reordered long-form arrangement. 703 editor tests green, tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Per the alignment audit's cosmetic notes: drop the scope's horizontal inset (PAD_X 4→0) so its time axis fills the width exactly like the timeline canvas — pixel-for-pixel cross-panel x. And make per-column peak sub-sampling adaptive (cover the env samples a column spans, capped) so peak HEIGHT isn't under-shown when zoomed out. No time-axis change. tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…on-engine # Conflicts: # frontend/src/editor/render/build-descriptor.test.ts # frontend/src/editor/render/build-descriptor.ts # frontend/src/local/jobs.ts # frontend/src/local/render/compositor.ts # frontend/src/local/render/edit.ts # frontend/src/local/render/edit.worker.ts
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.
What
Reworks the Punch-In effect (P-FX) system into one uniform modulation interface and fixes the stuck-pad bug.
Every effect now has the exact same control surface:
applyWetnessbus, so even VIGNETTE/RGB/UV get time-movement.Highlights
outSgrowing, un-deletable).setPlaying(false)now finalizes holds + the pad has a window pointerup/blur/unmount guard.fx/modulation.ts, pure + tested): envelope ⊗ lfo|sidechain, depth blend,{ level, phase }.SidechainScope.tsx): a 1:1 lens over the timeline's master-audio lane — same visible window (reconstructed fromui.zoom/ui.scrollX/arrTotal), arr→master per column, peak-bucketed; draggable threshold + live effect-strength band + beat grid-lines.sampleRate/hop(119.84 after whole-sample rounding) — a 0.14% time-scale drift = ~0.4 s off 5 min in. Now stores the true rate; alignment pinned by tests.computeIntensityruns in the export compositor; bpm/beatPhase + the sidechain audio-envelope thread through jobs → worker → compositor; modulation persists onPunchFxRecord.Merge with
mainmainlanded #60 (global color grade + opinionated filters) in parallel, touching the same FX/render files. Merged here; both features coexist —buildFx/compositor order is grade → filters → punch-in accents (with modulation).UI
M-screen (P/E/M) with an LFO|SIDE toggle, reusing the canonical
Encoderknob look (sharedEncoderKnob) — no bespoke knobs.Tests
tscclean.🤖 Generated with Claude Code