Loop Calculator (Audio)
How many loops does your audio clip actually need?
- audio
- loop_count
- total_frames
- duration
If you've ever built a video-loop workflow around an audio track - a talking head, a singing clip, an extend-sampling loop that regenerates frames to match a soundtrack - you know the annoying part isn't the sampling. It's the arithmetic. The audio is 12.7 seconds long, your loop samples 81 frames at 16 fps with 9 overlapping frames, and you need to know how many iterations to run. That's the exact job Loop Calculator (Audio) exists for, and it's the audio sibling of the plain Loop Calculator node in Eclipse > Video.
It's a pure math node: total_frames = ceil(duration Γ fps), then it figures out how many loop iterations of context_length frames (stepping by context_length β overlap_frames) it takes to cover that. Output one (loop_count) is the number of additional loops you need on top of the base loop - the README and the code both describe it as "needed for extend sampling feedback loop, excluding the base loop," so don't add one back in yourself. You also get total_frames and duration out for free, which is handy when you want the same numbers for a filename or a Keep Calculator without re-deriving them.
How it works
The real trick is that it mirrors the frame budgeting your Smart Folder or loop context already uses - the author explicitly built it to match: frame_load_cap = context_length Γ loop_count. If your sampler settings and your calculator disagree about context_length, you get a loop count that's right for the calculator and wrong for the workflow, so keep the two in sync.
The one input to actually think about is duration - it's ignored the moment you connect an AUDIO input, which overrides it with the real waveform length (waveform.shape[-1] / sample_rate, if you care about the mechanism). Wire your audio in and the node self-corrects when you swap tracks; type the number in and you're trusting yourself. The defaults (fps 16, context_length 81, overlap_frames 9) are tuned for the author's video loop conventions, so expect to change fps to match your actual video at minimum.
Where it fits
In practice this feeds the loop counter on your sampling loop and the audio-to-video length checks, usually in the same Eclipse > Audio neighborhood as Loop Align Silence - that one tells you where transitions should happen, this one tells you how many loops to run in the first place. Same three shared numbers (fps, context_length, overlap_frames), same mental model.
Install
Part of ComfyUI_Eclipse (r-vage). ComfyUI Manager, search ComfyUI_Eclipse, or:
cd ComfyUI/custom_nodes
git clone https://github.com/r-vage/ComfyUI_Eclipse
Restart after cloning. Dependencies are mostly ComfyUI's own stack; the pack's requirements.txt adds opencv-python, aiohttp and a few others - install the missing one only if a node errors. Watch out if you're loading a shared workflow: this pack rewrote the old RvTools_v2 and v4.0 removed legacy node IDs, so a broken workflow usually means running the Workflow Migration Tool rather than reinstalling.
Common issues
If loop_count comes out one short, check whether you're counting the base loop in your loop counter - the output is explicitly additional loops. If it's wildly off, your context_length doesn't match the sampler's frame cap. And the usual silent trap: connecting a mono audio that's actually a different length than you think. Connect the AUDIO socket and let the node measure it; typing duration by hand is how off-by-two-seconds loops happen.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| duration | FLOAT | 0.000β86400 | Audio duration in seconds. Ignored when an AUDIO input is connected. |
| fps | FLOAT | 16.001β240 | Target frame rate (frames per second). |
| context_length | INT | 811β4096 | Smart Folder context length. |
| overlap_frames | INT | 90β4096 | Number of overlapping frames between loops (e.g. motion_frame_count in InfiniteTalkToVideo). |
| audioopt | AUDIO | Optional AUDIO input. When connected, its duration overrides the duration widget. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| loop_count | INT | Number of additional loops (iterations) needed for extend sampling feedback loop (excluding the base loop). |
| total_frames | INT | β |
| duration | FLOAT | β |