Noise Gate — v1.2 User Guide

Performance‑optimised noise gate with attack, release, hold time, range control, and hysteresis for click‑free gating. v1.2 features a major speed rewrite: gate logic runs at 1000 Hz instead of audio SR (≈44× fewer iterations), with envelope resampled via sinc interpolation.

Author: Shai Cohen Affiliation: Department of Music, Bar‑Ilan University, Israel Version: 1.2 (2025) – Performance rewrite License: MIT License Repo: GitHub
Contents:

What this does

Noise Gate v1.2 attenuates a signal when its level falls below a user‑defined threshold. It includes standard studio‑gate features:

v1.2 performance rewrite:
  • Gate logic now runs at 1000 Hz instead of audio SR. For a 44.1 kHz file, this gives ≈44× fewer loop iterations – the dominant speed‑up.
  • Hold loop is O(n) single‑pass counter, not O(n·hold) nested loops.
  • Attack/release filtering also runs at 1000 Hz; transitions are refined by sinc interpolation during resample.
  • Gate envelope is resampled to audio SR with Praat's built‑in sinc (C‑speed, not scripted).

Quick start

  1. In Praat, select exactly one Sound object.
  2. Run script…Noise_Gate.praat.
  3. Choose a Preset:
    • Gentle (speech), Medium (vocals), Tight (drums), Aggressive (noise removal), Ducker (inverse gate), Tremolo Gate
  4. For custom mode (preset = Custom), adjust parameters as desired:
    • Threshold_dB – level to open the gate.
    • Hysteresis_dB – offset below threshold at which the gate closes.
    • Attack_ms, Hold_ms, Release_ms – timing.
    • Range_dB – attenuation when closed.
    • Sidechain_filter – off, HP 100 Hz, HP 200 Hz, or band 1–5 kHz.
  5. Click OK. The script analyses the sidechain, builds a gate envelope at 1000 Hz, resamples it, applies to the audio, and imports the result as originalname_gated.
Tip: Start with Medium (vocals) for a general‑purpose gate. For drums, use Tight (fast attack/release). For an inverse “ducking” effect, try the Ducker preset (range ‑12 dB).
Important: This effect is implemented entirely in Praat – no Python required. The gate envelope is built at 1000 Hz for speed, then resampled with sinc interpolation, ensuring smooth, click‑free transitions.

The 6 presets (+ Custom)

PresetThreshold (dB)Hyst (dB)Attack (ms)Hold (ms)Release (ms)Range (dB)Description
Gentle-3542100150-40Soft, slow gate for speech.
Medium-30315080-60Balanced for vocals.
Tight-2520.52030-80Fast, for drums/percussion.
Aggressive-2020.31020-80Hard noise removal.
Ducker-2535100200-12Inverse gate – gentle level drop.
Tremolo Gate-2011510-80Very fast, rhythmic chopping.

Parameters & defaults

Threshold & hysteresis

ParameterRangeDefaultDescription
Threshold_dB‑∞ … 0-30 dBLevel above which the gate opens. Measured from the peak intensity of the sidechain.
Hysteresis_dB≥03 dBGate closes at threshold – hysteresis. Prevents rapid toggling near threshold.

Timing

ParameterRangeDefaultDescription
Attack_ms≥01 msTime for the gate to open fully after threshold is exceeded.
Hold_ms≥050 msMinimum time the gate stays open after signal drops below close threshold.
Release_ms≥050 msTime for the gate to close after hold period.

Range & sidechain

ParameterRangeDefaultDescription
Range_dB‑∞ … 0-80 dBAttenuation when gate is closed. -80 dB = full silence, -6 dB = light reduction.
Sidechain_filterOff / HP 100 / HP 200 / Band 1‑5 kHzOffFilter applied to the sidechain signal before level detection. Useful for frequency‑dependent gating (e.g., triggering on kick drum).

Output

ParameterDefaultDescription
Normalize_outputyesScale output peak to 0.95 (‑0.5 dBFS). Disable to preserve absolute levels.
VisualizeyesShow input, gate envelope, and output waveforms.
PlayyesAuto‑play after processing.

Performance optimisations (v1.2)

⚡ Speed rewrite details

  • Gate logic at 1000 Hz: Instead of processing every audio sample (e.g., 44,100 Hz), the envelope is built at 1000 Hz – ≈44× fewer iterations for the state machine, hold, and attack/release loops.
  • Hold as O(n) counter: Previously, the hold was implemented with a nested loop scanning hold_samples for each sample – O(n·hold). Now a single counter tracks how many samples remain open, making hold O(n).
  • Attack/release coefficients: Exponential smoothing at 1000 Hz uses pre‑computed coefficients; the smooth curve is later refined by sinc interpolation during resampling.
  • Sinc resampling: The 1000 Hz envelope is upsampled to audio SR using Praat’s built‑in Resample with 50 Hz bandwidth – a C‑level sinc interpolation that is extremely fast and accurate.
  • Direct intensity lookup: Removed per‑sample object() interpolation; uses Get value in frame for direct, fast lookup from the Intensity object.

For a 10‑second file at 44.1 kHz, processing time drops from several seconds to well under one second.

Visualization (Praat picture)

When Visualize = 1, the script draws:

Tip: The gate envelope plot is the key diagnostic: it shows exactly when the gate opens (green rising to 1) and closes (falling to range_lin). The open percentage is calculated from the mean envelope value.

FAQ / troubleshooting

Gate is not closing fully / signal still present when closed

Check Range_dB: if set to a mild value (e.g., -6 dB), the closed gain is 0.5 (–6 dB), not silence. For full silence, set to -80 dB or lower. Also ensure the sidechain filter is not removing all energy – if the filtered sidechain is near‑zero, the gate may never open.

Gate chatters / opens and closes rapidly

Increase Hysteresis_dB – a larger offset between open and close thresholds prevents rapid toggling. Also try increasing Hold_ms to keep the gate open longer after the signal drops.

Attack/release sound “zippery” or stepped

The envelope is built at 1000 Hz and then sinc‑resampled – this should be extremely smooth. If you hear steps, it may be a bug; please report it. The exponential smoothing coefficients (exp(-4.6 / samples)) ensure a 98 % transition in the given time.

Understanding open percentage

The gate activity percentage is computed as (gateMean - range_lin) / (1 - range_lin) × 100. A value of 50 % means the gate was half‑open on average – useful for assessing how much of the signal passed through.

Sidechain filter

The sidechain is filtered before level detection. For example, to gate based on kick drum, use HP 100 Hz to isolate low frequencies. The filter is applied using Praat’s Filter (pass Hann band) with a 50 Hz transition width.

Ducker preset

The Ducker is an inverse gate: it opens when the signal is below threshold and closes when above. This is achieved by setting range_dB to a moderate value (‑12 dB) and using the same logic – the gate still opens above threshold, but because the range is small, the effect is a gentle level drop rather than silence.