Nodes/ComfyUI_Yvann-Nodes/Audio Peaks Detection
ComfyUI Node

Audio Peaks Detection

Finding the beats so you can cut on them

By yvann-ba·Created 2 years ago·Updated 6 months ago· 708
Audio Peaks Detection
  • audio_weights
  • peaks_weights
  • peaks_alternate_weights
  • peaks_index
  • peaks_count
  • graph_peaks
peaks_threshold0.40
min_peaks_distance5

Audio Analysis gives you a weight curve - a float for every frame. Audio Peaks Detection is what turns that smooth curve into discrete events. It finds the frames where the music hits - the kick, the drop, the big transient - and hands you a list of "here, cut right now" moments to trigger transitions, swap prompts, or switch images.

It's the glue between "measure the audio" and "make the visuals react," and it's dead simple to use.

How it works

The node takes your audio_weights and runs them through scipy.signal.find_peaks, a classic peak-finding routine. A frame counts as a peak when it's a local maximum sitting above peaks_threshold, and it has to be at least min_peaks_distance frames away from its neighbors.

Two knobs, and they do exactly what you'd expect:

  • peaks_threshold (default 0.4) - minimum height. Raise it to only fire on big transients like chorus drops; lower it to catch every hi-hat tick. If you're getting peaks on noise, this is the knob to turn.
  • min_peaks_distance (default 5) - minimum gap between peaks, in frames. Kick drums don't produce a single clean hit; they smear across a few frames. This distance collapses that smear into one event. Cranking it to 20+ means peaks only fire on genuinely separate musical phrases.

The outputs

Five of them, and three are genuinely useful:

  • peaks_weights - a binary list, 1 at peak frames, 0 everywhere else. This is the one you feed into Audio IPAdapter Transitions to trigger image changes on the beat.
  • peaks_alternate_weights - same binary list, but the value toggles each time a peak fires: 0, 0, 1, 1, 0, 0, 0, 1... It's an A/B pattern. Handy when you want to alternate between two looks on successive beats instead of jumping through a whole sequence.
  • peaks_index - the peak frame numbers as a comma-separated string, e.g. "0, 24, 53, 91". Wire this into Audio Prompt Schedule to attach a different prompt to each beat.
  • peaks_count - how many peaks were found. Useful as a sanity check (and for driving loop counts).
  • graph_peaks - a matplotlib preview with red dots on the detected peaks, so you can eyeball whether your threshold is sensible before wiring anything downstream.

A quirk worth knowing

The node prepends 0 to the peaks index list - so the first frame is always in the list, and peaks_count counts that extra entry. A track with three real beats reports a count of 4. It doesn't break anything (the transitions and scheduling nodes handle it), but it will trip you up the first time you see a count that's one higher than you expected. Now you know.

When to reach for it

If your audio-reactive video is "image jumps to a new image on every beat," this node is the trigger. Keep Audio Analysis → Audio Peaks Detection as the front half of any event-driven workflow, then hang Audio IPAdapter Transitions or Audio Prompt Schedule off the back. Same install as the whole pack - ComfyUI Manager search "ComfyUI_Yvann-Nodes", or:

cd ComfyUI/custom_nodes
git clone https://github.com/yvann-ba/ComfyUI_Yvann-Nodes

Restart, wire audio_weights in, and start with the defaults - 0.4 threshold and 5-frame distance are sane for most tracks.

Category👁️ Yvann Nodes/🔊 Audio

Inputs (3)

NameTypeDefaultDescription
audio_weightsFLOATSAudio weights from Audio Analysis node
peaks_thresholdFLOAT0.400–1Minimum height for peak detection (0-1)
min_peaks_distanceINT51–100Minimum frames between peaks (removes close unwanted peaks)

Outputs (5)

NameTypeDescription
peaks_weightsFLOATS
peaks_alternate_weightsFLOATS
peaks_indexSTRING
peaks_countINT
graph_peaksIMAGE