(deforum) Amplitude Spectral Centoid
One Number That Tells You How 'Bright' the Track Is
- audio_fft
- spectral_centroid
Every mix has a "center of mass" in frequency terms - the point where the energy balances out between the bass rumble and the high hats. (deforum) Amplitude Spectral Centoid - yes, that's the author's own spelling, "Centoid" - computes that balance for a track and hands it back as a single number. It's a brightness meter for your audio: dark, muffled music gives a low centroid; airy, cymbal-heavy music gives a high one.
It's one of the audio nodes in XmYx's Deforum Nodes pack, the ComfyUI port of the animation engine that dominated A1111's extension era from late 2022 (the KB's ui-history essay tracks that history). Like its siblings it expects the pack's AUDIO_FFT type from the surrounding audio ecosystem - the README's companion list points at ComfyUI-AudioScheduler for audio loading.
How it works
The calculation is the textbook definition: take the magnitude spectrum, weight each frequency by its magnitude, and divide the sum of those weighted frequencies by the total magnitude - sum(frequencies * magnitudes) / sum(magnitudes). Frequencies run from 0 up to half the sample rate (the Nyquist limit), and magnitudes are normalized by the FFT length first.
The thing to understand is the granularity: this node returns one FLOAT for the whole clip, not a per-frame series. That makes it a track-level descriptor rather than a reactive control signal. Its realistic use is gating or tagging - "this track is bright, so lean the animation palette one way" - not frame-accurate camera motion. Don't try to wire it into an amplitude-to-schedule node; it isn't an amplitude.
Input and output
- audio_fft (AUDIO_FFT) - the only input.
- spectral_centroid (FLOAT) - the single output.
Installing it
Same pack as everything else:
cd ComfyUI/custom_nodes
git clone https://github.com/XmYx/deforum-comfy-nodes.git
Restart, or use Manager → "Deforum Nodes" by XmYx. Standard pack warnings: heavy install (deforum-studio from git, librosa, moviepy, av, pydub, opencv-contrib, numpy<2.0.0), Python 3.10 per the README.
Common issues
Here's the honest catch, and it's visible in the source: the AUDIO_FFT type is used inconsistently across the pack. The dominant-note extractor iterates over audio_fft as a list of per-frame FFT objects; this node treats it as a single FFT object and calls np.abs(audio_fft) directly. Depending on what's actually upstream, it can crash or silently produce a meaningless number. These audio nodes are clearly experimental - there are no audio examples in the pack's examples folder, and the community workflows live on the Deforum Discord. If the node throws, the fix usually isn't in the node; it's in the inconsistency between the audio nodes themselves. And the standard pack-level failure - an orphaned A1111 deforum pip package - is still your first stop if nothing loads: pip uninstall deforum, then retry.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| audio_fft | AUDIO_FFT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| spectral_centroid | FLOAT | — |