Expand description
The spectral gating engine shared by profile and adaptive modes. It follows the PRD’s seven steps:
- STFT with a periodic Hann window (2048 samples at 44.1/48 kHz, scaled with the
sample rate), 75% overlap,
f32. - Noise statistics per bin: from the profile (mean and std of the magnitude in dB), or in adaptive mode from a minimum-statistics tracker (Martin 2001) with no profile.
- Threshold
mean + sensitivity × std. The mean is put on the power scale (mean of dB plus 2.51 dB for Gaussian noise, less for steadier noise) and the std is divided by 5.57 dB, the spread of Gaussian noise in dB (with a 2.5 dB floor so steady hum still gets a margin). So--sensitivity 6puts the threshold 6 dB above the mean power of steady hiss, and proportionally higher for noise that fluctuates more. Each bin’s level is compared with its threshold and mapped through a soft sigmoid (centred 1.5 dB above the threshold, 1.5 dB wide) to a gain between 0 dB and-reduction. - The mask is smoothed across frequency (a 3-bin morphological opening removes isolated
open bins narrower than a window main lobe, then a Hann-weighted average over
±smoothingbins adds soft skirts without pulling partials down) and in time (a lookahead maximum overattackworth of frames, then slew limits: the gate opens through the full range inattackand closes inrelease), so onsets are never clipped. --artifact-controlblends a 3×3 (time × frequency) median of the mask into it and fills spectral troughs up to a steady floor-reductionbelow the minimum-statistics noise estimate. Both remove the random flicker of gated noise (“musical noise”) at the cost of a little more residual noise.--link oncomputes one mask from the channel-mean power;--preserve-transientsdetects onsets (spectral flux of the above-threshold bins, adaptive threshold, local maximum) and holds the gate open around them with the threshold lowered to the noise mean and instant attack.- Inverse STFT with overlap-add (Hann² sums to exactly 1.5 at 75% overlap). With
--reduction 0dBevery gain is exactly 1.
The engine streams: it holds a constant number of frames (input ring, lookahead queue, overlap-add accumulator) regardless of input length.
Structs§
- Engine
- Streaming spectral gate.
- Engine
Stats - Statistics gathered while processing (for metrics).
- Gate
Config - Parameters of the gate (PRD defaults in
Default). - MinStats
- Minimum-statistics noise power tracker (after Martin 2001): smoothed periodogram, minimum over a ~1.5 s window kept as U sub-window minima, and bias compensation.
Enums§
- Noise
Model - Where the noise estimate comes from.
Constants§
- RAYLEIGH_
LOG_ BIAS_ DB - Mean of 10·log10 of an exponential variable is 2.507 dB below 10·log10 of its mean.
- RAYLEIGH_
STD_ DB - Standard deviation of 10·log10 of an exponential variable (Rayleigh magnitude in dB).
Functions§
- log_
bias_ db - Mean-of-log bias for a noise whose dB spread is
std_db: 2.507 dB for Gaussian noise (Rayleigh magnitudes, spread 5.57 dB), shrinking towards 0 for steady tones.