DSPRelated.com
Forums

Finding certain frequencies in an audio signal

Started by Thomas Schachtner July 4, 2006
Hi there,

I would like to write an app which can detect certain frequencies in an
audio signal.

There are 11 different frequencies between 1060 and 2600 Hz (freq. no. 1
to 11).
5 of these freqs are sent as some kind of trigger signal with each tone
having 70 ms length.

My program should detect these signals and the order they are
transmitted (e. g. freq. 1,4,8,3,5).

I heard sth. about a Goertzel algorithm which can be used to accomplish
this task, but I don't know very much about this algorithm and about
retrieving data from a pc sound card.

I am using Linux and I am able to get bytes from /dev/dsp.
But when I read N bytes from this /dev/dsp device, which sampling rate
do I have?

Do I then have to use the sampling rate of the sound card (44 kHz...)
for my calculations or do I have to measure the time my routine needs to
read out the N samples and calculate the "sampling rate" by myself?

How do I then calculate the Goertzel algorithm?

Can anybody understand the stuff despite my poor explanations?
And: could anybody maybe even help me?

Thank you
Thomas
Thomas Schachtner wrote:
> Hi there, > > I would like to write an app which can detect certain frequencies in an > audio signal. > > There are 11 different frequencies between 1060 and 2600 Hz (freq. no. 1 > to 11). > 5 of these freqs are sent as some kind of trigger signal with each tone > having 70 ms length. > > My program should detect these signals and the order they are > transmitted (e. g. freq. 1,4,8,3,5). > > I heard sth. about a Goertzel algorithm which can be used to accomplish > this task, but I don't know very much about this algorithm and about > retrieving data from a pc sound card.
What algorithm to use depends on the expeted SNR, the duration of the tones, the stability (in frequency) of the tones, and the separation of frequencies between the tones. The naive approach is to use one bandpass filter with "sufficiently narrow" pass band for each tone. I haven't used Goertzel's algorithm myself, but I can't really see that it fits in this scheme. Rune
Rune Allnor wrote:

> ... I haven't used Goertzel's algorithm > myself, but I can't really see that it fits in this scheme.
Why not? It's pretty standard for DTMF. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Thomas Schachtner schrieb:

> Hi there, > > I would like to write an app which can detect certain frequencies in an > audio signal. > > There are 11 different frequencies between 1060 and 2600 Hz (freq. no. 1 > to 11). > 5 of these freqs are sent as some kind of trigger signal with each tone > having 70 ms length. > > My program should detect these signals and the order they are > transmitted (e. g. freq. 1,4,8,3,5). > > I heard sth. about a Goertzel algorithm which can be used to accomplish > this task, but I don't know very much about this algorithm ...
You can start looking here (try the links at the bottom of the page): http://en.wikipedia.org/wiki/Goertzel_algorithm
>... and about > retrieving data from a pc sound card.
Can't help you with that.
> > I am using Linux and I am able to get bytes from /dev/dsp. > But when I read N bytes from this /dev/dsp device, which sampling rate > do I have? > > Do I then have to use the sampling rate of the sound card (44 kHz...) > for my calculations
Yes. The sampling rate should be returned to you by the API function that receives the data from the sound card.
> or do I have to measure the time my routine needs to > read out the N samples and calculate the "sampling rate" by myself? > > How do I then calculate the Goertzel algorithm?
See the above link.
> > Can anybody understand the stuff despite my poor explanations? > And: could anybody maybe even help me?
Sounds like a classical application for the Goertzel algorithm (tone detection). There is lots of information out there: the net is vast and infinite. Regards, Andor
Jerry Avins wrote:
> Rune Allnor wrote: > > > ... I haven't used Goertzel's algorithm > > myself, but I can't really see that it fits in this scheme. > > Why not? It's pretty standard for DTMF.
There are too many unknowns. Bandpass filters are simpler and more flexible when working with a signal with unknown properties. Maybe the Goertzel fits in the end, but it's a bit too specialized to be used as a first attempt to solve the problem. Use a plain vanilla tool first. When you know what you do and have a clear idea about what you want, you can use the specialist tools. Rune
Thomas Schachtner wrote:

