#### Archived

This topic is now archived and is closed to further replies.

# Programming tone detection

This topic is 5156 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys! I''ve had an idea of a project that needed to find the tone of the sound input. I''m looking for something almost like voice recognition, but instead note detection. All I''d need is to find out the frequency in Hz (ex A3 = 440hz) and I should able to do the rest on my own. Also, I''d need to be able to calculate it over short intervals, so I don''t want the note to be held for 1 second before the program finds out which note it is. Thanks for the help! - Vince989

##### Share on other sites
Fast Fourier Transform

##### Share on other sites

Now, where can I find info on it? A name is useless if you don''t have what goes with it...

And just to make sure we are talking about the same thing, one possible use would be to make a guitar tuner. If it''d work, then that''s really what I''m looking for!

- Vince989

##### Share on other sites
Come now; do a Google for FFT DSP PROGRAMMING.

##### Share on other sites
A guitar doesn''t emit a ''tone'' - it emits an analog waveform (which is preferably sampled for your convenience).

As for Googling for FFT DSP PROGRAMMING, it won''t probably be enough to get you started. My suggestion is for you to get a book on DSP (, read it) and if then you can''t figure this out for yourself, ask questions, because no one''s going to explain it to you in a forum, that''s for sure.

TCP - Transmission by Carrier Pigeons

##### Share on other sites
Actually, try this link:

www.dspdimension.com

By just doing an FFT of a short portion of a sampled sound you won''t receive the high accuracy of the pitch estimate you need. By using the analysis stage of the Phase Vocoder you will get an accuracy better than 1 Hz, provided you use buffers of 1024 samples and a sampling frequency of 44.1 kHz.

There is just a little math needed :-)

Tip: Precompute the cosine table instead of using the cos function if you want the algorithm to run faster...

good luck...

btw, You can check out this pdf for another quick explanation of the phase vocoder and how to use it for harmonizing a signal...

http://www.s3.kth.se/signal/reports/exjobb/04/IR-SB-EX-0411.pdf

##### Share on other sites
Actually, after reading a bit (especially the pdf file), I've found out I asked for info I already knew...

I know that sound isn't only a tone; it's some kind of waveform, and it can be calculated in Hz. In music, A3 is used for 440Hz, and A4 (one octave higher) is 880Hz. If you consider the fact that "notes are an exponential function" (k^x for instance), along with the fact the each octave is composed of 12 half tones, this means gives us that each half note (C to C# as well as E to F) is 1,0594602272727272727272727272727 times bigger than the last one. Knowing this, I don't really need tone detection; Instead, what I need is simply a way to get the frequency over a short timespan (as I am reading, estimate it from 1024 parts per defined timespan) . Then, once I could know the frequency in Hz over a short interval, I could take care of the rest... ^_^

As it is right now, it seems like what I need really is FFT . So, I'll just need to find some time (I study in Computer Science at college, and it's keeping me quite busy... ) , read into it, and I should be able to do it on my own.

Also, something quite interesting, I've received an e-mail which had a link to a site :
http://www.relisoft.com/freeware/index.htm
This site has an implementation of frequency detection using FFT, so I might as well look into it, get to understand how it works, and somewhat use it to make sure I'm on the right track. There is even the source code available for download, so that should help me get on the right track.

I'll be coding the game in C++ , and I'll make it cross-platform. Any pointers as to how I could make the sound input cross-platform, so it can work on Win32 as well as Linux and hopefully Mac?

Thanks for the help guys, you've already helped me progress quite a lot in the right direction...

- Vince989

[edited by - Vince989 on April 14, 2004 3:49:20 PM]

##### Share on other sites
A word of caution: FFT isn''t something "you decide to look into and do for yourself". Just a fair warning - it''s somewhat more involved than a simple tutorial or two. Anyone who says they can write the FFT from scratch without reading up on dozens of related issues, is either lying or... well, lying...

You''ve got the bulk of the general theory as to how to do this right, but that doesn''t mean you can do it (most people can''t... and I''m not overestimating). If you decide to go with a 3rd part FFT implementation, you''ll be off doing whatever you want to do in a lot less time. Just something for you to consider. Also consider www.fftw.org.

TCP - Transmission by Carrier Pigeons

• 10
• 17
• 9
• 13
• 41