def fst_delay_snd(fst, snd, samp_rate, max_delay):
# Verify argument shape.
s1, s2 = fst.shape, snd.shape
if len(s1) != 1 or len(s2) != 1 or s1[0] != s2[0]:
raise Exception("Argument shape invalid, in 'fst_delay_snd' function")
half_len = int(s1[0]/2)
a = numpy.array(fst, dtype=numpy.double)
b = numpy.array(snd, dtype=numpy.double)
corr = numpy.correlate(a, b, 'same')
max_pos = numpy.argmax(corr)
# plot(s1[0], samp_rate, a, b, corr)
return corr, (max_pos - half_len) / samp_rate
评论列表
文章目录