我试图导入一个波形文件,用FFT分析它(找到峰值)。然后用过滤器进行处理(例如去除噪音)。然后将其导出为新的wave文件
在实际过滤时,似乎发生了一些事情
滤波信号出错,因为在绘制滤波器输出时,绘图给出了错误的时间轴数据,并且在某些情况下输出的频谱发生了偏移或根本没有给出
我认为进口和类似的方法是有效的,我从几个来源获取了它们。 主要来源:https://azitech.wordpress.com/2011/03/15/designing-a-butterworth-low-pass-filter-with-scipy/
#designing filter.
order = 10
lowcut = 950
highcut = 1050
fs = 44100
#^^^(fs) is this same sampling frequency of the import?
#find filter coefficients
def butter_bandpass(lowcut, highcut, fs, order):
nyq = 0.5 * fs
low = lowcut / nyq
high = highcut / nyq
b, a = signal.butter(order, [low, high], btype='band')
return b,a
# Call filter to get coefficients
b, a = butter_bandpass(lowcut,highcut,fs,order)
print(b,a)
# filter frequency response
(w, h) = signal.freqz(b, a)
fig.add_subplot(131)
pyplot.plot((fs*0.5/numpy.pi)*w, numpy.abs(h)) #*w > fs*0.5/numpy.pi*
pyplot.title('Filter Respons Freq Domain')
print('Order filter','=',order)
pyplot.grid(True)
# Also not sure why source plots it as fs*0.5/numpy.pi < although this gives the right x-axis (frequency) as the input (highcut and lowcut).
# filtered output
#zi = signal.lfiltic(b, a, x[0:5], x[0:5])
#(y, zi) = signal.lfilter(b, a, x, zi=zi)
# ^^ not used.
y = signal.lfilter(b, a, data[:,0])
pyplot.plot(t, y)
pyplot.title('Filter Output Time Domain')
pyplot.grid(True)
最终产品需要是一个能够导入wav文件的脚本(它是采访和噪音(定义的峰值噪音)的组合),分析它以达到峰值,然后将其导出为新的wave可播放文件
目前没有回答
相关问题 更多 >
编程相关推荐