I have a sound source that generates an ultrasonic pulse. I have two microphones seperated by a distance which are at a distance from the source. I want to find the time delay of arrival of the ultrasonic pulse at the mics. I am filtering out all the frequencies other than my source frequency from the outputs of the mics. Due to noise and other reasons, the shape of the pulse received at each mic is not same. I am using cross-correlation to find the time delay but the results are inconsistent. I observed that when I use low frequencies (100~300hz), results are consistent. But I want to find using ultrasonic sound. I am using the below code for finding time delay


Can anyone please tell me what is it that I am doing wrong and how to correct it? I posted a similar question here, but couldnt understand the provided answer. In some articles, it is mentioned that cross-correlation works only for cases when the signal shapes are identical. If so, how can I find the delay? I was also wondering if the voice tracking cameras used in video conferencing use some technique other than cross-correlation.

  • $\begingroup$ How long a pulse? With what ruse/fall time? At what sample rate? Are there any potential audio reflections or reflectors in the environment? $\endgroup$
    – hotpaw2
    Mar 1, 2014 at 16:02
  • $\begingroup$ can you show your pulse in a figure? how different between the two pulses? do they have the same number of peaks? $\endgroup$
    – lennon310
    Mar 1, 2014 at 16:54
  • $\begingroup$ stackoverflow.com/q/4967453/125507 and gist.github.com/endolith/376572 $\endgroup$
    – endolith
    Mar 1, 2014 at 19:52
  • $\begingroup$ @hotpaw2, my pulse details are: total duration:0.5s, rise/fall time: 0.05s, sample rate: 44100 and audio reflections can be neglected. $\endgroup$
    – BaluRaman
    Mar 3, 2014 at 4:34

1 Answer 1


The transient edge or pulse shape of a tone burst represents a modulation. The resulting modulated signal will contain frequency components higher than the tone frequency. Thus you may need a sample rate much higher than just over 2X the tone frequency to reproduce a waveform accurately enough for cross-correlation to match the edges of the pulse envelopes. This is likely true for your low tones and for voices, where the sample rate can be 10X to 200X higher than the tone or forment frequencies.

Filtering out frequencies just below the tone carrier can also remove any lower sidebands of the modulation, thus likely increasing the error in envelope matching by cross-correlation.

  • $\begingroup$ So you mean to say that my sampling frequency should be at least 10x my tone frequency? If so, I cannot sample more than my current frequency. Are there any good alternate methods to cross-correlation for time delay calc? $\endgroup$
    – BaluRaman
    Mar 3, 2014 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.