Before anyone yells at me I fully realize that this question has been asked numerous times. I assure you that I've read through the existing questions and answers but I am still confused about part of the problem.
I have a sound source that plays music (A) in a closed environment. I have a mic that I'm using to record A. I am left with two wav files which share the same characteristics and length (number of samples).
My goal is calculate the time it took for A to reach the mic.
I am trying to perform the calculation using cross-correlation (numpy):
# Delay estimation corr = numpy.convolve(original_audio, recorded_audio, 'full') delay = int(len(corr)/2) - numpy.argmax(corr) distance = delay / sample_rate * 343 # sample_rate == 22050, m/s = speed of sound print("Distance full: %.2f cm" % (distance * 100))
I consistently obtain values in the 300,000 cm range. The distance between the speaker and mic is approximately 2 feet.
This is all pretty new to me so I'm sure I'm missing something obvious.
Thanks in advance.