I'm interested in active noise cancellation algorithms. Delving into the details of the implementation, the spectral subtraction is performed "on the fly."

There is a certain noise profile and a small record length from which this noise needs to be removed ("subtract").

So I have a question about a specific spectral subtraction algorithm: how is it performed and, in fact, over what? In general terms, I imagine this as the subtraction from the spectrum (frequency correspondence to amplitudes of harmonics) of a noise spectrum signal and the inverse Fourier transform. In general, it seems that the FFT used here does not correspond to frequencies, but simply an array of complex numbers. How can I read what I can’t imagine ...

PS: No need to give links to courses on sound processing and spectral analysis of signals. Just a question - just a clear answer.


There are such specialized programs as, for example, Noise Gator. So, if anyone knows, tell me what noise reduction algorithms are used by them (in particular, whether spectral subtraction is used; if so, where does the program take the noise impression).

  • This is where makseq.com/data/rd/Adaptive%20Noise%20Reduction%20(R1).pdf in section 4.1 (3 pages) is written at the level of understanding available for the third year of cooking school. - - Alexander Muksimov
  • The proposed procedure is as follows: perform the signal stft and noise, draw a noise by obtaining average Fourier transforms for each frequency among all signal windows, subtract the noise spectrum from the amplitude spectrum of the signal (replace negative results with zeros), and perform the inverse transformation. As a method of dealing with "musical noise" use the method of recursive smoothing over time. - D .Stark
  • Well. It is not quite clear exactly how to execute stft. For a start, the signal is cut into windows - how many of these windows should be divided? What should be taken into account? What kind of conversion to perform on each window? Fft? - D .Stark
  • The result of the FFT is an array of complex numbers. What amplitude spectrum are we talking about? - D .Stark
  • Maybe I misunderstood the meaning of the result of the FFT itself a little ... Is it true that this resulting array of complex numbers contains both information about the amplitude and phase spectra? In the case of the amplitude spectrum that interests us, you just need to calculate the modulus of the complex number (sqrt (a ^ 2 + b ^ 2)). - D .Stark


2 answers 2

Algorithms for noise removal can not be considered without deepening in mathematics, acoustics and the theory of spectral analysis of signals.

Any analysis of the signal using Fourier transforms assumes that the signal is stationary in the segment under study. Therefore, if the signal is non-stationary, it is divided into separate segments, called windows. The choice of window size depends on the type of signal under study, usually around 25-50 ms for an audio signal (smaller values ​​for human speech, large ones for music, especially consisting of stringed stringed instruments). You can use overlapping windows to improve the accuracy of the analysis.

However, it is impossible to simply apply the Fourier transform to the cropped windows, and the boundary regions of the segments are incorrectly processed. To solve this problem, the signal is pre-multiplied by a special weight function ("window"). For examples of window functions, see the Fourier Window Transform article .

Next, the Fourier transform is performed directly. It results in a signal spectrum, i.e. the value of the complex amplitude for different frequency ranges. From it, and it is necessary to subtract the noise spectrum. From the module of the complex amplitude of the signal is subtracted the module of the complex amplitude of the noise, multiplied by a certain coefficient; if the result is negative, it is replaced by zero. Phase component is left untouched. To the result of the subtraction, you can apply the inverse Fourier transform, and get a "cleaned" signal.

The final noise reduction algorithm in the presence of a known noise pattern:

  1. Splitting the signal into windows

  2. Applying window Fourier transform to windows

  3. Subtracting (modulo) the amplitude spectrum of the noise from the signal amplitude spectrum:

A = Max (A p. - k * A sh.; 0)

where k is the coefficient chosen experimentally

  1. Applying the inverse Fourier transform to the result

Window size, window overlap, type of window function used are selected empirically.

Links

Removing noise from audio using Fourier transform in Matlab

How can I choose an Fourier Transform window?

How to select the FFT?

  • k is the coefficient chosen experimentally - in what interval of values ​​should it be? Approximately at least. - D .Stark
  • Applying the inverse Fourier transform to the result — you can find a lot of FFT implementations in the network, which is not true for the inverse transform. You will not have any references to examples of the implementation of the inverse FFT, where the function is simply an array of complex numbers (well, our processed array)? - D .Stark
  • At the expense of subtracting the spectrum of the amplitude of the noise from the spectrum of the amplitude of the signal: based on the fact that we have a representation of the FFT signal as an array of complex numbers, the amplitude of the signal is the modulus of the complex number, and the phase is the argument; so, speaking of your formula, it seems like you need not to subtract, but multiply (use of a digital filter). Let's proceed from the fact that we have 2 complex numbers - one of the FFT of the noise signal, the other of the FFT of the signal being processed. What to do with them? - D .Stark
  • one
    @ D.Stark "you can find a lot of implementations of FFT on the network, but we can’t say anything about reverse conversion" fftw.org - MSDN.WhiteKnight
  • one
    @ D.Stark coefficient k is determined by how the loudness of the noise sample and the volume of the sound being processed correspond. If it is about the same, then 1. If the noise in the sample is too quiet, then it is greater than one. - MSDN.WhiteKnight

You already asked this question, and I answered. I will try to answer better than last time.

WINDOW

Let the noise be the sine (the guidance of the power supply network, for example). We photograph a fragment of noise in order to obtain its spectrum using the FFT algorithm:

enter image description here

It seems to be a sine, but in fact it is this: enter image description here

A sharp drop in red is a very strong distortion. If you listen to this in headphones with your ears, you will realize that this is not the noise that you want to subtract from your signal. To reduce distortion, a window is applied (do not eliminate, because the window itself distorts the signal):

enter image description here

Result of using the window:

enter image description here

It was a work with a noise sample.

Now you can perform FFT on this noise sample and get its spectrum. Further, on each input block of the signal, you can also perform an FFT and get its spectrum.

What happens if you try to subtract at each frequency the absolute value of the noise spectrum from the absolute value of the signal spectrum. It turns out that this operation corresponds in principle to multiplying the spectrum of a given signal block by some other spectrum, that is, applying a digital filter. Only for the next block of the input signal will this filter be different. As a result, the situation will be approximately the same as in the second picture - gaps on the block boundaries.

Personally, I came out of this situation as follows: I applied both filters to the signal block at once and interpolated the result linearly, that is, only the first filter acted in the first point of the signal block, only the second filter in the last point, and so linearly.

  • It turns out that the application of the window function is performed not to the spectrum, but to the signal itself. How is this action performed in practice? What to "multiply"? - D .Stark
  • the operation basically corresponds to multiplying the spectrum of a given signal block by some other spectrum, that is, applying a digital filter - Well, what multiplies what is in the spectrum? By indexes multiply fft arrays of complex numbers of signal and noise? Only for the next block of the input signal will this filter be different - Should it be different? Why? We have a cast of noise. Does it have to change like that? - D .Stark
  • operation, in principle, corresponds to multiplying the spectrum of a given signal block by some other spectrum, that is, applying a digital filter - or is it about multiplying the complex values ​​of the amplitudes of the spectra in frequency, respectively? - D .Stark