Engee documentation
Notebook

A model of a biquadratic NIR filter.

The Biquad Filter block independently filters each channel of the input signal using the specified biquadratic filter with infinite impulse response (IIR). If you specify filter coefficients in the parameter settings window, the block implements static filters with fixed coefficients.

The recorded noisy audio signal is fed to the input of this filter, and at the output we get 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, Samples_per_audio_channel);
    s, fs = wavread(patch);
    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 
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 models.

image.png

Single channel model:

image.png

Multi-channel model:

In [ ]:
run_model("Biquad_filter") # Запуск модели.
Building...
Progress 0%
Progress 0%
Progress 2%
Progress 2%
Progress 3%
Progress 4%
Progress 5%
Progress 6%
Progress 6%
Progress 7%
Progress 8%
Progress 8%
Progress 9%
Progress 10%
Progress 10%
Progress 11%
Progress 12%
Progress 13%
Progress 14%
Progress 14%
Progress 15%
Progress 16%
Progress 17%
Progress 18%
Progress 19%
Progress 19%
Progress 20%
Progress 21%
Progress 22%
Progress 22%
Progress 23%
Progress 24%
Progress 24%
Progress 25%
Progress 26%
Progress 27%
Progress 28%
Progress 28%
Progress 29%
Progress 30%
Progress 31%
Progress 32%
Progress 33%
Progress 33%
Progress 34%
Progress 35%
Progress 36%
Progress 37%
Progress 37%
Progress 38%
Progress 39%
Progress 40%
Progress 41%
Progress 41%
Progress 42%
Progress 43%
Progress 44%
Progress 44%
Progress 45%
Progress 46%
Progress 46%
Progress 47%
Progress 48%
Progress 48%
Progress 49%
Progress 50%
Progress 51%
Progress 51%
Progress 52%
Progress 53%
Progress 53%
Progress 54%
Progress 55%
Progress 55%
Progress 56%
Progress 57%
Progress 57%
Progress 58%
Progress 59%
Progress 60%
Progress 61%
Progress 61%
Progress 62%
Progress 63%
Progress 63%
Progress 64%
Progress 64%
Progress 65%
Progress 65%
Progress 66%
Progress 67%
Progress 68%
Progress 68%
Progress 69%
Progress 70%
Progress 71%
Progress 71%
Progress 72%
Progress 73%
Progress 74%
Progress 74%
Progress 75%
Progress 76%
Progress 77%
Progress 78%
Progress 79%
Progress 80%
Progress 80%
Progress 81%
Progress 82%
Progress 83%
Progress 84%
Progress 85%
Progress 85%
Progress 86%
Progress 87%
Progress 88%
Progress 89%
Progress 89%
Progress 90%
Progress 90%
Progress 91%
Progress 92%
Progress 93%
Progress 94%
Progress 95%
Progress 95%
Progress 96%
Progress 97%
Progress 98%
Progress 98%
Progress 99%
Progress 100%
Progress 100%
Out[0]:
SimulationResult(
    "filtered" => WorkspaceArray("Biquad_filter/filtered"),
    "noisy" => WorkspaceArray("Biquad_filter/noisy")
)
In [ ]:
run_model("Biquad_filter_multichannel") # Запуск модели.
Building...
Progress 0%
Progress 0%
Progress 7%
Progress 13%
Progress 20%
Progress 26%
Progress 100%
Out[0]:
SimulationResult(
    "out" => WorkspaceArray("Biquad_filter_multichannel/out"),
    "inp" => WorkspaceArray("Biquad_filter_multichannel/inp")
)

After running the model, we can see which frequencies have been filtered in the single-channel and multi-channel variations of the model.

image.png

image.png

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

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

Conclusion

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