# Finding the main frequency of an input audio signal

Started by August 29, 2007
```What is the best/easiest method to determine the main frequency of the
input audio signal? I am confused by some options (FFT, wavelets) and
I am just looking for a simple one which doesn't have to be too much
theory, but simply works. I still would like to learn something, not
just reuse somebody's solution in part or in whole and not understand
anything, but I wouldn't like to spend more then a day or two learning
the maths and so. Do you have any suggestions regarding this? Even a
simple list of possibilities would be good, but if you have the actual
experiences or links to some good tutorials, that would be great.

```
```wimxa@yahoo.com wrote:
> What is the best/easiest method to determine the main frequency of the
> input audio signal? I am confused by some options (FFT, wavelets) and
> I am just looking for a simple one which doesn't have to be too much
> theory, but simply works. I still would like to learn something, not
> just reuse somebody's solution in part or in whole and not understand
> anything, but I wouldn't like to spend more then a day or two learning
> the maths and so. Do you have any suggestions regarding this? Even a
> simple list of possibilities would be good, but if you have the actual
> experiences or links to some good tutorials, that would be great.
>

What is YOUR definition of "best/easiest"?

Why does FFT confuse you?

How do you define "simple"?

You are *ALMOST* asking the "RIGHT" questions.

This answer is *NOT* a put down. !!!!

I'm a fellow newbie who has learned that asking RIGHT question is > 1/2
the battle.

```
```wimxa@yahoo.com wrote:

> What is the best/easiest method to determine the main frequency of the
> input audio signal?

I think first you have to define "main frequency".

In music, there is a fundamental frequency, where other frequencies
might be multiples of that frequency.  In some cases, the fundamental
might not be as large as some harmonics.  It is said that in some cases
the fundamental might have zero amplitude, yet still be audible.
(That is, the brain figures out that it should be there.)

Maybe you just want the frequency with the most power, though.

-- glen

```
```On Aug 29, 8:24 pm, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
> wi...@yahoo.com wrote:
> > What is the best/easiest method to determine the main frequency of the
> > input audio signal?
>
> I think first you have to define "main frequency".
>
> In music, there is a fundamental frequency, where other frequencies
> might be multiples of that frequency.  In some cases, the fundamental
> might not be as large as some harmonics.  It is said that in some cases
> the fundamental might have zero amplitude, yet still be audible.
> (That is, the brain figures out that it should be there.)

because the period of repitiion is still 1/fundamental, even if the
amplitude of the first harmonic is zero (as long as there are enough
other odd harmonics with sufficient amplitude).

> Maybe you just want the frequency with the most power, though.

or a sorta weighted mean or spectral "center of gravity".

but if the OP wants to know the fundamental frequency of a reasonably
harmonic musical note, the thing he/she wants is called a "pitch
detector".

r b-j

```
```Thanks everyone for answering.

@Richard Owlett
> What is YOUR definition of "best/easiest"?
Can be implemented (including understanding why the implementation
works like that - just the main concepts) in day or two.

> Why does FFT confuse you?
Misunderstanding: I am confused which option to use. There are many -
which is best/easiest in the previous sense?

> How do you define "simple"?
That you don't actually need to know how it works to understand the
main concepts behind it. This is a little vague.

> You are *ALMOST* asking the "RIGHT" questions.
:)

> This answer is *NOT* a put down. !!!!
Got that. Thanks.

> I'm a fellow newbie who has learned that asking RIGHT question is > 1/2
> the battle.
I agree.

@glen
>I think first you have to define "main frequency".
>...
>Maybe you just want the frequency with the most power, though.
The last one would suffice.

@r b-j
> but if the OP wants to know the fundamental frequency of a reasonably
harmonic musical note, the thing he/she wants is called a "pitch
detector".
<
This seems interesting. Do you have any pointers where I can learn
this from (i.e. something you consider a good thing for a start)?

```
```On Aug 29, 2:51 pm, wi...@yahoo.com wrote:
> What is the best/easiest method to determine the main frequency of the
> input audio signal? I am confused by some options (FFT, wavelets) and
> I am just looking for a simple one which doesn't have to be too much
> theory, but simply works. I still would like to learn something, not
> just reuse somebody's solution in part or in whole and not understand
> anything, but I wouldn't like to spend more then a day or two learning
> the maths and so. Do you have any suggestions regarding this? Even a
> simple list of possibilities would be good, but if you have the actual
> experiences or links to some good tutorials, that would be great.

Well, first you need to define what you mean by the
"main" frequency, since the musical pitch frequency
that a human would recognize may not be the same thing
as any spectral envelope peak.

I have a list on a web page of a bunch of techniques
for frequency estimation which may or may not be useful

http://www.nicholson.com/rhn/dsp.html

Some methods are easy, some are better at various
criteria.  And you rarely get both unless you have
a highly constrained signal.

IMHO. YMMV.
--
rhn A.T nicholson d.0.t C-o-M

```
```<wimxa@yahoo.com> wrote in message
> What is the best/easiest method to determine the main frequency of the
> input audio signal?

The best and easiest method is to hire the consultant.

> I am confused by some options (FFT, wavelets) and
> I am just looking for a simple one which doesn't have to be too much
> theory, but simply works.

A frequency counter?

> I still would like to learn something, not
> just reuse somebody's solution in part or in whole and not understand
> anything, but I wouldn't like to spend more then a day or two learning
> the maths and so.

Wonderful.

> Do you have any suggestions regarding this? Even a
> simple list of possibilities would be good, but if you have the actual
> experiences or links to some good tutorials, that would be great.

I have all of that. Do you have money?

VLV

```
```"robert bristow-johnson" <rbj@audioimagination.com> wrote in message
> On Aug 29, 8:24 pm, glen herrmannsfeldt <g...@ugcs.caltech.edu> wrote:
> > wi...@yahoo.com wrote:

> but if the OP wants to know the fundamental frequency of a reasonably
> harmonic musical note, the thing he/she wants is called a "pitch
> detector".

Pitch detector! Magic word! You said it!
Topes! Topezz! Where is Topezzz?

VLV

```
```On 29 Aug, 23:51, wi...@yahoo.com wrote:
> What is the best/easiest method to determine the main frequency of the
> input audio signal?

A piano. Play the input signal on a speaker and press the tangents
on the piano till you fin a tone which matches the signal.

> I am confused by some options (FFT, wavelets)

and become less confused.

> and
> I am just looking for a simple one which doesn't have to be too much
> theory, but simply works.

Sure. And I would just love to find that pile of gold everybody
knows is where the ranbow ends.

> I still would like to learn something, not
> just reuse somebody's solution in part or in whole and not understand
> anything,

Maybe you don't want that, but that's a brilliant
way to start, if you want to learn something.

> but I wouldn't like to spend more then a day or two learning
> the maths and so.

You are really something, aren't you? How much maths
can you learn in two days?

> Do you have any suggestions regarding this? Even a
> simple list of possibilities would be good, but if you have the actual
> experiences or links to some good tutorials, that would be great.

I might have one or two suggestions, but they would require
the mats, playing with code examples. You have already
excluded all of that from your list of acceptable activities,
so mentioning such options is a mere waiste of time.

Rune

```
```On Aug 30, 3:29 am, wi...@yahoo.com wrote:
> This seems interesting. Do you have any pointers where I can learn
> this from (i.e. something you consider a good thing for a start)?

Check for: Autocorrelation, AMDF (average mean difference function),
Peak picking in the FFT is good. Wavelets should work to (but I
have no idea how because I consider them too abstract, but that's just
me)

All of these alas do require some checking of the math, but more
importantly (several years ago when I asked
the group almost the same question, and r b-j said I asked the right
questions :) given the data any of the
above methods supply, you have to do some "smart" interpreting of the
data.

What is considered smart for one type of input signal might not be so
smart for another. In short, all of the above methods will work, but
to work well, the data they supply needs to be "interpreted".

/Rob

```