Smooth Audio Queue
Exact duration and clean crossfades — the finishing node
- audio
- queued_audio
- conditioning_audio
- info
Two problems ruin an otherwise fine MusicGen workflow: the clip is never the exact length you asked for, and when you play clip after clip the seam between them thumps. SmoothAudioQueue handles both. Displayed as "Smooth Audio Queue", it trims or pads audio to a precise target duration and crossfades between successive clips so a chain of generations plays like one continuous piece of music.
This is the node you reach for when timing actually matters - syncing a generated track to a video, matching a bar count from BPMDurationInput, or stitching generations into a longer composition.
How it works
Three mechanisms in one node.
Duration validation. MusicGen generates on a ~50-token-per-second grid, so the node rounds any target_duration you give it to the nearest ~0.02s token boundary and caps it at 30s. That keeps your target in a range the model can actually hit.
Exact-length trimming. With a validated target, it trims excess samples or pads with silence to reach exactly that duration, sample-accurately. This is the "make it precisely 7.583s" part.
Crossfading. When the input audio changes and auto_play is on, it builds a linear fade-out/fade-in blend between the previous clip and the new one (crossfade_duration, 0–2s) and concatenates them. Successive generations come out with a smooth hand-off instead of a click.
The inputs that matter:
- audio - the incoming clip.
- target_duration - 0 = use the clip's original length; otherwise the exact seconds you want (0–30).
- crossfade_duration - 0–2s, default 0.5. The blend length between clips.
- queue_id - separate id per stream so independent chains don't crossfade into each other.
- auto_play - on by default; when on, new audio triggers the crossfade.
Outputs: queued_audio (the processed result), conditioning_audio (the original, passed through for continuation), and info (validated duration, status, buffered-clip count).
Where it fits
The killer combo is BPM → MusicGen → this node. Generate a four-bar clip at 128 BPM (7.5s), run it through SmoothAudioQueue with target_duration at the same value, and you get a clip that's actually 7.5s on the nose - the difference between "a loop" and "a loop that lines up in a DAW". For DJ-style mixing of two sources into one stream, give both the same queue_id and let the crossfade do the work.
Install
It's one of the ten nodes in ebrinz/ComfyUI-MusicGen-HF. Install the pack once via 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.
Troubleshooting
Crossfade artifacts on short clips - a 2s fade on a 3s clip eats most of it; drop crossfade_duration to 0.2–0.3s or skip the crossfade. If durations drift from your target, remember the ~0.02s token rounding is baked in; use BPMDurationInput on the same math so both sides agree. And if transitions never seem to fire, check queue_id - a different id per branch means no shared buffer, so no crossfade. Finally, target_duration of 0 means "leave it alone," so a zero that was meant to be a real value silently does nothing. Set it, run it, and the info output will tell you exactly what it validated to.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — | |
| target_duration | FLOAT | 0.000–30 | Precise target duration (0 = use original length) |
| crossfade_duration | FLOAT | 0.50–2 | Crossfade duration between clips |
| queue_id | STRING | main | Queue identifier for multiple audio streams |
| auto_play | BOOLEAN | true | Automatically play when audio changes |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| queued_audio | AUDIO | — |
| conditioning_audio | AUDIO | — |
| info | STRING | — |