ComfyUI Node

Audio Gain Match

Remove the loudness variable so your A/B test means something

By lucasgattas·Created 12 months ago·Updated 7 months ago· 60
Audio Gain Match
  • audio_ref
  • audio_in
  • audio_matched
  • gain_db
  • ref_level
  • in_level
mode
max_gain_db12.0

Here's the dirty secret of audio comparison: louder wins, every time, whether it's better or not. It's the single most reliable way to fool yourself in this whole hobby - you "enhance" a track, it comes back a hair louder, and your brain reports it as more detailed and clearer when it's really just louder. This node is the fix. It measures the level of your input against a reference and applies the matching gain, so you can finally compare two files on content rather than on perceived volume.

It lives in the Egregora null-test suite, where it plays a specific role: after the alignment node lines up your processed audio with the reference, this node matches levels so the subtraction that follows (the null test) is comparing signal and not level. Use it standalone too, any time you want a fair A/B.

How it works

The mode dropdown picks what "level" means:

  • LUFS-I (default) - integrated loudness, the BS.1770-style perceptual measure. This is the better default for music and anything musical; it matches how loud it feels.
  • RMS - plain root-mean-square level in dB. Simpler and often preferable for technical comparisons where you want a straightforward energy match.

The node computes the reference level and the input level, derives the difference as gain_db, clamps it to max_gain_db (default ±12 dB, range ±48) so you never get a runaway boost, and applies it. If sample rates differ between the two files, it resamples the input to the reference rate first - quietly, with linear interpolation - so the levels are computed on the same time base.

The inputs that matter

  • audio_ref - the file whose level you're matching to.
  • audio_in - the file getting the gain.
  • mode - LUFS-I for perceptual matching, RMS for technical matching.
  • max_gain_db - the safety clamp on how much gain can be applied.

Outputs: audio_matched (the level-corrected audio), plus three FLOATs - gain_db (what was applied), ref_level, and in_level - which are handy to look at once to confirm the match wasn't doing something absurd.

Install and the take

Zero extra dependencies - it's pure NumPy in the null-test suite. The only real gotcha is using it: remember the clamp exists, so if gain_db comes out at exactly ±12 dB, the match didn't fully happen and you may want to raise max_gain_db. And the 1770-named twin in the Eval pack does the same job with a wider range and the same LUFS/RMS modes - pick whichever you remember exists. The important thing is to use one of them before you trust any enhancement A/B.

CategoryEgregora/Analysis

Inputs (4)

NameTypeDefaultDescription
audio_refAUDIO
audio_inAUDIO
modeoptCOMBO2 options: LUFS-I, RMS
max_gain_dboptFLOAT12.0-48–48

Outputs (4)

NameTypeDescription
audio_matchedAUDIO
gain_dbFLOAT
ref_levelFLOAT
in_levelFLOAT