You are expecting something wrong!
No library error
Regardless of whether the library creates it correctly or not, you are looking for a pattern that rarely exists in real sounds. Only an ideal sine wave generated electronically will cause a discrete discrete signal to appear in frequency. graph. If you do not believe this, try running the “spectrum analyzer” visualization in winamp or media player. This is not so much a PC error.
Real Sound Waves - Complex Animals
Depict a sawtooth or square wave in your brain eye. these sharp turns - angles or points on the wave, are like tons of higher harmonics on an FFT or even a real Fourier. And if you have ever seen a real “square wave / sawtooth” on the sight or even a “sinusoidal wave” created by the tool that was supposed to create a sinusoid, look at all the sharp corners and cracks only ONE note (if you don’t have a frame, just zoom in on the courage - the more you zoom in, the higher the notes you look at). Yes, these deviations are considered frequencies.
It is difficult to tell the difference between a single note and an entire orchestra, sometimes in spectral analysis.
But I hear solitary notes!
So how does the ear do it? He considers the whole waveform. Then your lower brain lies in your upper brain about what constitutes an input: one note, not a mess of overtones.
You cannot do it as completely, but you can get closer to it through "training."
Approximation: the creation of some skills
PLAY the notes on the instrument and “save” the frequency graph. Do this for notes in several frequency ranges or, better, all notes.
Then interpolate notes to fill in the blanks (1/2 or 1/4 steps) by multiplying the saved charts for this tool by 2 ^ (1/12) (or 1/24 by 1/4 steps, etc.).
Define how to store them in a rapidly changing data structure, such as BST or trie. Only he would have to return "how close is this account." He would have to identify the match through the proportions of frequencies, as well as if he came in different volumes.
Using smarts
The next time you look for a note from this tool, just take a “heard” frequency graph and find it in this data structure. You can record several instruments that form various waveforms and look for them too. If there are background sounds or a few notes, make the closest match. Then, if you want to identify other notes, "subtract" the found frequency diagram from the sample and rinse, repeat the repetition.
He will not work with your voice ...
If you've ever tried to tune yourself by drinking a guitar tuner, you will find out that tuners are not so smart. Of course, some instruments (esp voice) really float around the field and generate an ever-changing waveform (even without singing).
What are you trying to accomplish?
You didn’t need to fully take this fantasy for a “simple” tuner application, but if you do not use only one tuner application, I assume that you really want to identify notes (for example, maybe you want to automatically generate midi files from songs on the radio ; -)
Good luck. I hope you find a library that does all this stuff instead of collapsing your own.
Change 2017
Take a look at this web page: http://www.feilding.net/sfuad/musi3012-01/html/lectures/015_instruments_II.htm Well down, there is a spectral analysis of various organ tubes. There are many, many overtones. You can find them - with enough work - if you first train your application with them (just like telling a child, "this is what the clarinet sounds like ...")