Onset Gate

Overview

onset_gate is a specialization of noise_gate that adds a slope guard for gating out slow attacks. It has two independent thresholds:

onset_threshold

An absolute level, as in noise_gate.

slope_threshold

The required envelope rise over attack_width.

The gate opens if the signal is either unambiguously loud or rising fast:

  • open if env > onset_threshold OR slope(env) > slope_threshold

Above onset_threshold the level alone opens the gate at once, so a loud note need not wait for (and clip) its attack. Below it, the slope guard governs: only a fast rise passes, so slow moving signals such as noise or bleed are rejected. Release is unchanged: the gate closes when the level drops below the release threshold.

The constructor parameters attack_width and sps specify the slope’s delta time. For example, given an attack width of 500 µs and a slope threshold of -30 dB, the difference in amplitude over a period of 500 µs must exceed -30 dB to pass the slope guard.

Include

#include <q/fx/onset_gate.hpp>

Declaration

struct onset_gate : noise_gate
{
               onset_gate(
                  decibel onset_threshold
                , decibel slope_threshold
                , decibel release_threshold
                , duration attack_width
                , float sps
               );

   using noise_gate::operator();

   bool        operator()(float env);

   void        slope_threshold(decibel t);
   float       slope_threshold() const;
};

Expressions

As a subclass of noise_gate, onset_gate inherits all the publicly accessible member functions, member variables, and types of its base class.

In addition to valid expressions for noise_gate, onset_gate allows these expressions.

Notation

g

Object of type onset_gate.

ot, rt

Object of type decibel representing onset (level) and release thresholds, respectively.

st

Object of type decibel representing the slope threshold.

aw

Object of type duration representing attack width.

sps

Floating point value representing samples per second.

Constructor

Expression Semantics

onset_gate(ot, st, rt, aw, sps)

Construct an onset_gate with the specified onset (level) threshold, ot, slope threshold, st, release threshold, rt, attack width, aw, and samples per second, sps.

C++ brace initialization may also be used.

Slope Threshold

Expression Semantics

g.slope_threshold()

Get the current slope threshold as a linear (non-decibel) value.

g.slope_threshold(st)

Set the slope threshold to st.