URN Smart Seamless Audio Extender
Stretch a 30-second loop into three minutes without an obvious seam
- audio_input
- audio
- detected_bpm
- info
- total_dur_out
You generated a great 30 seconds of music. You need three minutes for the video. Naively looping the file gives you an audible jump every 30 seconds - the join is right where a listener's attention lives, so it's the most obvious thing in the track.
URN Smart Seamless Audio Extender (class URNSmartSeamlessAudioLoop) finds an internal loop point where the audio actually matches itself, repeats it with a short crossfade, and reports what it did. It's the most ambitious node in the pack and the one with the most settings, so the honest summary is: three or four of them matter and the rest are for when the defaults don't work.
How it works
Two analysis engines, and the default is the real one.
Advanced (Librosa) estimates BPM from an onset envelope, then extracts log-spectral features across 28 bands at 50 frames per second and hunts for candidate loop pairs - a start point and an end point whose audio content matches. Candidates are scored on correlation and spectral cost and fine-aligned to the sample, beat and meter detection snaps the search to bars rather than a random downbeat, and the winner comes with a confidence score. Advanced (SoXR HQ) is the same path using SoXR resampling for analysis instead of librosa's Kaiser-fast; Basic (V5) is the older, faster matcher with none of that structural analysis.
Then it renders: the loop region repeats to reach output_length, every join is crossfaded, and with crossfade_mode on Auto the overlap is derived from the source, the mode and the BPM rather than being a fixed number - deliberately short, because the node's own notes say an over-long crossfade reads as an obvious dissolve instead of a loop. A final fade-out goes on the end, and peak protection scales the result if a crossfade sum overshoots.
extension_mode is the choice that changes the musical result most. Best Internal Loop builds the whole extension around the strongest loop region, so you may not hear every part of the source. Preserve Full Input plays the complete original once, then loops from the chosen start point after the source reaches its natural end - which is what you want for anything with an intro.
Inputs and outputs
The ones worth setting:
audio_file- a picker for files in ComfyUI's input folder, used only whenaudio_inputisn't connected. A connected AUDIO cable always wins, enforced at validation and at runtime, so changing the upstream Load Audio file doesn't require reconnecting.output_length- target duration in seconds. If you ask for less than the source length, it just trims and no looping happens at all.mode-Musicfor beat/rhythm-aware matching,Ambiencefor texture and seam continuity,Genericwhen it's neither.loop_preference-Auto, or bias toward 4/8/16-bar phrases, orLong Phrasewhen you'd rather have a long repeat than a tight one.search_quality-Fast/Balanced/Thorough(the default recommendation) /Maximum.minimum_loop_seconds(default 8) - stops the search picking a two-second loop that obviously repeats.crossfade_mode/crossfade_seconds- leave Auto unless you're chasing a specific artefact.final_fade_secondsandpeak_protect.
Outputs: audio (the extended result), detected_bpm (a FLOAT, and 0 when BPM isn't meaningful or couldn't be detected - check this before trusting a bar-based loop preference), info (a detailed report: source and output duration, loop start/end, loop duration, crossfade, confidence, analysis details) and total_dur_out.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/Clivey1234/Comfyui_URN_AudioTools
Run install.bat, or install the pack's requirements.txt with ComfyUI's Python - Advanced analysis needs librosa and scipy, and the node raises a clear error naming both if they're missing. If you're stuck without them and want to test the wiring, analysis_engine on Basic (V5) is the lighter path.
ComfyUI Manager: search Comfyui_URN_AudioTools. It appears as URN Smart Seamless Audio Extender under URN Audio Tools.
Common issues
The seam is still audible. Read info and look at the reported confidence before you change anything. A low-confidence match on busy material with long reverb tails is the hard case - no crossfade fixes a loop where the two ends genuinely don't match. Try Long Phrase, drop minimum_loop_seconds, or feed it a shorter, more repetitive source.
detected_bpm is 0. That's the node being honest rather than guessing, and it means the bar-based loop_preference options have no rhythm grid to work with. Switch loop_preference to Auto and mode to Ambience or Generic.
Thorough/Maximum is slow. It is, by definition - larger search effort, more candidates. Fast is roughly the "just give me something" setting, and on simple loops the quality difference is often small. Search quality is the first thing to lower if the node is eating your queue.
The output is quieter than the source. peak_protect scaled the whole result because a crossfade pushed the sum over the limit. Turn it off to keep your levels, but then nothing is stopping the clip from overshooting.
It ignored the file I picked. You have an AUDIO cable connected. The connected input always wins - that's intentional, so swapping the upstream loader's file doesn't leave a stale picker value in play.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| audio_file | COMBO | 1 options: | |
| output_length | FLOAT | 60.001–3600 | — |
| mode | COMBO | Music | 3 options: Music, Ambience, Generic |
| analysis_engine | COMBO | Advanced (Librosa) | 3 options: Advanced (Librosa), Advanced (SoXR HQ), Basic (V5) |
| loop_preference | COMBO | Auto | 5 options: Auto, 4 Bars, 8 Bars, 16 Bars, Long Phrase |
| extension_mode | COMBO | Best Internal Loop | 2 options: Best Internal Loop, Preserve Full Input |
| search_quality | COMBO | Thorough | 4 options: Fast, Balanced, Thorough, Maximum |
| minimum_loop_seconds | FLOAT | 8.00.5–120 | — |
| crossfade_mode | COMBO | Auto (Recommended) | 2 options: Auto (Recommended), Manual |
| crossfade_seconds | FLOAT | 0.060–5 | — |
| final_fade_seconds | FLOAT | 0.500–10 | — |
| peak_protect | BOOLEAN | true | — |
| audio_inputopt | AUDIO | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| audio | AUDIO | — |
| detected_bpm | FLOAT | — |
| info | STRING | — |
| total_dur_out | FLOAT | — |