巴特沃思过滤器python

时间:2019-11-19 16:08:23

标签: python filter fft wav butterworth

我想用Butterworth带通过滤一个df.count文件。我试图将wav文件转换为wav,然后应用带通滤波器,然后再应用fft。从图形上看,它似乎经过了一些过滤,但是当我减少输入和输出ifft时,音频没有差异,就像过滤器不起作用一样。有错吗

wav

1 个答案:

答案 0 :(得分:0)

lfilter documentation为例,您似乎不需要执行FFT,而直接将data提供给过滤器。这样就更简单了

frequency,data = wavfile.read('Input_sound.wav')

def butter_bandpass_filter(data, lowcut, highcut, frequency, order):
    nyq = 0.5 * frequency
    low = lowcut / nyq
    high = highcut / nyq

    b, a = butter(order, [low, high], btype='bandpass')
    y = lfilter(b, a, data)
    return y 

filtered_sound=butter_bandpass_filter(data,2100,3400,44100,4)
wavfile.write('Filtered_ouput.wav',frequency,filtered_sound)