Nodes/Deforum Nodes/(deforum) ExtractDominantNoteAmplitude
ComfyUI Node

(deforum) ExtractDominantNoteAmplitude

Drive Your Animation From the Melody, Not the Noise

By XmYx·Created 3 years ago·Updated 3 months ago· 198
(deforum) ExtractDominantNoteAmplitude
  • audio_fft
  • dominant_note_amplitude
  • phase_amplitude
min_frequency20
max_frequency8000
magnitude_threshold0.01
smoothing_window_size5

Most audio-reactive animation keys off overall loudness, which means a bass-heavy track sends every value through the roof and your camera barely notices the melody. (deforum) ExtractDominantNoteAmplitude takes the opposite approach: instead of summing the whole spectrum, it finds the single strongest note in a frequency window at each moment and tracks that. The result is an amplitude curve that follows the lead instrument or vocal line rather than the wall of sound around it.

This is one of the audio-sync nodes in XmYx's Deforum Nodes pack - the ComfyUI port of the animation engine that ruled A1111's extension scene from late 2022 (the KB's ui-history essay covers that era in detail). It operates on the FFT data produced by the pack's surrounding audio ecosystem rather than raw audio.

How it works

It walks through the FFT frames of your track and, for each one:

  1. Cuts the spectrum down to the frequency band you care about - that's the min_frequency/max_frequency pair.
  2. Smooths the magnitudes with a Savitzky–Golay filter if smoothing_window_size is big enough (this is why the window must be an odd number; the filter has a parity constraint baked in).
  3. Zeros out any magnitude below magnitude_threshold - cheap noise gate.
  4. Finds the loudest remaining bin and records its magnitude and phase.

Outputs are two same-length series: dominant_note_amplitude (the loudness of the strongest note per frame) and phase_amplitude (that note's phase). The phase output might look like trivia, but it's the second half of the round trip - pair it with the pack's InverseFFT node and you can resynthesize a signal after playing with the spectrum.

The inputs that matter

  • audio_fft (AUDIO_FFT) - required; comes from the FFT stage upstream in the Deforum audio chain.
  • min_frequency / max_frequency - the band to search. Default 20–8000 Hz already trims the inaudible top end. To track a bassline, drop max to ~250; for vocals, 300–3000. This is the knob that makes the node feel magical or useless.
  • magnitude_threshold (default 0.01) - kills rumble and room tone that would otherwise win on quiet frames.
  • smoothing_window_size (default 5, must be odd, max 101) - smooths the magnitude curve before picking the peak, which stops the "dominant note" from flickering between two nearly-equal bins.

Installing it

Part of the Deforum Nodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/XmYx/deforum-comfy-nodes.git

Restart, or install via Manager → "Deforum Nodes" by XmYx. As with everything in this pack, it's a heavy install: deforum-studio from git, librosa, moviepy, av, pydub, opencv-contrib, and a numpy<2.0.0 pin, on Python 3.10 per the README. There are no audio examples in the pack's examples folder - expect to build your chain from the audio nodes the README recommends as companions and the community Discord.

Common issues

The two things that bite people: a smoothing_window_size that's even (the Savitzky–Golay filter just throws an exception, silently caught, so you get no smoothing and no error - confusing), and a max_frequency set below the actual note you're chasing, which makes the node track the loudest thing that happens to be in the wrong band. Start with the defaults, then narrow the band to what you actually hear. And if the pack refuses to load at all, check for an orphaned A1111 deforum package (pip uninstall deforum) - it's the pack's most common install failure.

Categorydeforum/audio

Inputs (5)

NameTypeDefaultDescription
audio_fftAUDIO_FFT
min_frequencyoptFLOAT200–20000
max_frequencyoptFLOAT80000–20000
magnitude_thresholdoptFLOAT0.010–1
smoothing_window_sizeoptINT51–101

Outputs (2)

NameTypeDescription
dominant_note_amplitudeAMPLITUDE
phase_amplitudeAMPLITUDE