Refactoring round 10 covers everything since round 9 (808e1ee): 110
commits with about 47 000 new lines, nearly all of them sound, sound
FX, instruments, patterns and songs. Behaviour is unchanged.
Duplicate code (jscpd over src, 50 tokens, TypeScript only, measured
on 808e1ee and here alike: 47 clones / 426 lines before, 33 / 245
after; round 9 itself ended at 22 / 160 by this count):
- PreviewParams (new, editor/soundfx) is the header's parameter bar
of the Sound FX and the Instrument tab: values, defaults, fields
and the voices a moved field reaches. Both tabs had it line for
line.
- fxWorklet: an Effect base runs the bit crusher, phaser, flanger,
limiter, LFO and bus shifter, a Source base the pitch player and
the Chip. Start is the one wait for a voice's first sample, which
four processors wrote out each.
- nodes/shared has checkPort, detachedPort, fxParamsPort and
letRingPort. The Play and Stop nodes of sounds, notes, patterns and
songs spelled each port out, up to five times.
- parameterValues builds both Sound FX parameters and Instrument
parameters, which differed in name and text only.
- SetLoopCommand sets the ruler loop of a pattern or a song. It
replaces SetPatternLoopCommand and SetSongLoopCommand.
- addLink in music/routing is the one rule for a link that both the
song routing and the Master routing keep.
- eqCurves works out each band and their sum for the EQ tab, which
did that in its drawing code. It replaces eqCurveDb, which only a
test called.
- Smaller ones: the eight neighbour directions of a tile cell, and
drawFloatingBox for the shadowed box of Popup and FloatWindow.
- Left on purpose: Play pattern and Play song stay two parallel node
definitions, and the smaller clones under ten lines stay.
Architecture:
- SoundLibrary.ts goes from 2897 to 2188 lines. What a stage of a
sound FX becomes as Web Audio nodes, and how the knobs of a playing
voice move, is now viewport/fxNodes.ts. None of it keeps state of
the library.
Dead code (TS language service, references per export and member):
- soundRefIds, LFO_SHAPE_INDEX, TREMOLO_ROWS, VIBRATO_ROWS and
REVERB_ROWS had no reader. The four routing node defs are
registered without an unused exported name.
- soundFileOf and portTypeOf were called by tests only. The tests
now ask findSound and portOf, which the editor uses. DRY moves
from src into the one test that uses it.
- 51 values used only in their own file lose their `export`. Types
and the node catalogues stay exported.
- Kept on purpose: neighboursOf is the cell by cell reading the
indexed neighboursIn is checked against, and PitchShifter.latency
is the test's one view of how late the shifter is.
Comments and docs:
- Seven comments told history ("no longer", "any more", "as
before", "of before #354"). Nine comment blocks ran far past the
line width. Proof that this changed no code: the bundle was md5
identical, and the touched tests and e2e modules were identical
after esbuild.
- README: sound FX, instrument, pattern, song and bus in the asset
list, the pages Instruments, Patterns and Songs, 1919 checks.
- Wiki: see its own commit.
Tests:
Gate (melektaus-atx) 274 files, 4236 tests, CHECK EXIT 0
e2e 34, 64, 65 ALL PASSED, 180 checks
Unit, touched areas 16 files, 804 tests
No check was added, the e2e sum stays at 1919. Counter-checks, each
put back by copy and compared with cmp:
- addLink without the loop rule: 2 tests fail, one per routing.
- eqCurves with the sum of the last band only: 1 test fails.
- Start in the worklet never waiting: e2e 34 fails in exactly the
four checks that hang on a voice's first sample (Flanger, Tremolo,
Chip, a pitched note planned ahead).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The asset link in the inspector already pings an asset on a click and
opens it on a double-click. The rows of the Scene objects panel only
selected and folded. Now they lead to the asset the same way.
- A click on the row that is selected already pings the object's
asset in the asset panel. The selection stays. The ping comes on
release, so picking a row up to drag it pings nothing.
- A double-click or Enter on an object's row opens its asset,
selected or not.
- ListView has a new onReselect for a plain click on the row that is
selected alone. onSelect stays quiet then, as nothing changes.
Decided without asking:
- A double-click on an object's row no longer folds it. The chevron
and the arrow keys still do. A group's row has no asset and keeps
folding on a double-click.
- A click with Ctrl or Shift, and one that narrows a multi-selection
to its row, does not ping. Both change the selection.
- A row whose asset is missing pings and opens nothing.
Findings:
- The double-click window goes by time (400 ms), not by the event's
detail. Two quick click() calls from the harness are a double-click.
The comment in e2e 01 said otherwise and is gone.
Tests:
- e2e 01 (melektaus-atx): ALL PASSED, 13 checks. The two checks for
folding on a double-click became one for the ping and two for
opening. Counter-check without the ping: that check red.
- Gate (melektaus-atx): CHECK EXIT 0, 268 files, 4142 tests.
- Not checked: Enter on a row, a group's row on a double-click.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The suite spent 88% of its step time asleep: 564 s of steps, 496 s of
them in sleep(n) - fixed spans estimated by hand and then copied from
step to step. That is why it was slow, and why it flickered.
The signal is afterFrames(count, timeout) in ui/render.ts, exposed as
__gm.afterFrames(). It wakes the loop itself, because an editor that
draws nothing would never redeem a promise of a frame, and it gives up
after a timeout instead of hanging the run. settle() in the harness
waits two drawn frames (~32 ms) instead of 150-300 ms and falls back to
sleep(150) when the hook is missing (an old build): silently not
waiting would make every later check a coin toss.
Every action goes through it now - click, doubleClick, wheel, drag,
dragAsset, press, typeText, select, mutate, undo, redo - and with that
about 550 sleep() calls behind those actions became redundant, helpers
that are nothing but a mutate in a coat included. What a frame cannot
answer got its own condition instead: waitUntil(expr), play()/stop()
waiting on __gm.state.mode rather than on 300 ms, saved() for the
autosave (the two hand-written polling loops sampled at 300 ms for
something that arrives after a second), and showTab() as a real tool -
47 places called evaluate("__gm.showTab(...)") raw, and 24 of them
waited for nothing at all and read the old panel.
564 s -> 243 s of step time, the waiting share 88% -> 76%. Three kinds
of wait were kept, and each one bit when it was taken away: loading
bytes (textures, fonts), game time that a repaint cannot stand in for
(time scale, shader and particle clocks, the live values a running
graph carries), and the inertia the scroll step measures on purpose.
Two things the new speed uncovered, both real: 25-animation read the
frame menu unfiltered and had frozen an incomplete list (the CI failure
on c990dbc), and 33-render-on-change measured idleness while the
autosave of the step before was still painting - it waits for
saveStatus to leave dirty/saving now, so it measures that nothing
happens any more instead of that it waited long enough.
Pixi only fills `detail` on the `click` event it synthesises; on
`pointerdown` it is always 0, so every `e.detail === 2` branch was dead
code. Asset rows, hierarchy folding and select-all in text fields never
responded to a double-click.
A shared click counter in src/ui/clicks.ts replaces the three readings of
`e.detail`. A finished double-click ends the run, so two in a row count
2 and 2 rather than 3 and 4.
The harness could only send `clickCount: 1`, which is why no test caught
this: every "activate" check went through Enter. It can send real
double-clicks now, and five checks drive the three paths separately.
The Container tab reuses SceneViewport against any object holder, so a
container template is edited exactly like a scene. Right-click no longer
changes the selection, which previously made nesting impossible: opening
the menu on a container loaded it, and "Place in container" then targeted
itself.
Template edits (move, rename, override) now reach already-placed instances
per slot, through a shared templateSync used by both the apply path and the
plain object commands. Copies the user has touched keep their own value.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Tooling:
- Prettier as the single formatting authority (110 columns, single quotes,
measured against the existing style); Markdown excluded because table-cell
padding turns the README glossary into 1000-character lines.
- Type-aware ESLint ending in eslint-config-prettier, so a rule always means
"this is a bug", never "this looks different".
- .editorconfig and an `npm run check` that runs typecheck, lint, format and
tests in one go.
Findings fixed on the first run: three more duplicate imports, four
String(unknown) calls (parameter types narrowed instead of casts), two dead
initialisers, two redundant casts, a console.log for a real error. Two
warnings were false here and are disabled with a reason in place.
Tests 132 -> 269:
- node-catalog.test.ts covers every node with a run(), with a guard that fails
when a new node has no row.
- behavior-events.test.ts covers the ten event nodes through a running World,
checking timing rather than existence.
- Input's state machine (press/release/releaseAll) is reachable without DOM
events now; the DOM handlers are thin adapters.
Compare fell back to == without a configured operator although the schema
default is <; aligned.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>