How to Use FFmpeg sidechaingate Filter

This guide explains how to use the sidechaingate filter in FFmpeg to apply sidechain gating to your audio files. You will learn the basic syntax, the primary parameters that control the gate's behavior (such as threshold, attack, and release), and see practical command-line examples for controlling one audio track's volume using the level of another.

Understanding Sidechain Gating in FFmpeg

A noise gate reduces the volume of an audio signal when it falls below a certain threshold. In sidechain gating, the gate on the main audio channel is opened or closed based on the volume level of a second, separate audio channel (the sidechain/detection signal).

The FFmpeg sidechaingate filter (also accessible via the alias asgated) requires two audio inputs:

  1. First input: The audio signal you want to gate (the primary audio).
  2. Second input: The control signal (the sidechain audio).

Key Parameters

You can customize the filter using several parameters formatted as key=value pairs separated by colons:

  • level_in: Set the input level of the primary audio (default: 1).
  • range: Set the level of reduction when the gate is closed (default: 0.06125). Lower values reduce the quiet parts more drastically.
  • threshold: The signal level of the sidechain input above which the gate opens (default: 0.125).
  • ratio: The reduction ratio (default: 2).
  • attack: The time in milliseconds it takes for the gate to fully open once the sidechain exceeds the threshold (default: 20).
  • release: The time in milliseconds it takes for the gate to close once the sidechain drops below the threshold (default: 250).
  • detection: Choose how the sidechain signal level is detected: peak or rms (default: rms).

Basic Command Syntax

To use the filter, you must use -filter_complex because the filter requires two distinct input streams.

Here is the template command:

ffmpeg -i main_audio.wav -i sidechain_audio.wav -filter_complex "[0:a][1:a]sidechaingate=threshold=0.15:attack=10:release=150[outa]" -map "[outa]" output.wav

Command Breakdown:

  • -i main_audio.wav: Instantiates the first input stream (index 0:a), which is the audio you want to modify.
  • -i sidechain_audio.wav: Instantiates the second input stream (index 1:a), which acts as the trigger.
  • -filter_complex "[0:a][1:a]sidechaingate=...[outa]": Feeds both audio streams into the sidechaingate filter. The output of this filter is labeled [outa].
  • threshold=0.15: Sets the gate to open when the sidechain audio level rises above 0.15.
  • attack=10:release=150: Configures a fast 10ms opening time and a smooth 150ms closing time.
  • -map "[outa]": Tells FFmpeg to write the processed audio to the output file.

Practical Example: Gating Synth Pads with a Kick Drum

A common music production technique is to gate a sustaining synthesizer pad using a transient kick drum. This creates a rhythmic, pumping effect where the synth is only heard when the kick drum hits.

ffmpeg -i pad.wav -i kick.wav -filter_complex "[0:a][1:a]sidechaingate=threshold=0.2:range=0.01:attack=5:release=100[out]" -map "[out]" rhythmic_pad.wav

In this setup:

  • range=0.01 ensures that when the kick drum is silent, the pad is almost completely muted.
  • attack=5 makes the gate open almost instantly when the kick strikes.
  • release=100 allows the pad sound to fade out quickly but smoothly after each kick hit.