Take the 2-minute tour ×
Sound Design Stack Exchange is a question and answer site for sound engineers, producers, editors, and enthusiasts. It's 100% free, no registration required.

I am trying to write a small application which would try and recognize notes within a recorded sound.

I don't know much about sound theory, and I am having a hard time figuring out how digitalized sound actually works.


All I've been told is to calculate a Fast Fourier Transform to get a list of frequencies and then try and convert the strongest frequency into a note.


Any ideas?

share|improve this question
1  
This question could be clearer. Are you asking how to recognize notes from a sound sample, or you asking for ideas because you're stuck? –  neilfein Jan 4 '11 at 14:37
    
@neilfein: asking for ideas, I guess asking how to recognize notes would be too much to ask, not sure –  RadiantHex Jan 4 '11 at 14:41
3  
@neilfein: I'd agree the question is a little vague but it's not subjective. In this case it's vague because the OP is asking where to start. Warrior Bob gave a good general overview in his answer. From that the OP should be able to get a start and perhaps ask more specific questions. –  BenV Jan 4 '11 at 16:01
2  
While I would otherwise suggest closing the more vague questions, there are a lot of those questions that come up in audio discussions. I figure we don't have a lot of questions on here yet, so if there's some clear benefit to be gained, I can't see a reason not to give an answer a try. It just means that one answer probably isn't going to be the 'right' or 'best' one. –  Warrior Bob Jan 4 '11 at 17:15
1  
For ideas, you might be interested at looking into Sing & See & Pitch Primer, have tried the first one which works fine enough but the second one seems to be more solid from what I see in the video... But that would require me to buy an iPhone. :-( –  Tom Wijsman Jan 5 '11 at 10:08
show 6 more comments

migrated from video.stackexchange.com Feb 21 at 11:04

This question came from our site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation.

3 Answers

up vote 10 down vote accepted

This kind of broad question doesn't really imply a specific answer, so I'm going to go with an equally broad answer that, while not precise, might still be helpful.

You'll want to know the basic idea behind Fourier's Theorem which is that all waveforms can be expressed as a sum, possibly infinite, of sine/cosine waves. Wikipedia's page on Fourier series strikes me as good, although it's more technical than you might need, what with all the math. This is the idea on which Fast Fourier Transforms work - take a sample of your signal in, get a mostly-correct list of the component sine waves (which is to say, frequencies) which sum together to make that sample.

From those you can decide which one is your fundamental frequency, and convert it to a note based on what its pitch is.

Digitized sound works, like Lennart Regebro said, by simply writing down the amplitude of your soundwave on a regular interval as a number. There are two factors you'll immediately be concerned with: Sampling Rate, which is how many such notations are made per second, and Bit Depth, which is the amount of data and therefore the resolution of those notations. You might've seen 44.1KHz/16bit in reference to CDs. That's what these are: 44.1 thousand samplings per second, and each one of them is 16 bits, so possible numbers are 0 to 65535.

Do keep in mind that I've never written such an application, but this is what I've picked up about how such software works.

share|improve this answer
1  
Excellent practical explanation. –  BenV Jan 4 '11 at 15:57
3  
While the algorithm is well understood, writing a fast implementation takes a fairly large amount of effort. Unless you're trying to beat the competition with a faster implementation, just go for a library that already does fast Fourier transform (FFT). Here's the link to a FFT C/C++ library: fftw.org and for Java implementations, take a look at this StackOverflow topic: stackoverflow.com/questions/636686/… –  Kim Burgaard Jan 4 '11 at 20:11
    
Bob: thank you a lot for your detailed answer. It has helped me a lot! –  RadiantHex Jan 5 '11 at 11:43
    
Once you have determined the frequencies in a sample, then take a look at this topic on the relation between frequencies, scales and notes: math.stackexchange.com/questions/11669/… –  Kim Burgaard Jan 13 '11 at 3:21
add comment

Digitized sound is just a sequence of numbers recording the amplitude of the soundwave at equal intervals (most often 44100 times per second).

Applying FFT and finding the strongest frequency, or all frequencies above a treshold sounds like a reasonable way of finding the note. Converting the frequency into a note is easy, once you know that middle A is 440Hz, and that notes are "logarithmic", ie the next higher A is 880Hz and the next 1760Hz, etc.

share|improve this answer
    
thank you so much! I did not know they were logarithmic. Sorry if I ask, but would you have any good online resources you would recommend? –  RadiantHex Jan 4 '11 at 14:46
2  
@RadiantHEx: Not really, but here is a list of the notes and their typical frequencies: phy.mtu.edu/~suits/notefreqs.html I've been a hobby musician for 30 years, so I've learnt this bit by bit, so I don't know of any good resources. Wikipedia always helps of course, but I'm sure you figure that out already. en.wikipedia.org/wiki/Digital_audio :) –  Lennart Regebro Jan 4 '11 at 15:54
add comment

If you are looking for specific tones, or a small number of tones, you can also use Goertzel's Algorithm:

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

Useful for things like DTMF.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.