Julia 中的高通滤波器

High pass filter in Julia

我正在与 Julia 一起录制 5 秒剪辑的现场音频,并希望剪掉特定频率以下的所有声音。这是我目前的记录脚本:

using PortAudio, SampledSignals, LibSndFile, FileIO, Dates

stream = PortAudioStream("HDA Intel PCH: ALC285 Analog (hw:0,0)")

buf = read(stream, 5s)

while true
    save(string("recording_", Dates.format(now(), "yyyymmdd_HHMMSS"), ".wav"), buf, Fs = 48000)

如何过滤掉下面的所有声音,例如10kHz?我一直在查看 DSP 包中的 Highpass 函数,但我不太了解如何正确应用它。

using DSP

"""
    highpassfilter(signals, fs, cutoff, order=4)
Apply high pass filter to signals, return filtered data
"""
function highpassfilter(signals, fs, cutoff, order=4)
    wdo = 2.0 * cutoff / fs
    filth = digitalfilter(Highpass(wdo), Butterworth(order))
    filtfilt(filth, signals)
end