I am trying to find a specific block of data that should hold valid audio data that I want to process. For instance, I record at 44.1kHz, but I only transmit a .5s of content. Since the buffer I store the recordings in contains both the recording as well as background noise, is there a way to isolate the sample I desire? Is this a simple filtering problem? I know the range of frequencies I need in the sample, so would a bandpass filter solve this issue? My ultimate goal is to run the time series data through an FFT to see which of the desired frequencies were transmitted. Note that this is being done in software. Thanks for any help!

  • 1
    $\begingroup$ What is the nature of the wanted signal? What is the nature of the background noise? What is roughly their frequency bandwidth? And what is roughly the signal to noise ratio? I'm asking as there are various methods to approach this depending on your particular circumstances. $\endgroup$ – Izhaki Jul 4 '13 at 9:10
  • $\begingroup$ I'm not sure how to find signal to noise ratio, but the nature of the noise should be arbitrary (ie should be able to find signal in any condition where the range of frequencies I want are mostly untouched). $\endgroup$ – Batman Jul 5 '13 at 0:33

Knowing the range of frequencies is a good start and yes a bandwidth filter will certainly help you isolate them but you must consider the overall level of background noise vs signal noise.

Performing an FFT on filtered (bandwidth or otherwise) data will only yield results on the frequencies that are left over! This will either be of use to you or not.

If the number of frequencies that you are after are not that numerous, a collection of IIR (infinite impulse response) filters might be a better choice.

Consider DTMF tones used by telephones and cellphones, typically IIR filters have found their way in software based detection of these dual-tone based signals. There are online resources for calculating each of the filter's co-efficients. You must use one filter per frequency that you are after.

Here is an iPhone version of source code for DTMF decoding using IIR filters

The file DTMFDecoder.m contains the bulk of the code with the co-efficients defined near the top.

Without knowing any further detail, this is all I am able to help you with.

  • $\begingroup$ The range of frequencies I am targeting are a bit numerous (160 or so) all above 14khz. What exactly is an IIR? $\endgroup$ – Batman Jul 5 '13 at 1:17
  • $\begingroup$ My comment was too long, so I had to respond as a new answer (see below). $\endgroup$ – ronnied Jul 5 '13 at 23:16

An IIR is an infinite impulse response filter. If you are monitoring 160 or so frequencies don't use IIRs. FFT will be more suitable for your purposes. Recording at 44.1KHz (CD quality) will allow you to record frequencies of up to a theoretical limit of half of this, so frequencies up to 22.05KHz. However, the closer you approach this limit, the more poorly represented the frequencies will be. You will need to choose an appropriate bin width to be able to discern each frequency accurately. For example, an FFT width of 1024 @ 44.1KHz will give approx 21.53Hz resolution: 22050 / 1024. This means that the FFT can yield information on your frequency range, in 21.53Hz steps. If you then consider your range of interest, 14KHz and above, then this yields the following: 22050 - 14000 = 8050Hz bandwidth; 8050 / 21.53 = 373.9. So you would be able to detect the amplitude and phase of about 373 frequencies between 14KHz and 22.05KHz using an FFT with a width of 1024. Frequencies that fall between these discrete steps of 21.53Hz will muddy your results and may appear to be two neighboring frequencies instead of the one clean frequency. You can increase the FFT width to give you more finer results but it does come at a computational cost. Modern smart phones are able to do an FFT at a width of 1024 in realtime. If you can, I suggest recording the signal at a higher sample rate to give you better signal accuracy first, then pick an FFT width with sufficient resolution for your needs. If the desired signals are pure enough, then the FFT should give you clear results that you can work with. Also my favourite windowing function is: Blackman-Harris, I find it gives the best main lobe to side lobe compromise but you may have to experiment here depending on the results you get. Good luck!

  • $\begingroup$ Current smartphones can do many thousands of float FFTs of length 1024 in realtime, so longer ones are quite reasonable if necessary. $\endgroup$ – hotpaw2 Jul 6 '13 at 6:20
  • $\begingroup$ Thanks, this was my current approach, but I guess my issue was that you would need to slide the FFT over the data to find the specific start and end points of the data in the recording. Is this true, or can you just send all your data through the FFT and it should yield the same results? Thanks. $\endgroup$ – Batman Jul 8 '13 at 21:25
  • $\begingroup$ As you increase your FFT resolution (single frame) you actually decrease your temporal information of the frequencies identified by the FFT. So yes, sliding the data as you refer it to can strike a balance between knowing 'what' and 'when'. Windowing your data becomes crucial to yield better results when doing this. $\endgroup$ – ronnied Jul 10 '13 at 1:09
  • $\begingroup$ You will need to decide how much FFT overlapping is necessary to yield enough temporal information for your purposes. $\endgroup$ – ronnied Jul 10 '13 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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