PDA

View Full Version : How to test sound freq?


Burgos
07-13-2008, 09:05 PM
First of all: Hello, everybody!

I have a problem that I can't figure myself, so I'm kindly asking you fo
help. My application consists of two parts: the first one, which i
generating clean sin tone for a given frequency, and the second one, whic
is used to detect signal freq.

I have used FFT to find frequency of input sound, but it seems t
expensive for me, because all I need is to test single freq., rather tha
whole bandwidth. Is there any cheaper way (in resources thinking) than tha
I've mentioned?

Thank you.

namespace
07-13-2008, 10:28 PM
>generating clean sin tone for a given frequency

Simply evaluate x = sin(2 * pi * f * t), where f is your frequency in H
and t is the time in seconds at which you wish to calculate x. The sin
wave amplitudes will be in x. To generate an actual tone that you can use
you will have to find some way to convert the amplitudes to a usabl
signal. This depends on the hardware that you have. If you have a DAC
then you might write a program to output the amplitudes as an analo
signal.

Using Matlab, you can generate a sine tone with the following program:

fs = 96000;
period = 1/fs;
timemax = 1;
t = 0:period:(1-period);
freq = 1000;
x = sin(2*pi*freq*t);

You could also write the program in a language such as C.

To determine a signal frequency, the Fast Fourier Transform (FFT) is th
most widely-used method to determine spectral content (which is good if yo
have a signal with a power-of-two signal length). However, if you know th
signal frequency which you want to match, you can detect the frequency b
algorithms particular to DTMF signalling.

Of particular interest is the Goertzel algorithm; you can find som
information here:

http://en.wikipedia.org/wiki/Goertzel_algorithm

Vladimir Vassilevsky
07-13-2008, 11:06 PM
Burgos wrote:
> First of all: Hello, everybody!
>
> I have a problem that I can't figure myself, so I'm kindly asking you for
> help. My application consists of two parts: the first one, which is
> generating clean sin tone for a given frequency, and the second one, which
> is used to detect signal freq.
>
> I have used FFT to find frequency of input sound, but it seems to
> expensive for me, because all I need is to test single freq., rather than
> whole bandwidth. Is there any cheaper way (in resources thinking) than that
> I've mentioned?

How about a frequency counter?


Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com

Burgos
07-14-2008, 02:56 AM
@namespace

I have made tone generator, using DSound buffers and simply cos(2*pi*f*t
and I know what frequency is.

I've looked around and I've found Goertzel's algorithm, but I didn't us
it because of DTMF structure (as I remember, it was the sum of two si
signals). You say that I can detect tone frequency with that algorithm?

@Vladimir V.

I think it is not possible for me to develop frequency counter in C++ :(.

Thank you, both.

Burgos
07-14-2008, 03:05 AM
"You say that I can detect tone frequency with that algorithm? "

What I meant to say is "sound frequency." Sorry :(.

Vladimir Vassilevsky
07-14-2008, 03:06 AM
Burgos wrote:

> @Vladimir V.
>
> I think it is not possible for me to develop frequency counter in C++ :(.

How wonderful. So, you can't just count the number of samples between
the two zero crossings of the signal. Is this because of C++, or C# pehaps?


Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com

Burgos
07-14-2008, 11:27 AM
I don't know C#, and I am pretty new in DSP, sorry, don't be ironic :(.

However, thank you for your great suggestion, I think that will do th
trick :).

Thank you!
Greetings for Serbia

Burgos
07-14-2008, 11:39 AM
Hm...

Now I've looked around and I think that I need to implement noise gate
too, because what I do is capturing data from LineIn, rather than readin
pcm data from file.

Mikolaj
07-16-2008, 08:21 AM
On 13-07-2008 at 22:05:36 Burgos <[email protected]> wrote:

> First of all: Hello, everybody!
>
> I have a problem that I can't figure myself, so I'm kindly asking you for
> help. My application consists of two parts: the first one, which is
> generating clean sin tone for a given frequency, and the second one,
> which
> is used to detect signal freq.
>
> I have used FFT to find frequency of input sound, but it seems to
> expensive for me, because all I need is to test single freq., rather than
> whole bandwidth. Is there any cheaper way (in resources thinking) than
> that
> I've mentioned?
>
> Thank you.
>

If you want just to detect appearance of the tone at specific frequency
maybe simple filtering would be enough.

How about filter matched tu sine wave or notch filter or any bandpass
filter?
And than some slicer/amplitude detector/integrator-discriminator somthing.



--
Mikolaj