ComfyUI Node

VRGDG_CleanAudio

The normalization step this whole pack assumes — 48kHz, stereo, frame-aligned

By vrgamegirl19·Created about a year ago·Updated 2 days ago· 717
VRGDG_CleanAudio
  • audio
  • AUDIO

Every audio pipeline has a silent assumption, and for the VRGameDevGirl music-video workflow it's this: 48kHz, stereo, snapped to a 25fps frame grid. The set-math nodes compute durations from sample counts, the combine nodes trim scenes to frame counts, and the final mux expects the original audio back in a known shape. If you load an arbitrary mp3 - 44.1kHz mono, or 96kHz - none of that math holds together. This node is the normalization step that makes the rest of the pack trustworthy.

Feed it any AUDIO and it returns the same clip converted to the canonical format: resampled to 48kHz, forced to 2 channels, quantized to 16-bit PCM range, and padded so the total sample count lands exactly on the 25fps frame boundary (1920 samples per frame at 48kHz). It's the "make everything agree" node, and you should put it right after your audio loader and before anything that does math on durations.

How it works

The conversion is methodical, and worth knowing because each step fixes a specific downstream bug:

  • Resample to 48kHz - via torchaudio's resampler. This is non-negotiable for the pack: the frame math (samples_per_frame = 48000 // 25) assumes it.
  • Force stereo - mono gets expanded to two identical channels; >2 channels get downmixed to mono then expanded back. Keeps every downstream node's channel handling simple.
  • 16-bit PCM range - clamps to [-1, 1] and quantizes to 32767 levels. Lossy-ish if your audio was already 16-bit, but harmless in practice and it matches what the final AAC encode expects.
  • Frame-align - pads the tail with silence until the sample count is a multiple of 1920. This is the subtle one: without it, a track that's 1921 samples long would silently push the last scene's duration a frame off.

Output is an AUDIO dict (waveform + sample_rate) in that canonical shape.

The honest caveats

The frame-alignment pads with silence at the end, which adds up to ~1920 samples (40ms at 48kHz) of dead air at the tail. On a 3-minute track that's nothing; if you're doing many cropped segments, it's worth knowing the returned clip is never shorter than the source. Also note "clean" here means formatted, not denoised - this node doesn't remove hiss or background hum despite the name. If you want the audio actually cleaned, that happens in your DAW or a separate denoise step before this node.

Install

Same pack: ComfyUI Manager → search "vrgamedev", or git clone https://github.com/vrgamegirl19/comfyui-vrgamedevgirl into ComfyUI/custom_nodes, restart. Requires the pack's requirements (kornia, librosa, imageio) and torchaudio, which ships with ComfyUI's embedded Python. If you're feeding this pack audio from an unusual source, run this node before anything else in the chain and you'll dodge a whole class of "the durations are off by half a frame" bugs.

CategoryVRGDG/Audio

Inputs (1)

NameTypeDefaultDescription
audioAUDIO

Outputs (1)

NameTypeDescription
AUDIOAUDIO