0

I have recorded audio spanning a few seconds and containing two similar tones generated with the same frequency. They are a couple of seconds apart. What I would like to do is detect the end of the first tone and the beginning of the second tone in terms of how many samples apart they are for this audio file. Assume 16-bit signed PCM at 48KHz audio and a byte array to represent the raw audio.

I am struggling on how I can figure this out;

a) Run a DFT to detect the occurrence of the specific frequency of the tone

b) Since the two tones are the loudest, somehow, figure out the peaks and where they start/end for the two tones

c) Run the audio file through a band pass filter to filter out all other frequencies, I will potentially end up with two lines, or two non-zero segments in the array

What is the most straightforward method (feel free to suggest other techniques)?

John Smith
  • 307
  • 3
  • 14

1 Answers1

0

Run the samples through a Fast Fourier Transform, matching to your expected frequencies within a certain tolerance, then count number of samples between when not matching?

Dan Armstrong
  • 469
  • 2
  • 5
  • Is this essentially using the answer/resources from http://stackoverflow.com/questions/17429407/get-frequency-wav-audio-using-fft-and-complex-class ? Thanks – John Smith Dec 06 '16 at 17:58
  • Not really sure. I was just hoping I could nudge you in a possible direction. – Dan Armstrong Dec 06 '16 at 21:03
  • I managed to get an FFT running on the signal from the link I provided above. This is an array of real/imaginary numbers. I am able to find the magnitudes per frequency. Given the FFT array and it's absolute signal, how would I deduce frequency information based on sample number? – John Smith Dec 08 '16 at 18:18
  • I supposed you'd have to run the FFT for different starting samples, since the FFT needs to work on a power-of-two set of samples. Kind of like a sliding window over the samples to narrow-in on the more precise range. – Dan Armstrong Dec 08 '16 at 22:41
  • So basically I should run the FFT many times, taking a few samples to have a frequency range vs time range? Is this like STFT? Thanks again! – John Smith Dec 08 '16 at 23:00
  • That's what I'm thinking. Maybe somebody with more experience can chime-in? – Dan Armstrong Dec 08 '16 at 23:01