Skip to content

refactor(audio): the review's cleanup list, and the design record behind the rack - #3176

Merged
vanceingalls merged 542 commits into
mainfrom
wa-19d-cleanups
Aug 13, 2026
Merged

refactor(audio): the review's cleanup list, and the design record behind the rack#3176
vanceingalls merged 542 commits into
mainfrom
wa-19d-cleanups

Conversation

@vanceingalls

Copy link
Copy Markdown
Collaborator

The last slice of the old #3156.

Four of the nine cleanups the review listed: the non-null assertion and two casts the guards already covered, one enabled-node helper instead of three restatements, and dataset keys derived from their attributes.

Lining up the three enabled-node call sites was not cosmetic — it exposed that buildFxChain's filter had no test, and its failure is silent: a bypassed node shifts every later node's parameters into its neighbour with an identical shape either way. Now covered.

Also carries the design record for the rack work that follows: the preset research and catalogue rationale, and the schematic direction.

🤖 Generated with Claude Code

@miga-heygen miga-heygen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: refactor(audio): the review's cleanup list, and the design record behind the rack — #3176

Verdict: LGTM

Four cleanups from the review's list plus the missing test that aligning the call sites exposed, plus a thorough design record.

enabledAudioFxNodes unification — three restatements of .filter((node) => node.enabled !== false) replaced with the canonical enabledAudioFxNodes(chain). This is the SSOT fix the skill flags: same predicate in two helpers, one owner. But lining up the call sites was not cosmetic — it exposed that buildFxChain's update filter had no test. The failure is silent and shape-preserving: a bypassed node shifts every later node's parameters into its neighbour, and the shape string is identical either way (bypassed nodes don't contribute), so nothing forces a rebuild.

The new test creates [highpass enabled, peaking disabled, lowpass enabled], updates the lowpass frequency, and verifies the highpass didn't move. Clean proof of the filter's correctness.

Dataset key derivationHF_AUDIO_FX_DATA_KEY = HF_AUDIO_FX_ATTR.slice("data-".length) and HF_AUDIO_AUTOMATION_DATA_KEY likewise. The studio writes through the attribute and reads through the dataset key; the read side was carrying its own "fx-chain" literal and a rename would half-land. Both spellings now derive from one constant, with tests proving they match. Applied to audioFxSummary.ts, propertyPanelAudioFxGroup.tsx, useVolumeAutomation.ts, and propertyPanelAutomation.ts.

Shape reassignment removalshape = shapeOf(next) was recomputed on every observer tick to write back the string that was already there (the early return proved it equal). Now const.

Narrowing vs assertionresolveAutomationRange uses param directly after the param.kind !== "number" guard instead of casting to HfAudioFxNumberParam. The type system already narrowed it.

FxNodeRow keyingkey={node.id ?? ${node.type}-${i}} instead of ${node.type}-${i}. Two effects of the same type kept their keys through a reorder, so React reused each row in place. Controls hold real state (a half-typed number, an in-flight drag), which stayed at the position and landed on whichever effect moved into that slot.

Cross-realm instanceof fix in analyseel?.tagName !== "AUDIO" instead of instanceof HTMLAudioElement. The composition's elements belong to an iframe's document, so the constructor is from a different realm and instanceof is false for every one. Reading to plain values ({ src, start }) earlier eliminates the non-null assertions downstream.

Design recordplans/audio-fx-presets.md is a well-researched catalog proposal. The honesty about what the 15 effects can't do (no noise reduction, no pitch shift, no spectral repair) is the most valuable part — it prevents scope creep into Tier 1 territory that would need ML. The carve-as-precedent argument is strong: these scripts reuse analysis code that already ships, no new process, no new dependency, no new render-path failure mode.

No issues found.


Review by Miga

🤖 Generated with Claude Code

vanceingalls and others added 23 commits August 13, 2026 01:33
* feat(core): carve against every voice over a bed, always dynamically

A bed usually runs under a whole sequence — a narrator, an interview answer, a
second presenter — and carving against one of them left the others fighting it.
`source` becomes `sources`, and `mixCarveSources` sums every voice onto the BED's
clock before anything is measured. That is what keeps one analysis sufficient: the
chain is fixed, so there is no per-voice filter to switch between, and bands drawn
from all the speech there is with envelopes that rise wherever any of it happens
answer the actual question — where and when is speech masking this bed.

Summed rather than averaged: two people talking at once mask more than either
alone. Audio before the bed starts is dropped rather than folded in at zero, since
it plays over nothing and shifting it would put a cut where there is no voice.

`dynamic` is gone. A fixed depth thins the bed through every pause, and once both
have been heard there is no reason to want it, so every carve follows the speech.

Two helpers the panel and the headless script now share instead of each carrying a
copy — two definitions of "what does this name suggest" drift, and then the two
disagree about which track is the voice:

- `classifyAudioName` reads a track's kind from its id and filename together.
  `unknown` is deliberately common: treating an unrecognised name as "not a voice"
  would hide the one track somebody needs to pick.
- `clipsOverlap` keeps out a voice that never plays while the bed does. An unwritten
  duration counts as unbounded, not zero — refusing a clip whose length the
  composition leaves to the media would drop the commonest case there is.

Files written before this still load: a single `source` reads as a one-voice list,
a stored `dynamic` is ignored, and an absent attribute means the defaults whole.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(core): stop \b from missing underscore-separated names, guard clipsOverlap's negative duration

\b treats `_` as a word character, so \bbed\b never matched bed_01,
music_bed_loop, or theme_song, and \bvo\b/\bvox\b/\btts\b had the same gap —
an underscore-separated bed classified as "unknown" and could end up offered
as its own carve source. Replaced the short hints with a boundary that
actually excludes letters and digits on both sides.

clipsOverlap computed end = start + duration without guarding sign, so a
negative duration put end before start — an interval that does not describe
anything, and one specific case showed it silently dropping a real overlap
(a shorter, earlier broken end rejected a clip that genuinely contained the
point). Duration clamps to zero instead: a clip cannot un-play time, and a
zero-length clip at its start is the sane reading of "duration nobody wrote
down as positive."

Review by Miga (PR #3212).

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
#3212 (accidentally squash-merged into this branch instead of main) changed
HfCarveSettings from a single `source` + `dynamic` toggle to a `sources`
list with dynamic mode removed outright — the multi-voice UI consumer that
goes with that shape lands in the very next PR, so this branch was left with
a type that no longer matched its own code.

Minimal port, not the multi-voice redesign that PR does properly: the
"Listen to" picker and analyse() treat sources[0] as the one voice this UI
still understands, and every dynamic-mode branch (the automated envelope
lanes, the toggle, the checkbox) is gone along with the field — a carve is
now always the static value the analysis computes, matching what the type
change made permanent. Test suite trimmed the same way: the automation-lane
and toggle tests covered behavior that no longer exists.
# Conflicts:
#	packages/studio/src/components/editor/propertyPanelAudioFxGroup.test.tsx
#	packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx
#	packages/studio/src/components/editor/propertyPanelFxSection.tsx
# Conflicts:
#	packages/studio/src/components/editor/propertyPanelAudioFxGroup.test.tsx
#	packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx
#	packages/studio/src/components/editor/propertyPanelFxSection.tsx
#	skills-manifest.json
#	skills/hyperframes-audio/SKILL.md
#	skills/hyperframes-audio/references/attributes.md
#	skills/hyperframes-audio/scripts/carve.mjs
Base automatically changed from wa-19c-worklet-fixes to main August 13, 2026 12:43
@github-actions

Copy link
Copy Markdown

Fallow audit report

Found 5 findings.

Details
Severity Rule Location Description
minor fallow/high-cognitive-complexity packages/studio/src/components/editor/audioFxSummary.ts:13 'audioFxSummary' has cognitive complexity 18 (threshold: 15)
major fallow/high-crap-score packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx:207 'setCarve' has CRAP score 97.0 (threshold: 30.0, cyclomatic 19)
minor fallow/high-crap-score packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx:280 'carvedAgainstBy' has CRAP score 37.1 (threshold: 30.0, cyclomatic 11)
critical fallow/high-crap-score packages/studio/src/components/editor/propertyPanelAudioFxGroup.tsx:490 'analyse' has CRAP score 148.4 (threshold: 30.0, cyclomatic 24)
critical fallow/high-crap-score packages/studio/src/components/editor/propertyPanelFxSection.tsx:267 'FxCarveModule' has CRAP score 148.4 (threshold: 30.0, cyclomatic 24)

Generated by fallow.

Blocks the regression workflow's required preflight gate.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vanceingalls
vanceingalls merged commit fd4d411 into main Aug 13, 2026
55 of 57 checks passed
@vanceingalls
vanceingalls deleted the wa-19d-cleanups branch August 13, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants