Search code examples
audioaudio-streamingaudio-recordingnoise-reduction

How to create Anti-noise?


How can I create anti-noise with code or an application? It doesn't have to be realtime, just sound that is the opposite of the entire soundtrack! So, when you play both together, they will cancel out each other.


Solution

  • If you have pure noise availible try (I have not tried it my self) to fft you can use fftw-3

    1 Take some buffer containeing noise only 2 Zero-pad the noise so that its length matches up with the entire signal 3 Calculate the noise spectrum N 4 Calculate the signal spectrum X filter out frquencies in X that are present in N and store the result in Y 6 Recompose y from Y

    in Matlab or octave:

    n=length(x);
    n(1:noise_end-noise_start+1)=x(noise_start:noise_end);
    N=fft(n);
    X=fft(N);
    %   Filter noise frquencies
    y=ifft(Y);
    

    The idea is to use the spectrum of the noise signal to reduce the noise in the desired signal. When the spectrum of the noise is known, filter these frequencies out.