Skip to content

Read and write lyrics in MIDI files - #163

Merged
ghost-in-the-groove merged 1 commit into
mainfrom
feat/midi-lyrics
Nov 25, 2026
Merged

ghost-in-the-groove merged 1 commit into
mainfrom
feat/midi-lyrics

Conversation

@ghost-in-the-groove

Copy link
Copy Markdown
Owner

Summary

MIDI files now carry lyrics both ways (ADR-0084).

 import
   gather       per MIDI track
-    Lyric event  -> "lyrics dropped"
+    Lyric event  -> the track's lyric line
+  assignLyrics  each line goes to the channel whose notes start with most of its syllables:
+                one of the same track, else any of the file (a track of words only -> the melody)
+  placeLyrics   a syllable on the note starting nearest it (at most a 32nd away), as verse 1
 export
+  lyricEvents   a Lyric event per syllable, right before its note-on:
+                "Twin-" "kle " ...  (hyphen = the word goes on, space = it ends)
+                each pass through a repeat sings the verse of that pass
  • Reading is lenient, because files disagree and RP-017 is not freely available:
    • Spaces, CR/LF and karaoke's / and \ around a syllable are trimmed.
    • A hyphen after a syllable, alone, or before the next one joins it to the next.
    • Empty events sing nothing.
  • Dropped with a warning:
    • on import, syllables away from any note or on a note that already sings;
    • on export, verses that no pass of a repeat sings, a second staff's lyrics, and extenders.

Evidence

  • Before: io.MIDI import lists what the model cannot hold expected "lyrics dropped", and export wrote no lyrics.
  • After: three new io.MIDI ... cases.
    • import puts lyric events on the notes they start with:
      • "Twin-" "kle " "\r" "lit" (2 ticks late) "-tle" "\star" give Twin- kle lit- tle | star;
      • a syllable over a rest is dropped with a warning.
    • import gives a lyrics track without notes to the melody it sings: a words-only track goes to the flute, not the bass.
    • export sings each pass of a repeat with its verse:
      • the bytes FF 05 04 "one " 00 90 3C are written;
      • read back, the measures are one | two | end- ing;
      • the warnings name the unsung verse and the extender.
  • The corpus MIDI band snapshots now show its "la" syllable, drawn under the staff, and no longer warn.
  • Checked on local Guitar Pro files exported to MIDI and read back:
    • A vocal track kept all 170 syllables.
    • Another kept 101 of 104. The 3 lost are 2 second-verse syllables on measures played once and 1 syllable on a tied note, which has no note-on. All 3 are reported.
  • The full gate passes locally.

Merge Danger

Door: two-way

Blast Radius: small

  • MIDI files with lyrics now import them: tracks that sing get taller systems, and the warning is gone.
  • Exported MIDI files gain Lyric events. Players that do not show lyrics ignore them.

Lyric meta events go on the notes they start with, and a track of words
only goes to the melody it sings. The export writes a Lyric event per
syllable, and each pass through a repeat sings the verse of that pass.
@ghost-in-the-groove
ghost-in-the-groove enabled auto-merge (squash) November 25, 2026 10:03
@ghost-in-the-groove
ghost-in-the-groove merged commit 656e9ff into main Nov 25, 2026
3 checks passed
@ghost-in-the-groove
ghost-in-the-groove deleted the feat/midi-lyrics branch November 25, 2026 10:17
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