Nodes/SC YuE2 ABC Helpers/SC YuE2 ABC Song Length
ComfyUI Node

SC YuE2 ABC Song Length

12 Before You Spend the GPU On It

By ShantyCircuit·Created 16 days ago·Updated 16 days ago· 0
SC YuE2 ABC Song Length
    • report
    • seconds
    • bars
    ◄abc—►

    Here's the annoying thing about YuE2 workflows: the score comes out as a wall of text, and the only way to find out how long the song is has historically been to render the whole thing and look at the waveform. You wait, you get 4:12, and now you re-roll.

    SC YuE2 ABC Song Length answers the question in a fraction of a second, from the score alone. No sampling, no render, no GPU. Point it at a score and it tells you how long it will play, how many bars there are, how long the instrumental stretches run, and whether the score does anything weird with meter.

    The mechanism (it's arithmetic, and that's the point)

    ABC notation encodes everything you need to compute duration: a meter (M:), a tempo (Q:), a note unit (L:), and bars separated by pipes. So the node just parses the file and does the sum.

    It reads the tempo either as Q:1/4=120 or plain Q:120, and it also catches tempo changes written inline inside a vocal line as [Q:...]. Then, per section - sections being the % marker lines that YuE2 writes for intro/verse/chorus - it counts bars and multiplies by seconds-per-bar, which is (meter / note unit) × 60 / bpm. Bars are counted from the Vocal voice only, which is what keeps the number honest instead of double-counting every voice in the score.

    Two bits of musical housekeeping happen along the way. Chord symbols and inline fields are stripped before counting, so a bar stuffed with "Dm" and [K:] noise still counts as one bar. Multi-rests (Z, Z4) count as the number of bars they actually rest. Vocal-free bars get tallied separately, a section that's more than three-quarters instrumental gets flagged as <- instrumental in the table, and the report also tells you the longest stretch without vocals - useful when you're deciding whether the model gave you a proper verse or three minutes of vamping.

    What you get out

    Three outputs. report is the good stuff: a numbered section table with tempo, bar count, vocal-free bars and length per section, a total row, and a warning line for any mid-score meter switch. seconds is a float for anything you want to do math on downstream, and bars is an int, handy if you think in structure rather than duration.

    Because the node is marked as an output node, it has a run button. You can drop it in, wire a score to it, hit run, and read the totals without triggering Generate Music at all. The summary also renders on the node itself, so you don't have to hunt in the console.

    The inputs are one socket

    There's a single optional input, abc - and it's connection-only, so you can't paste a score into it. That's fine once you know the trick the bundled example workflow uses: a PreviewAny node is a pass-through, so you can tap it into the chain at any point and feed Song Length from there. The example does exactly that to inspect the raw score from Length Search before Fix Meter and Speed Change get to it, which is how you compare "what the model wrote" against "what I turned it into".

    Install

    Standard pack install, no Python dependencies. You need a recent ComfyUI with the V3 node API.

    cd ComfyUI/custom_nodes
    git clone https://github.com/ShantyCircuit/ComfyUI-SC-YuE2-ABC-Helpers
    

    Restart ComfyUI, hard-refresh the browser (Ctrl+Shift+R), and look under ShantyCircuit/YuE2. Manager users: search SC YuE2 ABC Helpers. The YuE2 model itself loads separately through CheckpointLoaderSimple with yue2_3b_bf16.safetensors - this pack has no weights.

    Things that will confuse you

    • "No bars found. Is this a YuE2 ABC score?" Either you connected something that isn't a score, or the score has no V: Vocal line at all - bar counting runs off the Vocal voice, so a purely instrumental score can come back empty. Same message if you left the input disconnected.
    • The numbers don't match the audio file exactly. They shouldn't, necessarily. This is the score's own arithmetic: meter, tempo and bar count as written. It's a pre-flight estimate, not a measurement of a render you haven't made yet.
    • A meter warning shows up at the bottom. That's not Song Length's problem to fix. It's telling you the score has a one-bar meter glitch - hand it to SC YuE2 ABC Fix Meter.
    • No summary box on the node. The pack's frontend script (js/show_summary.js) didn't install, or your browser cached the old one. Hard refresh and check the browser console.

    If you're iterating on song length at all, this is the node to keep permanently bolted to your graph. It costs nothing to run, and it turns "wait two minutes and find out" into "read the table".

    CategoryShantyCircuit/YuE2

    Inputs (1)

    NameTypeDefaultDescription
    abcoptSTRING—

    Outputs (3)

    NameTypeDescription
    reportSTRING—
    secondsFLOAT—
    barsINT—