Extract shared natural-HOPO helpers into natural-hopo.ts - #73
Closed
elicwhite wants to merge 1 commit into
Closed
Conversation
This was referenced Apr 20, 2026
Owner
Author
This was referenced Apr 20, 2026
elicwhite
force-pushed
the
shared-natural-hopo-helpers
branch
2 times, most recently
from
April 20, 2026 05:10
2626335 to
f850ad9
Compare
This was referenced Apr 20, 2026
elicwhite
marked this pull request as ready for review
April 20, 2026 16:09
The chart scanner, chart writer, and MIDI writer each had their own
near-identical copies of isFretChord / isSameFretNote / isInFretNote /
isNaturalHopo over NoteEvent[], and the parser had the same three
helpers again over TrackEvent[]. This consolidates all five callsites
into src/chart/natural-hopo.ts.
The helpers are generic (<T, E extends { type: T }> + an isFret
predicate); thin wrappers are exported for each concrete group type:
- NoteEvent-based (scanner + writers): isFretChord / isSameFretNote /
isInFretNote, plus the combined isNaturalHopo.
- TrackEvent-based (parser's resolveFretModifiers):
isFretChordRawEvents / isSameFretNoteRawEvents /
isInFretNoteRawEvents. The parser still builds its natural-HOPO
check inline — it compares effectiveNotes to lastNotes while
passing the raw pre-coalesced events to isSameFretNoteRawEvents,
a subtlety no NoteEvent callsite has.
The isFretNoteType / isFretEventType predicates are also exported,
so the parser's two standalone isFretNote(...) callsites (filtering
event lists outside the group helpers) share the same definition too.
The parser's four local helpers (isFretNote, isSameFretNote, isFretChord,
isInFretNote) are deleted.
Net: ~70 LOC of duplication removed across scanner, parser, and (in
the writer branches further up the stack) the two writers. One file
owns every natural-HOPO rule.
This commit updates the scanner + parser; the writers move to the
shared helpers in the two branches further up the stack that own them.
elicwhite
force-pushed
the
shared-natural-hopo-helpers
branch
from
April 21, 2026 04:29
f850ad9 to
ec22459
Compare
Owner
Author
|
Closing — content merged upstream via Geomitron#105 (commit ec22459 is now on master). |
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.

The chart scanner, chart writer, and MIDI writer each had their own near-
identical copies of isFretChord / isSameFretNote / isInFretNote /
computeHopoThresholdTicks / isNaturalHopo, all operating on NoteEvent[].
Consolidate them into src/chart/natural-hopo.ts. computeHopoThresholdTicks
takes the format ('chart' | 'mid') so both backends share one function.
This commit only updates the scanner; the writers are updated in the two
branches further up the stack that own them. The parser's TrackEvent-based
helpers stay put — they operate on a different type shape (EventType, not
NoteType) and generalizing over both would cost more readability than it
would buy.