I would like to find the phase shift between two non-periodic signals read from an electret microphone. So what I did so far is the following:
- read the signals from the mics using an arduino uno micro controller.
- finished writing an fft code based on cooley_tukey algorithm.
- tested the fft with the help of matlab.
My plan is:
- search for the maximum value in each signal and store its index
- find the phase corresponding to the index found in the previous step from fft using: phase = atan(imaginary/real)
- assume phase1 and phase2 corresponding to phases calculated in step(2) for signals 1 and 2 respectively.
- difference = phase1 - phase2 if (difference < 0) → phase1 < phase2 → signal 1 came first and vice versa.
So, is this procedure correct? Am I going to get the phase shift using this technique? I would to do a sound localization using 4 microphones. Thanks in advance. Your help is appreciated.