Split useMidiPlayer.ts into focused modules + grow frontend tests - #116
Merged
Conversation
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.
Split useMidiPlayer.ts into focused modules + grow frontend tests
Break the 1228-line useMidiPlayer.ts composable (1228 -> 610) into focused,
mostly-testable modules — the offline WAV render, shared constants, synth
voices, voice routing, and the scheduler trigger callbacks — and cover the
fragile extracted logic with tests (96 -> 123).
New modules (pure moves — no behaviour change):
PLAYER_PARTS/PlayerPart/CHANNEL_PART, so live playback and the offline
render read one source (no import cycle). useMidiPlayer re-exports
PLAYER_PARTS/PlayerPart so external importers are unaffected.
(offlineRenderRaw, sumPartBuffers, partHasNotes, limitMix, renderOfflineFast,
isRendering). The pause-on-export stays a thin wrapper in useMidiPlayer,
which owns the playback refs.
to synthDrums.ts); they take the player's disposables array so cleanup still
disposes their nodes.
(resolveMelodicVoiceKind) + CC10 pan (panFromCC10); getMelodicInstrument now
switches on the returned kind.
(drumTriggerCallback/voiceTriggerCallback): mute gating, the kick sidechain
pump, and trigger args, injected into toggle so they test without a Tone
context.
New tests: wavEncoder (RIFF header / interleave / clamp / mono), voiceRouting
(voice-selection precedence + pan), scheduler (mute gating, pump, trigger args),
and partHasNotes channel->part mapping.
Verified: vue-tsc + eslint + production build + 123 vitest green. Live playback