音频波形匹配
问题描述:
我匹配的400毫秒2个波形。我正在使用关联来检查班次。
cc = correlate(b1,b2,mode="same")
n=len(cc)
cc=2*cc/n
dur=n*dt1/2;
d=linspace(-dur, dur, n)
idx = argmax(cc)
我正在2波形之间切换。但如何获得两个波形的实际匹配位置?
答
你可能想mode = "full"
和需要做一些更多的数学挑选相关峰和调整序列长度填充
希望这个例子将有助于显示的问题:
import math
import numpy as np
import matplotlib.pyplot as plt
a = [math.sin(i* math.pi/10) for i in range(300)]
b = [math.cos(i*math.pi/10) for i in range(300)]
plt.plot(a, 'red')
plt.plot(b, 'green')
axb= np.correlate(a,b, mode="full")/100.0
x = range(len(axb))
plt.plot(x, axb)
您得到的转变是您需要移动b1以使其与b2达到最大共生关系的转变。 –
我附上了图像。两者之间的平移是0.015 ms。我可以移动0.015 ms,但实际匹配从0.26 ms开始 – deep