Engee documentation
Notebook

Rejector filtering

The Notch-Peak Filter unit filters each channel of the input signal in time using a specified centre frequency and bandwidth.

In our case, the following settings are used:

  1. 200Hz bandwidth,
  2. Peak/cut centre frequency 7350Hz.
  3. input signal sampling frequency 22050Hz.

The input of this filter is the recorded noisy audio signal, and the output is the filtered signal.

Let's proceed to the implementation of this project: set auxiliary functions and build a model.

Let's define the function of the player.

In [ ]:
Pkg.add(["WAV"])
In [ ]:
using WAV;
using .EngeeDSP;

function audioplayer(patch, fs, Samples_per_audio_channel);
    s = vcat((EngeeDSP.step(load_audio(), patch, Samples_per_audio_channel))...);
    buf = IOBuffer();
    wavwrite(s, buf; Fs=fs);
    data = base64encode(unsafe_string(pointer(buf.data), buf.size));
    display("text/html", """<audio controls="controls" {autoplay}>
    <source src="data:audio/wav;base64,$data" type="audio/wav" />
    Your browser does not support the audio element.
    </audio>""");
    return s
end 
[ Info: Precompiling WAV [8149f6b0-98f6-5db9-b78f-408fbbb8ef88]
Out[0]:
audioplayer (generic function with 1 method)

Let's connect the auxiliary function of the model start.

In [ ]:
function run_model( name_model)
    
    Path = (@__DIR__) * "/" * name_model * ".engee"
    
    if name_model in [m.name for m in engee.get_all_models()] # Проверка условия загрузки модели в ядро
        model = engee.open( name_model ) # Открыть модель
        model_output = engee.run( model, verbose=true ); # Запустить модель
    else
        model = engee.load( Path, force=true ) # Загрузить модель
        model_output = engee.run( model, verbose=true ); # Запустить модель
        engee.close( name_model, force=true ); # Закрыть модель
    end
    sleep(5)
    return model_output
end
Out[0]:
run_model (generic function with 1 method)

Build and run the model.

image.png

In [ ]:
run_model("NotchPeak_filter") # Запуск модели.

After running the model, we can see which frequencies have been filtered out.

image.png

Now let's listen to the input and output signals.

In [ ]:
audioplayer("$(@__DIR__)/MysterySig.wav", 24000, 256);
In [ ]:
audioplayer("$(@__DIR__)/output.wav", 24000, 256);

Conclusion

As we can hear from the recordings and see from the model, the filter works correctly and allows to get rid of extraneous noise in the original audio signal.