Nodes/Deforum Nodes/(deforum) Amplitude Time Smoothing
ComfyUI Node

(deforum) Amplitude Time Smoothing

Stop your audio-reactive animation from twitching like a strobe

By XmYx·Created 3 years ago·Updated 3 months ago· 198
(deforum) Amplitude Time Smoothing
  • amplitude
  • smoothed_amplitude
window_size5

Raw amplitude curves from audio are spiky. Every transient, every breath of the vocal, every hi-hat hit shows up as a sudden jump in the waveform - and if you feed that straight into a zoom or translation schedule, your animation jerks around at sample rate instead of moving musically. (deforum) Amplitude Time Smoothing is the little node you put in between the audio analysis and the schedule to fix exactly that. It's a moving average over time: it replaces each value with the mean of its neighbors, which flattens the jitter and leaves you with the broad shape of the music. You rarely notice it's there, but a music-reactive Deforum video without it looks broken.

How it works

The node takes an AMPLITUDE series (any of the pack's amplitude-typed outputs - envelope, beat energy, whatever you extracted) and convolves it with a flat window of window_size samples using numpy. That's textbook moving-average smoothing: each point becomes the average of itself and its window_size neighbors. Bigger window = smoother, more laggy curve; smaller window = closer to the original, still noisy. There's no state here - it's a pure function of the series you hand it, so you can stick it anywhere in the chain and it just reshapes the curve.

The inputs that matter

Only two, and only one of them is a real knob:

  • amplitude - the AMPLITUDE series you want to tame. This is the required input.
  • window_size - integer, default 5, minimum 1. A value of 1 is a no-op (average of one sample is the sample). Values around 5–15 are the sweet spot for music; go higher only if your amplitude series is unusually dense or you want a very lazy, "envelope-like" response.

The single output is smoothed_amplitude, an AMPLITUDE series ready to feed into a schedule-mapping node like (deforum) Amplitude to Schedule or a comparator.

When you actually reach for it

Two situations. First, you've detected beats or an envelope and the raw curve is so noisy that the resulting motion looks like camera shake - drop this node in and the motion starts to breathe with the track. Second, you're about to feed amplitude into something that expects smooth-ish input (like a math expression in Amplitude to Schedule), because sharp discontinuities there produce wild values. One aside worth knowing: don't smooth before you need the timing. Beat times should stay sharp; it's the strength curves you want to smooth. This node smooths values, not timestamps, so keep it on the amplitude path.

Installing it

Part of Deforum Nodes (XmYx). Via ComfyUI Manager search "Deforum Nodes", or:

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

Restart ComfyUI; the first launch runs install.py, which pulls in the heavy deps (librosa, opencv-contrib-python, moviepy, numpy<2.0.0, the deforum-studio backend). Python 3.10 per the README.

Where people get burned

The common trap is over-smoothing: crank window_size to 30+ and your animation stops reacting to the actual beat entirely - you've averaged the music into a gentle drone. Start at the default, nudge up only until the stutter is gone, and don't touch it again. If the output still looks wrong after smoothing, the problem is upstream (bad amplitude extraction), not this node - smoothing can't fix garbage input, it can only make garbage slower.

Categorydeforum/audio

Inputs (2)

NameTypeDefaultDescription
amplitudeAMPLITUDE
window_sizeoptINT5

Outputs (1)

NameTypeDescription
smoothed_amplitudeAMPLITUDE