Nodes/IAMCCS-nodes/Audio Timeline Gate (continue/stop)
ComfyUI Node

Audio Timeline Gate (continue/stop)

Keep generating, or stop?

By IAMCCS·Created 11 months ago·Updated 7 days ago· 113
Audio Timeline Gate (continue/stop)
    • should_continue
    • should_stop
    • is_last_segment_out
    • cursor_frames_out_passthrough
    • report
    remaining_frames_after0
    effective_unique_frames0
    min_next_frames1
    strict_stop_on_lasttrue
    is_last_segment0
    cursor_frames_out0

    Some nodes do real work, and some just answer yes or no. IAMCCS_AudioTimelineGate is the second kind, and it's a good example of a decision node done right. In a chunked audio-to-video loop you need one place that looks at the remaining frames and says "make another segment" or "we're done" - otherwise the loop either runs past the end of your audio or stops one chunk early. This is that place.

    It's embarrassingly simple under the hood, which is the point. You feed it three numbers:

    • remaining_frames_after - how many track-aligned frames remain after the current segment.
    • effective_unique_frames - how many actually-new frames the current segment contributed.
    • min_next_frames - the minimum left over that justifies generating another segment.

    Then it computes: if there's nothing left after the current segment, it's the last one; if strict_stop_on_last is on (the default), it stops immediately when nothing remains; otherwise it keeps going as long as remaining_frames_after >= min_next_frames. Outputs are the two booleans-as-ints you'll actually wire: should_continue and should_stop, plus an is_last_segment_out flag and a passthrough cursor_frames_out for routing. The report string logs the full decision math, which is worth one glance the first time because "why did my loop stop?" is usually a wrong remaining_frames_after on the input, not a bug in the gate.

    There are two optional inputs worth knowing: is_last_segment lets an upstream node (the pack's AudioExtensionMath) force the last-segment verdict explicitly, and cursor_frames_out is a pure passthrough - useful if you're threading a loop cursor through the chain and don't want to re-route around the gate.

    Where it lives: it's the loop-termination piece of the IAMCCS audio timeline system. The AudioSegmentAutoPlanner gives you the plan, the generation makes a segment, and this gate decides whether to iterate. It's also handy completely standalone in any ComfyUI loop that needs a frame-based continue/stop signal.

    Installing it: part of IAMCCS/IAMCCS-nodes, installed with the pack - ComfyUI Manager → search "IAMCCS", or cd ComfyUI/custom_nodes && git clone https://github.com/IAMCCS/IAMCCS-nodes.git and restart. No models, no extra dependencies, pure integer logic.

    One honest note: this is the kind of node that makes sense in the author's pipeline and can feel like overkill elsewhere. If you're hand-wiring a loop, a couple of math nodes can do the same thing - but they'll do it with the off-by-one errors that this gate exists to prevent. The default min_next_frames of 1 means "generate another segment if even one frame remains," which is the behavior you want for a seamless tail. Raise it to e.g. 8 if you'd rather not burn a whole generation for a handful of frames - that's the real tuning knob here.

    CategoryIAMCCS/Audio

    Inputs (6)

    NameTypeDefaultDescription
    remaining_frames_afterINT00–10000000Remaining track-aligned frames after the current segment.
    effective_unique_framesINT00–10000000Actual usable unique frames of the current segment.
    min_next_framesINT11–100000Minimum remaining frames required to justify creating another segment.
    strict_stop_on_lastBOOLEANtrueIf true, stop immediately when nothing remains after the current segment.
    is_last_segmentoptINT00–1Optional explicit last-segment flag from AudioExtensionMath.
    cursor_frames_outoptINT00–10000000Optional passthrough cursor for downstream routing.

    Outputs (5)

    NameTypeDescription
    should_continueINT
    should_stopINT
    is_last_segment_outINT
    cursor_frames_out_passthroughINT
    reportSTRING