Skip to content

writeMidiFile: wrap EVENTS section names in brackets - #88

Open
elicwhite wants to merge 2 commits into
round-trip-unrecognized-extrasfrom
wrap-section-events-in-brackets
Open

writeMidiFile: wrap EVENTS section names in brackets#88
elicwhite wants to merge 2 commits into
round-trip-unrecognized-extrasfrom
wrap-section-events-in-brackets

Conversation

@elicwhite

Copy link
Copy Markdown
Owner

Summary

  • writeMidiFile now emits practice sections as [section <name>] instead of the unwrapped section <name> form.
  • Moonscraper/Clone Hero's MIDI reader matches the literal prefix [section and silently drops the unwrapped form, so the prior output lost every section in CH for round-tripped MIDIs.
  • Matches the .chart writer and the RBN/Rock Band MIDI convention; YARG accepts both forms via NormalizeTextEvent + TryParseSectionEvent.

Test plan

  • npx vitest run passes
  • Round-trip a chart with sections through writeMidiFile and confirm sections appear in Clone Hero

Moonscraper/Clone Hero's MIDI reader matches the literal prefix
`[section ` and silently drops sections written as plain `section
name`. Emit `[section <name>]` to match the .chart writer and the
RBN convention; YARG accepts both forms.
The chart-format spec
(Chart-File-Formats/chart-format/Format-Overview.md, "Basic Global
Events" table + example) shows sections in .chart files written as
plain `section <name>`. The Rock Band / GH1+2 MIDI Practice-Sections
docs say parsers should accept both `[section <name>]` and plain
`section <name>`. A scan of 15,525 charts in the wild confirms it:

  .chart  93,034 plain events,         0 bracketed (across 6,490 charts)
  .mid         9 plain events,   133,046 bracketed (across 9,047 charts)

Updates:
- chart-writer.ts: emit plain `section <name>`. Moonscraper / Clone
  Hero's .chart reader explicitly checks for `"section` (no leading
  bracket) at the start of the E-event payload — bracketed sections
  in .chart silently dropped on import.
- chart-parser.ts: strict plain-only. Bracketed sections in .chart
  fall through to unrecognizedTextEvents instead of being promoted
  to typed sections.
- midi-writer.ts (already in ec5668c) keeps emitting `[section …]`,
  the MIDI canonical form.
- midi-parser.ts (unchanged) stays lenient on input — accepts both
  forms per the spec.
- per-track-data.test.ts: pin the new .chart strictness.
@elicwhite
elicwhite force-pushed the wrap-section-events-in-brackets branch from 08a5714 to 6a03090 Compare April 26, 2026 17:08
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