> I would like to write an app which can detect certain frequencies in an > audio signal. > [..] > I am using Linux and I am able to get bytes from /dev/dsp. > But when I read N bytes from this /dev/dsp device, which sampling rate > do I have?
You should use the alsalib API functions from the ALSA project http://www.alsa-project.org/ since this is the API which is supported in the future. Accessing /dev/dsp is the old OSS emulation. The documention about ALSA is here: http://www.alsa-project.org/documentation.php
> Do I then have to use the sampling rate of the sound card (44 kHz...) > for my calculations or do I have to measure the time my routine needs to > read out the N samples and calculate the "sampling rate" by myself?
Just set the sampling rate as you need it. bye Andreas -- Andreas H�nnebeck | email: acmh@gmx.de ----- privat ---- | www : http://www.huennebeck-online.de Fax/Anrufbeantworter: 0721/151-284301 GPG-Key: http://www.huennebeck-online.de/public_keys/andreas.asc PGP-Key: http://www.huennebeck-online.de/public_keys/pgp_andreas.asc
On 4 Jul 2006 22:45:14 -0700, "Rune Allnor" <allnor@tele.ntnu.no>
wrote:

> >Jerry Avins wrote: >> Rune Allnor wrote: >> >> > ... I haven't used Goertzel's algorithm >> > myself, but I can't really see that it fits in this scheme. >> >> Why not? It's pretty standard for DTMF. > >There are too many unknowns. Bandpass filters are simpler and more >flexible when working with a signal with unknown properties. Maybe >the Goertzel fits in the end, but it's a bit too specialized to be used > >as a first attempt to solve the problem. > >Use a plain vanilla tool first. When you know what you do and have >a clear idea about what you want, you can use the specialist tools.
I guess I got lost here somewhere...the Goertzel algorithm is a bandpass filter for pretty much the described application. My only question would be sensitivity given the short duration of the tones as well as susceptibility to whatever frequency offsets (errors) that may be expected in the tones (if any). Eric Jacobsen Minister of Algorithms, Intel Corp. My opinions may not be Intel's opinions. http://www.ericjacobsen.org
Eric Jacobsen wrote:
> My only > question would be sensitivity given the short duration of the tones as > well as susceptibility to whatever frequency offsets (errors) that may > be expected in the tones (if any).
...which are the very issues I mentioned in my first reply in this thread, comments that have been lost somewhere. The Goertzel algorithm works for one stable tone at a known frequency and of a certain duration. If that's the case in this application, by all means, use the Goertzel. However, it may be wise to use a more robust bandpass filter until the nature of the signal has been established. Rune
Rune Allnor wrote:
> Eric Jacobsen wrote: > > My only > > question would be sensitivity given the short duration of the tones as > > well as susceptibility to whatever frequency offsets (errors) that may > > be expected in the tones (if any). > > ...which are the very issues I mentioned in my first reply in this > thread, > comments that have been lost somewhere. The Goertzel algorithm > works for one stable tone at a known frequency and of a certain > duration. If that's the case in this application, by all means, use the > > Goertzel. However, it may be wise to use a more robust bandpass > filter until the nature of the signal has been established.
Since the Goertzel algorithm is one common implementation of a bandpass filter, how would your more robust implementation differ in stability, frequency and duration characteristics for detecting the OPs category of tones? -- rhn A.T nicholson d.0.t C-o-M
Ron N. wrote:
> Rune Allnor wrote: > > Eric Jacobsen wrote: > > > My only > > > question would be sensitivity given the short duration of the tones as > > > well as susceptibility to whatever frequency offsets (errors) that may > > > be expected in the tones (if any). > > > > ...which are the very issues I mentioned in my first reply in this > > thread, > > comments that have been lost somewhere. The Goertzel algorithm > > works for one stable tone at a known frequency and of a certain > > duration. If that's the case in this application, by all means, use the > > > > Goertzel. However, it may be wise to use a more robust bandpass > > filter until the nature of the signal has been established. > > Since the Goertzel algorithm is one common implementation of a bandpass > filter,
Do you say that "common" equals "best" or even "good"? What does popularity have to do with anything? Is Windows the best OS around? "Popularity" has nothing to do with "fitness for purpose".
>how would your more robust implementation differ in stability, > frequency and duration characteristics for detecting the OPs category > of tones?
These are two different questions. The first is to evaluate Goertzel's algorithm vs other bandpass filters. The second addresses the OPs application. Answering the latter first: I know nothing other about the OPs application than was written in his first (and, as far as I can see, only) post in this thread. I have stated twice what I find lacking in his post with respect to making major decisions about what to do and how to deal with the problem. As for the conventional "non-Goertzel" bandpass filter, I am sure you know that the user chooses center frequencies, bandwidths and stop band attenuations very freely. The formulas are there, click, clack, the computer produces a set of coefficients and the frequency responses are easy to inspect. The impulse resoponses are easy to inspect, too, one can readily see from the decay time if this or that impulse response fits in this or that signaling scheme, or if the different symbols will be mixed in time. As I've said before, repeated once and state again: The Goertzel is a specialist tool that can be used instead in some applications, but lots of work has to be domne first in order to see that it actually fits the application in question. Rune