Crates.io | ladspa_noisecoring |
lib.rs | ladspa_noisecoring |
version | 1.0.0 |
source | src |
created_at | 2018-04-07 13:01:10.557264 |
updated_at | 2018-04-07 13:01:10.557264 |
description | A LADSPA noise reduction filter. |
homepage | https://bitbucket.org/jmb/ladspa-noisecoring |
repository | |
max_upload_size | |
id | 59412 |
size | 155,462 |
This is a LADSPA high quality noise reduction plug-in. It can be used by any LADSPA-enabled audio processing application. It is able to remove most types of continuous noise from audio signals, including blue, white, pink and brown noise.
This plug-in is copyright ⓒ2011-2018 Jérôme M. Berger and released under the terms of the GNU LGPLv2.1. You should have found a copy of the license along with this plug-in, or you can find it here.
The plug-in exposes the following parameters:
Reduction amount (dB)
– Amount by which the noise will be reduced.Noise level (dB)
– Noise level (see Noise model).Noise shape (dB/decade)
– Noise shape in decibels per decade (see
Noise model).Filter length
– Filter length. This parameters affects the balance
between resolution in time and resolution in frequency. Small values
give better time resolution, while large values give better
frequency resolution. This should preferably be set to a power of 2.Residual output
– If this is enabled, the filter effect will be
reversed: instead of removing the noise, the filter will keep only
the noise. This can be used to check that you are not removing part
of the signal along with the noise.Automatic noise model
– If this is enabled, estimate the Noise level
and Noise shape
parameters from the input signal. The
values given to these parameters through the input ports are
ignored.Automatic reactivity
– Speed at which the automatic noise shape
adjusts to changes in the input noise. Smaller values mean that the
filter is more stable but adapts more slowly to changes (at the
extreme, if this is 0, then the filter will estimate the parameters
from the first window and doesn't adapt if the noise changes). With
larger values the filter adapts faster, which may caus artefacts as
the filter changes. Note that the default value of 0.25 make for a
very stable filter that is still able to adapt to changes in only a
few milliseconds (less than 20ms at 44kHz with a filter length of
4096).Fast mode
– If this is enabled, the filter will only overlap two
windows instead of four. This causes the filter to run twice as
fast, but may cause a slight degradation in output quality.Note: The automatic noise model is pretty conservative and tends to underestimate the noise level. Don't hesitate to increase the reduction amount when the automatic model is enabled (increasing the amount by 4dB is reasonable in this situation).
The filter relies on a simple noise model to determine which part of the signal is noise and which part is legitimate signal. The noise model assumes that noise will have level $l_n(f)$ in dB at frequency $f$ with:
$$l_n(f)=L-shape\times\log\left(\frac{f}{f_0}\right)$$
where:
The plug-in is real-time compatible provided that the Filter length
parameter does not change.
The plug-in assumes that any frequency whose level is significantly greater than the modelled noise level is mostly signal and should be preserved. Conversely, any frequency whose level is close to or lower than the modelled noise level is mostly noise and should be removed. Therefore the plug-in builds a dynamic equalisation filter whose frequency response depends on the input at any given point in time.
The ideal frequency response is given by:
$$g(f)=1-e^{-\frac{l(f)}{s(f)}}$$
where $l(f)$ is the input level at frequency $f$ and $s(f)$ is the filter strength at that same frequency. This gives a response of 1 for large input levels, which are mostly signal, and a value of 0 for small input levels, which are mostly noise.
The strength $s(f)$ is computed from the modelled noise level $l_n(f)$ and the desired reduction amount $a$ in such a way that the response will be equal to $a$ if the measured level is equal to the modelled noise level:
$$1-e^{-\frac{l_n(f)}{s(f)}}=a$$
solving for $s(f)$ gives:
$$s(f)=-\frac{l_n(f)}{\ln(1-a)}$$
This ideal response is then dilated by an amount $\delta_f$ that depends on the filter length. This dilation ensures that narrow-band signals will be preserved by the windowing. As an unfortunate side-effect this also preserves noise at frequencies close to the signal. However this is not an issue in practise because psycho-acoustic effects mean that the signal will mask most of the preserved noise. The dilated response is given by:
$$g_d(f)=\max_{|\phi-f|<\delta_f}g(\phi)$$
Finally the dilated response is windowed in order to avoid the Gibbs phenomenon.
In order to apply the filter, the input signal is divided in windows of size twice the filter length (rounded up to the next power of two). Each window is then analysed to create the equalisation filter and this filter is applied to the signal. In fast mode each window is overlapped by half its length with the previous one. In standard mode, four windows are overlapped. In either case, the outputs are mixed to ensure a smooth transition between equalisation filters.
When using the automatic noise model, each window is analysed to guess the noise level and noise shape. The analysis is a two steps process:
In order to create the rough noise model, the plugin looks at local minimas of the spectrum, i.e. frequency bands whose amplitude is less than the immediately preceding and following bands. Those frequency bands are assumed to be mostly noise and so suitable for building our noise model. The plugin searches for two such bands, one at the low end of the spectrum ($l(f_l)$) and the other at the high end of the spectrum ($l(f_h)$), then builds the rough noise model from those two bands:
$$l^{(r)}_n(f)=\frac{l(f_h)-l(f_l)}{log(f_h)-log(f_l)}(log(f)-log(f_l))+l(f_l)$$
In order to increase robustness of the model, the plugin looks at the first three local minimas at the low end of the spectrum, and at the last three local minimas at the high end of the spectrum and keeps the band with the middle level in each group of three.
The refined model is created through linear regression of the spectrum in the loglog domain, keeping only the frequency bands such that $l(f)<l^{(r)}_n(f)+M$ (where $M$ is set to 10dB).