Nodes/MD Nodes/MD: Mastering Gain
ComfyUI Node

MD: Mastering Gain

The one-knob gain trim for your audio pipeline

By MDMAchine·Created about a year ago·Updated 3 months ago· 15
MD: Mastering Gain
  • audio
  • AUDIO
gain_db0.00

MD_Mastering_Gain is the simplest node in the MD Nodes mastering family, and sometimes that's exactly what you want: a clean volume trim with a single control. In - gain - out. It's the audio equivalent of a plain math node, and it earns its place because the mastering chain needs stages: you don't want to be re-typing gains into the middle of a complex chain when a quiet trim node can sit between EQ and compressor.

Where it fits: AI-generated audio (ACE-Step and friends) often comes out either hot and clipped or timid and quiet, and the first thing you want before any dynamics processing is a known level to work from. Boost here before the compressor so the compressor's threshold means something; cut here if a stage downstream is overloading.

How it works

It takes the AUDIO dict, extracts the waveform, and multiplies the samples by 10^(gain_db / 20) - plain linear gain, no limiting, no normalization, no touch of the stereo image. Positive dB boosts, negative cuts. The output is the same audio dict with adjusted waveform, so it slots anywhere in a signal chain. It doesn't measure anything and doesn't add metadata; it's deliberately boring.

The inputs that matter

There's exactly one real control:

  • gain_db - from -60 dB (near-silence) to +24 dB. Zero is unity, no change.

Input audio in, single AUDIO out, wire to the next stage.

Installing

It ships inside MD Nodes, so install the pack once:

cd path/to/ComfyUI/custom_nodes
git clone https://github.com/MDMAchine/ComfyUI_MD_Nodes.git
cd ComfyUI_MD_Nodes
pip install -r requirements.txt

Or find MD Nodes in ComfyUI Manager and install, then restart. The gain math itself is pure numpy/torch; the heavy audio requirements (soundfile, librosa) matter for the pack's file-loading and saving nodes around it, not for this trim.

Common issues

The honest warning: gain is not loudness. Boosting a quiet track by +10 dB because it "sounds low" is how you end up clipping and then wondering why the limiter is working overtime - the LUFS normalizer in the same pack measures the actual perceived level and is the right tool for "how loud should this be on Spotify." Gain here is for level staging inside the chain. And remember it has no built-in safety: if you trim +24 dB on something already near full scale, you'll clip hard at the next stage. If you need a ceiling, put the limiter or a -1 dBTP LUFS pass after it.

CategoryMD_Nodes/Audio Processing

Inputs (2)

NameTypeDefaultDescription
audioAUDIOAUDIO INPUT
gain_dbFLOAT0.00-60–24GAIN (dB) • Purpose: Boost or cut volume.

Outputs (1)

NameTypeDescription
AUDIOAUDIO