Professional Loop Transition
Make generated clips loop like they were meant to
- audio
- looped_audio
- conditioning_audio
- info
MusicGen is terrible at endings. It generates a clip and then just... stops, mid-tone, with a click you can hear from across the room. ProfessionalLoopTransition is the pack's answer for dance-music workflows: it stitches clips together with beat-aligned crossfades so that the tail of one generation flows into the head of the next like a DJ's mix, not a tape splice. It's the most ambitious node in this pack - and the one with the most knobs.
The core idea is simple: keep the last audio you received, and when new audio arrives, blend the end of the old clip into the start of the new one over a transition that's measured in musical beats, not arbitrary seconds.
How it works
It's stateful. The node holds the previous clip per loop_id (a string id you set; different ids = independent chains), detects when its input changes, and crossfades old→new. Before blending it does a few pro moves, all toggleable:
- DC offset removal - strips the constant offset that causes pops and clicks at cut points.
- Phase alignment - cross-correlates the tail of the old clip with the head of the new one and shifts to minimize phase cancellation, so the two don't fight each other during the blend.
- Auto-normalize - balances levels so the transition doesn't jump in volume.
- Zero-crossing detection - finds natural silent points in the waveform for the cleanest possible cut.
The transition_type input picks the algorithm: beat_match (default - beat-aligned crossfade for rhythmic music), phrase_match (same idea tuned for phrase boundaries), zero_cross (cleanest cuts anywhere), and power_match (matches RMS levels first, best when clips vary in loudness). transition_beats (0.25–8) sets how long the transition lasts in beats - one beat at 128 BPM is ~0.47s. The optional crossfade_curve (linear, equal_power, exponential, s_curve) shapes the fade; equal_power holds perceived volume steady, which is why it's the default.
Outputs: looped_audio (the stitched result), conditioning_audio (the original input, passed through for MusicGen continuation), and info (what transition ran, BPM, and status).
The honest framing
This is a transition between successive generations, not a magic "make this one clip loop forever" button. You feed it a stream - run MusicGen a few times with evolving prompts, or alternate SmoothAudioQueue output into it - and it makes the hand-offs seamless. For the first clip there's nothing to transition to, so it just passes through; the info string will say "First loop - no transition". Expect that.
The inputs that matter
- audio, bpm (60–200, must match your actual tempo), transition_type, transition_beats, loop_id - the core five.
- dc_offset_removal, auto_normalize, phase_align - leave on; they're cheap and they work.
- crossfade_curve - only touch when you hear an actual problem (e.g. s_curve if equal_power sounds phasey).
Install
Same pack, ebrinz/ComfyUI-MusicGen-HF - via ComfyUI Manager (search the pack title) 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. No extra model downloads - this is pure DSP on top of whatever audio you feed it.
Troubleshooting
Choppy transitions → increase transition_beats or switch to zero_cross. Volume jumps → power_match plus auto_normalize. Phasey or hollow blends → keep phase_align on and try equal_power or s_curve. And the classic: your BPM input doesn't match the actual tempo of the audio, so the "beat-aligned" transition lands off-grid anyway. Set bpm to the real tempo of what you generated. If transitions never happen at all, check that you're feeding it changing audio - same input means "Loop maintained", and a fresh loop_id means it forgets everything it knew.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| audio | AUDIO | — | |
| bpm | FLOAT | 128.060–200 | BPM for beat-aligned transitions |
| transition_type | COMBO | beat_match | Type of transition algorithm |
| transition_beats | FLOAT | 1.000.25–8 | Transition duration in beats |
| loop_id | STRING | main_loop | Loop identifier for multiple streams |
| auto_normalize | BOOLEAN | true | Automatically normalize audio levels |
| dc_offset_removal | BOOLEAN | true | Remove DC offset before transitions |
| crossfade_curveopt | COMBO | equal_power | Crossfade curve type |
| phase_alignopt | BOOLEAN | true | Align phases for smoother transitions |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| looped_audio | AUDIO | — |
| conditioning_audio | AUDIO | — |
| info | STRING | — |