Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Add simple 3 band equalizer node for audio. (#12519)

comfyanonymousf262444dd481
diff --git a/comfy_extras/nodes_audio.py b/comfy_extras/nodes_audio.py
index b63dd8e97..7e74169f2 100644
--- a/comfy_extras/nodes_audio.py
+++ b/comfy_extras/nodes_audio.py
@@ -698,6 +698,67 @@ class EmptyAudio(IO.ComfyNode):
create_empty_audio = execute # TODO: remove
+class AudioEqualizer3Band(IO.ComfyNode):
+ @classmethod
+ def define_schema(cls):
+ return IO.Schema(
+ node_id="AudioEqualizer3Band",
+ search_aliases=["eq", "bass boost", "treble boost", "equalizer"],
+ display_name="Audio Equalizer (3-Band)",
+ category="audio",
+ is_experimental=True,
+ inputs=[
+ IO.Audio.Input("audio"),
+ IO.Float.Input("low_gain_dB", default=0.0, min=-24.0, max=24.0, step=0.1, tooltip="Gain for Low frequencies (Bass)"),
+ IO.Int.Input("low_freq", default=100, min=20, max=500, tooltip="Cutoff frequency for Low shelf"),
+ IO.Float.Input("mid_gain_dB", default=0.0, min=-24.0, max=24.0, step=0.1, tooltip="Gain for Mid frequencies"),
+ IO.Int.Input("mid_freq", default=1000, min=200, max=4000, tooltip="Center frequency for Mids"),
+ IO.Float.Input("mid_q", default=0.707, min=0.1, max=10.0, step=0.1, tooltip="Q factor (bandwidth) for Mids"),
+ IO.Float.Input("high_gain_dB", default=0.0, min=-24.0, max=24.0, step=0.1, tooltip="Gain for High frequencies (Treble)"),
+ IO.Int.Input("high_freq", default=5000, min=1000, max=15000, tooltip="Cutoff frequency for High shelf"),
+ ],
+ outputs=[IO.Audio.Output()],
+ )
+
+ @classmethod
+ def execute(cls, audio, low_gain_dB, low_freq, mid_gain_dB, mid_freq, mid_q, high_gain_dB, high_freq) -> IO.NodeOutput:
+ waveform = audio["waveform"]
+ sample_rate = audio["sample_rate"]
+ eq_waveform = waveform.clone()
+
+ # 1. Apply Low Shelf (Bass)
+ if low_gain_dB != 0:
+ eq_waveform = torchaudio.functional.bass_biquad(
+ eq_waveform,
+ sample_rate,
+ gain=low_gain_dB,
+ central_freq=float(low_freq),
+ Q=0.707
+ )
+
+ # 2. Apply Peaking EQ (Mids)
+ if mid_gain_dB != 0:
+ eq_waveform = torchaudio.functional.equalizer_biquad(
+ eq_waveform,
+ sample_rate,
+ center_freq=float(mid_freq),
+ gain=mid_gain_dB,
+ Q=mid_q
+ )
+
+ # 3. Apply High Shelf (Treble)
+ if high_gain_dB != 0:
+ eq_waveform = torchaudio.functional.treble_biquad(
+ eq_waveform,
+ sample_rate,
+ gain=high_gain_dB,
+ central_freq=float(high_freq),
+ Q=0.707
+ )
+
+ return IO.NodeOutput({"waveform": eq_waveform, "sample_rate": sample_rate})
+
+
class AudioExtension(ComfyExtension):
@override
async def get_node_list(self) -> list[type[IO.ComfyNode]]:
@@ -720,6 +781,7 @@ class AudioExtension(ComfyExtension):
AudioMerge,
AudioAdjustVolume,
EmptyAudio,
+ AudioEqualizer3Band,
]
async def comfy_entrypoint() -> AudioExtension: