Nodes/Network Bending for ComfyUI/Audio Reference Encoder
ComfyUI Node

Audio Reference Encoder

Turn up to four reference tracks into one steerable latent

By DavidPiazza·Created about a year ago·Updated 9 months ago· 0
Audio Reference Encoder
  • vae
  • audio_a
  • audio_b
  • audio_c
  • audio_d
  • combined_latent
  • info
combination_modeattention
weight_a1.00
weight_b1.00
weight_c1.00
weight_d1.00
extract_segmentsfalse
segment_duration2.00

Reference tracks are how every producer actually works, and Audio Reference Encoder is how you bring that habit to latent generation. It takes one to four audio clips, encodes them with a Stable Audio VAE, and merges them into a single combined latent you can then feed to Audio Latent Guidance or Audio Style Transfer. It's the "load my references" node for everything else in this pack's audio half.

How it works

Each AUDIO input goes through the same vae.encode() path - resampled to the VAE's rate, normalized, encoded, and wrapped as a latent. Then the latents get combined with whichever combination_mode you picked: average (plain mean), weighted (mean scaled by the per-input weight_aweight_d), pca (project onto principal components), or attention (learned weighting). attention is the default, and it's the one that tends to give you a blend that's actually usable rather than a wash.

There's a genuinely nice option hiding in here: extract_segments. Flip it on and the node scans each clip, finds the highest-energy window of segment_duration seconds, and uses only that - so a 3-minute track becomes "the loudest, most characteristic 2 seconds." Great for pulling the vibe of a track without dragging in ten minutes of it.

The inputs that matter

  • vae - a Stable Audio VAE, the same one you use elsewhere in the audio workflow.
  • audio_a - required; the first reference.
  • audio_b / audio_c / audio_d - optional references; the node collects however many you plug in.
  • combination_mode - how the refs are merged.
  • weight_aweight_d - per-reference weights (0–2) for weighted mode.
  • extract_segments / segment_duration - the "grab the best bit" option.

Outputs are combined_latent (a LATENT) and info (a LATENT_INFO with the shapes and statistics). The latent is the one you wire into guidance or style transfer; the info output you can largely ignore or inspect.

Installing it

From the DavidPiazza/network_bending pack via ComfyUI Manager ("Network Bending"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/DavidPiazza/network_bending.git

Restart, and install the audio deps (torchaudio, librosa) from requirements-audio.txt - without them every audio node in the pack quietly vanishes.

Where it bites

The classic mistake is mixing references at wildly different sample rates or lengths and wondering why the blend sounds like a warped cassette - encode through the same path (AudioVAEEncode defaults to 44100) so they're comparable. Also, this node doesn't decode anything itself; the combined_latent is only useful if it's feeding guidance or style transfer, or being decoded by AudioVAEDecode. On the plus side, unlike some declared-but-stub nodes in this pack, every mode here is actually implemented - weighted and attention are the useful ones; pca is a fun experiment more than a workflow staple.

Categoryaudio/reference

Inputs (12)

NameTypeDefaultDescription
vaeVAEStable Audio VAE model
audio_aAUDIOFirst reference audio
combination_modeCOMBOattentionHow to combine multiple references
audio_boptAUDIOSecond reference audio
audio_coptAUDIOThird reference audio
audio_doptAUDIOFourth reference audio
weight_aoptFLOAT1.000–2
weight_boptFLOAT1.000–2
weight_coptFLOAT1.000–2
weight_doptFLOAT1.000–2
extract_segmentsoptBOOLEANfalseExtract most characteristic segments
segment_durationoptFLOAT2.000.5–10Duration of segments to extract (seconds)

Outputs (2)

NameTypeDescription
combined_latentLATENT
infoLATENT_INFO