Looping Audio Preview
Hear your loop, on repeat, before you commit to it
- audio
- looped_preview
- conditioning_audio
- info
Music is a thing you have to hear, and ComfyUI's default audio preview plays a clip once. LoopingAudioPreview plays it on repeat - three times by default - so you can actually judge whether a generated loop loops, rather than squinting at a waveform. It's the pack's listening room, and it has one extra trick: it passes your original audio through untouched as a second output, so the same node can preview and hand audio onward to the next generation in one shot.
How it works
Give it an AUDIO input and it repeats the waveform loop_count times (1–10), encodes the result to a temp WAV via PyAV, and returns it to ComfyUI's UI as a playable preview. Three outputs: looped_preview (the repeated audio), conditioning_audio (the original, un-looped input, passed straight through), and info (a status string with durations, sample rate, and queue state).
Two design choices are worth understanding before you lean on them.
It's stateful. The node forces re-execution on every run (its IS_CHANGED always returns NaN) and keeps class-level playback state keyed by instance_id. That's deliberate: the whole point is that it reacts to new audio arriving over time, not that it's a pure function of its inputs. For most people the only thing you need to remember is to give each preview node a unique instance_id if you run more than one - otherwise they step on each other's state.
queue_mode is wall-clock, not sample-accurate. When enabled, the node estimates how long the current loop should still be playing (using real time, not ComfyUI's clock) and, if you feed it new audio before the estimate says the old loop finished, it queues the new audio instead of interrupting. It's a pragmatic hack - it works for judging tracks back to back, but it's not a DAW. If you need sample-precise transitions, that's what SmoothAudioQueue is for.
The inputs that matter
- audio - the clip to preview (MusicGen output, or
LoadAudioStandaloneoutput for existing files). - loop_count - how many repeats. 3 is a good default for judging a loop; more for longer listens.
- enable_preview - toggle playback on/off. Turn it off to skip the temp-file write when memory's tight.
- queue_mode - on/off for the "wait for the current loop before playing the new one" behavior.
- instance_id - unique per preview node. Defaults to
default; change it the moment you add a second preview.
Install
Part of ebrinz/ComfyUI-MusicGen-HF. ComfyUI Manager → search "ComfyUI-MusicGen-HF", or:
cd ComfyUI/custom_nodes
git clone https://github.com/ebrinz/ComfyUI-MusicGen-HF
cd ComfyUI-MusicGen-HF
pip install -r requirements.txt
Restart ComfyUI. PyAV (av) does the preview encoding, so it must be installed.
Troubleshooting
"Audio not looping" is almost always loop_count set to 1 or enable_preview off - both are easy to hit when you're clicking around. If two previews misbehave, check you gave them distinct instance_ids. High loop_count on a long clip means a big tensor (10 × 30s is 300s of audio held in RAM); drop the count or disable preview on a constrained machine. And when you see silence in the preview output, remember the node falls back to returning its input with an error string in info - read that before blaming the audio.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — | |
| loop_count | INT | 31–10 | Number of times to loop the audio for preview |
| enable_preview | BOOLEAN | true | Enable audio preview playback |
| queue_mode | BOOLEAN | false | Wait for current audio to finish before playing new audio |
| instance_id | STRING | default | Unique identifier for this preview instance (for multiple nodes) |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| looped_preview | AUDIO | — |
| conditioning_audio | AUDIO | — |
| info | STRING | — |