我正在使用AudioLazy Library来提取一些音频功能.
lpc function(线性预测编码)在时域中接收块,并返回白化LPC滤波器(ZFilter)
filt = lpc(intensity,order=16) # Analysis filter
gain = 1e-2 # Gain just for alignment with DFT
(gain / filt).plot(min_freq=0,max_freq=3.141592653589793/4);
filt是一个ZFilter:
1 - 2.47585 * z^-1 + 2.68746 * z^-2 - 1.71373 * z^-3 + 0.383238 * z^-4 + 0.451183 * z^-5 - 0.480446 * z^-6 + 0.304557 * z^-7 + 0.0277818 * z^-8 - 0.280118 * z^-9 + 0.0705354 * z^-10 + 0.0217045 * z^-11 + 0.0456379 * z^-12 - 0.012231 * z^-13 + 0.00986871 * z^-14 + 0.0553664 * z^-15 - 0.0800961 * z^-16
绘图功能,返回图像:
我想从幅度曲线中提取数值(以dB为单位).你能帮助我吗?
谢谢
最佳答案
我用这几行代码解决了这个问题……现在我可以提取(并绘制:P)LPC向量.
原文链接:https://www.f2er.com/python/439737.htmlsamples=2048; #Number of samples (frequency values)
min_freq=0.; #Frequency range
max_freq=3.141592653589793/4; #Frequency range
freq_scale="linear" #Chooses whether plot is "linear"
mag_scale="dB" #Chooses whether magnitude plot scale.
fscale = freq_scale.lower()
mscale = mag_scale.lower()
mscale = "dB"
fig = plt.figure()
Hz = 3.141592653589793 / 12.
# Sample the frequency range linearly (data scale) and get the data
freqs = list(line(samples,min_freq,max_freq,finish=True))
freqs_label = list(line(samples,min_freq / Hz,max_freq / Hz,finish=True))
data = filt.freq_response(freqs)
mag = { "dB": dB20 }[mscale]
print mag(data);
情节如下: