YuE2 Load MIDI
Got a MIDI File? YuE2 Will Sing It, and It Takes 17 Milliseconds to Read
- score_abc
- lyrics
Everyone who writes songs has a folder of MIDI files: something you sequenced years ago, a karaoke .kar, a notation export of a melody you actually like. YuE2 Load MIDI turns any of those into something YuE2 can sing - it reads the file on the spot, downloads nothing, and a three-track file took 0.017 seconds in the author's own measurement.
It's a different job from the rest of the pack: YuE2 Transcribe listens to a recording and guesses what it heard, while this one reads notes that are already exact.
Where this fits, honestly
Local music generation in ComfyUI mostly means ACE-Step - great instrumentals, weak vocals. YuE2 is the other half of that deal, and Load MIDI is the branch for when the tune exists and only the performance is missing.
How a file becomes a singable score
The node reads the notes out of one track as the vocal line and another as the instrumental line, then folds them into the ABC score YuE2 sings from. Some of that folding is lossy, and the node tells you rather than hiding it:
- A score keeps one tempo, so a file with tempo changes gets them averaged, and the node says so. Bars come from the file's meters, and a file played in by hand is rounded to sixteenths with a notice.
- Each score line holds one note at a time, so of notes struck together the top one is kept and the node reports how many it dropped. Chords in the vocal track are sung as their top note.
- A line whose middle pitch sits outside C4 to A#5 is moved by whole octaves, because YuE2 sings the octave it is given. The key comes from the file's key signature where it fits the notes and is estimated otherwise, and markers named like sections become sections.
The settings that matter
midi is a file in ComfyUI's input folder - .mid, .midi, .kar or .rmi. Choose MIDI file... on the node uploads one, and so does dropping a file onto the node; the dropdown is empty until a file is there.
mode is melody (default) or full: the first writes the two lines without chords, the second adds chord symbols guessed from the other tracks - and each pairs with cot at melody or full on the song node. Those chords are a guess; read them over in Edit score....
vocal_track and instrument_track default to auto, and the list printed on the node shows you what auto picked, and why, before anything runs: the track a karaoke file's words fall on, then one named as the voice or the melody, then the highest line that is not a bass. instrument_track can also be none.
without_sections is on by default and is the one to understand. On, the score goes out as a bare tune with no section comments, and YuE2 Generate Song lays your lyrics along the tune's phrases before singing - splitting at breaths and bar lines, matching each line to a phrase with about as many notes as it has syllables. That matters: sung with its own sections, a wordless tune loses the words (0 of 46 words heard in order over one test theme). Turn it off when you are singing a karaoke file with its own words.
Outputs are score_abc (wire it into YuE2 Generate Song's score_abc) and lyrics (a karaoke file's words under their section tags, or a bare [Verse] to write under).
Install
The pack's install is the usual custom-node drill - its only hard dependency is tiktoken, and the models are fetched on first use by the song node, not this one:
cd ComfyUI/custom_nodes
git clone https://github.com/pytraveler/YuE2-ComfyUI
# then restart ComfyUI
Nine workflows ship with the pack under Workflow → Browse Templates; template 7, Sing a MIDI file, is this node already wired up.
Where people get burned
The older YuE-in-ComfyUI experience was rough enough that people spent a week on it and got 90 seconds of silence. What this pack changes is mostly bookkeeping: a bad score is refused with the reason on the node (No score could be written from 'x.mid': the file has no notes, for instance) instead of failing downstream. Usual suspects: a file that is not really MIDI despite the extension, a drum track picked by hand for the voice (drums have no tune - the node says so), and a lyric that fights the tune, which earns a warning about lines having half again as many notes as syllables. With max_seconds at 0, a tune-led song stops a little past the tune's own length, and the node reports which bars never got sung.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| midi | COMBO | A MIDI file in ComfyUI's input folder: .mid, .midi, .kar or .rmi. 'Choose MIDI file...' uploads one, and so does dropping a file on the node. The list on the node names the file's tracks and which of them the score takes. | |
| mode | COMBO | melody | 'melody' writes the vocal and instrumental lines without chords, to be sung with 'cot' set to 'melody'. 'full' adds chord symbols guessed from what the other tracks play together, for 'cot' set to 'full'. They are a guess: read them over in 'Edit score...'. |
| vocal_track | COMBO | auto | The track the voice sings, by its number in the list on the node. 'auto' takes the track the karaoke words fall on, then a track named as the voice or the melody, then the highest line that is not a bass. Chords in the track are sung as their top note. |
| instrument_track | COMBO | auto | The track the score's instrument line takes, by its number in the list on the node, or 'none'. 'auto' takes a track named for it, then the busiest remaining track above G3 that is neither a bass nor mostly chords, and leaves the line empty when there is none. |
| score_abcopt | STRING | The edited score kept on this node. Empty at first, which means every run writes the file's score. 'Edit score...' fills it after a run. The edit belongs to the file, the mode and the tracks it was made for: with another file or another choice the node writes the score anew and says so. A score pasted before any run carries no file and is output as it is. | |
| lyricsopt | STRING | The edited lyrics kept on this node. Empty at first, which means the lyrics output is the file's karaoke words under their section tags, or the section tags alone. 'Edit lyrics...' fills it. An edit belongs to the file it was written for; lyrics written before any run are output as they are. | |
| without_sectionsopt | BOOLEAN | true | On, as it starts: the score goes out without section comments, as a bare tune, and 'YuE2 Generate Song' lays the lyrics it sings along it -- each line on a phrase with about as many notes as the line has syllables, the tune repeated when the words outlast it, and the song ending with the words. A tune written without these words in mind is sung clearly that way when its phrases have room for them. Off: the score keeps the sections the file names -- its markers, or a karaoke file's paragraphs -- or is one verse, and is sung as it arrives. For a karaoke file sung with its own words, or lyrics written to this score's sections. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| score_abc | STRING | — |
| lyrics | STRING | — |