Skip to content

writeMidiFile: emit PART GUITAR / GHL instrument tracks - #75

Open
elicwhite wants to merge 1 commit into
midi-writer-drumfrom
midi-writer-guitar
Open

writeMidiFile: emit PART GUITAR / GHL instrument tracks#75
elicwhite wants to merge 1 commit into
midi-writer-drumfrom
midi-writer-guitar

Conversation

@elicwhite

Copy link
Copy Markdown
Owner

Adds fret-instrument emission to writeMidiFile.

  • buildFretTrack: one MIDI track per instrument group (guitar / bass /
    guitarghl / bassghl / keys / guitarcoop / rhythm / GHL variants);
    multiple difficulties merge into the same track.
  • emitFretNotes: 5-fret (95/83/71/59 diffStarts) and 6-fret/GHL
    (94/82/70/58) note-number mapping; open notes routed two ways:
    ENHANCED_OPENS mode (diffStart+0, preserves chord-with-open) when any
    group contains both open and non-open, else forceOpen-SysEx fallback
    (diffStart+1 + SysEx, collapses chords with open but safer next to
    animations at easy diffStart). Coalesces fret-note length with
    overlapping animations at the same tick:noteNumber via pre-computed
    seq slots so animation ordering survives re-parse.
  • Force modifier ranges (forceHopo / forceStrum / forceTap) via
    emitFretModifierRanges — inverts resolveFretModifiers: natural HOPO
    state is re-derived with the MIDI threshold (1 + res/3), and a modifier
    emits only when the resolved flag disagrees. forceHopo = diffStart+6
    (5-fret) / +7 (GHL); forceStrum = +7 / +8; forceTap as SysEx.
  • reconstructModifierRanges: collapses per-tick hit sets into minimal
    contiguous ranges over noteTicksInOrder.
  • Instrument-wide emission: star power (MIDI 116), solo (MIDI 103),
    flex lanes (126/127 with per-difficulty LDS velocity), per-track text
    events, versus phrases (105/106), animations (with skip when the fret
    note above already emitted at the same tick:noteNumber), per-track
    unrecognizedMidiEvents.
  • [ENHANCED_OPENS] text event when that mode is active.
  • Helpers added: addSysExOnOff, reconstructModifierRanges,
    midiIsFretChord / midiIsSameFretNote / midiIsInFretNote.

Vocal tracks (PART VOCALS / HARM1-3) land in the follow-up PR.

Tests: 15 new test cases covering track naming, 5-fret + GHL
note-number mapping, open-note encoding (both modes), force modifier
emission (hopo/strum/tap + non-emission when natural matches),
instrument-wide sections, and round-trip through parseChartAndIni for
both 5-fret modifiers and GHL chord-with-open. 53 midi-writer tests,
397 total scan-chart tests passing at the tip.

Comment thread src/chart/midi-writer.ts Outdated
Adds fret-instrument emission to writeMidiFile.

- buildFretTrack: one MIDI track per instrument group (guitar / bass /
  guitarghl / bassghl / keys / guitarcoop / rhythm / GHL variants);
  multiple difficulties merge into the same track.
- emitFretNotes: 5-fret (95/83/71/59 diffStarts) and 6-fret/GHL
  (94/82/70/58) note-number mapping; open notes routed two ways:
  ENHANCED_OPENS mode (diffStart+0, preserves chord-with-open) when any
  group contains both open and non-open, else forceOpen-SysEx fallback
  (diffStart+1 + SysEx, collapses chords with open but safer next to
  animations at easy diffStart). Coalesces fret-note length with
  overlapping animations at the same tick:noteNumber via pre-computed
  seq slots so animation ordering survives re-parse.
- Force modifier ranges (forceHopo / forceStrum / forceTap) via
  emitFretModifierRanges — inverts resolveFretModifiers: natural HOPO
  state is re-derived with the MIDI threshold (1 + res/3), and a modifier
  emits only when the resolved flag disagrees. forceHopo = diffStart+6
  (5-fret) / +7 (GHL); forceStrum = +7 / +8; forceTap as SysEx.
- reconstructModifierRanges: collapses per-tick hit sets into minimal
  contiguous ranges over noteTicksInOrder.
- Instrument-wide emission: star power (MIDI 116), solo (MIDI 103),
  flex lanes (126/127 with per-difficulty LDS velocity), per-track text
  events, versus phrases (105/106), animations (with skip when the fret
  note above already emitted at the same tick:noteNumber), per-track
  unrecognizedMidiEvents.
- [ENHANCED_OPENS] text event when that mode is active.
- Helpers added: addSysExOnOff, reconstructModifierRanges,
  midiIsFretChord / midiIsSameFretNote / midiIsInFretNote.

Vocal tracks (PART VOCALS / HARM1-3) land in the follow-up PR.

Tests: 15 new test cases covering track naming, 5-fret + GHL
note-number mapping, open-note encoding (both modes), force modifier
emission (hopo/strum/tap + non-emission when natural matches),
instrument-wide sections, and round-trip through parseChartAndIni for
both 5-fret modifiers and GHL chord-with-open. 53 midi-writer tests,
397 total scan-chart tests passing at the tip.
@elicwhite
elicwhite force-pushed the midi-writer-guitar branch from f4cca25 to 940eeea Compare April 22, 2026 16:34
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.

1 participant