K
K
KiriKiri2010-09-28 01:30:08
Audio
KiriKiri, 2010-09-28 01:30:08

Algorithms for processing and analyzing sound

I would like to write my own software tuner for the guitar (similar to AP Guitar Tuner), but unfortunately I am not at all familiar with this topic. I can roughly imagine what is needed for this, but I don’t know how to approach the problem. Recommend resources or literature on relevant topics. Thank you.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
megalol, 2010-09-28
@megalol

musicdsp.org and evon forum and e-mail list.
In Russian - any book on digital signal processing will give a normal base.
According to your situation, the algorithm is as follows:
microphone (sound) => ADC (digital array) => window FFT (array of complex numbers) => array of amplitudes (array of real numbers) => relative maximum frequency => maximum frequency => note
For your situation you need to know the API for picking up sound from the microphone. Api will issue portions of sound in chunks, say, 1024 floats each. (With a sample rate of 44100, this would be 44100/1024 = 43 milliseconds).
You need to apply a windowed Fast Fourier Transform (FFT) to this piece, look somewhere for a normal article that explains it (a book on digital signal processing will come in handy). There are a bunch of library functions on the internet.
To know what the conversion actually does, I advise you to install Adobe^W Audition^W free audio editor with a spectrum analyzer and see what is done with the sound of different notes, what is affected by the window size, etc. The brain itself also works with the spectrum, and not with the signal itself, so intuitively everything is understood with a bang.
With FFT, the more data, the greater the spectral resolution. For the required resolution, it may be necessary to FFT 8192 bytes or so. FFT will give an array of 8192 complex numbers, the modulus of each of these numbers will give the amplitude of the spectrum. In this case, the values ​​4096-8191 will be a mirror copy of 0-4095, this is a feature of the algorithm. For complex numbers, you can get the amplitude, the phase is not needed in this case, and the amplitude is sqrt (re ^ 2 + im ^ 2). Well, then search for the maximum in the array.
The maximum will be the relative frequency (the array is 0-4095, and the frequencies are 0-44100/2). To convert absolute to relative, you need to multiply by 44100/8192 in proportion. Those. by the sampling rate divided by the FFT window size. And now translate the frequency into a note. There is an exponential dependence (the frequency of the next note is higher than the frequency of the previous one to the twelfth root of two), using a tablet like (A4 440; A # 4 465.96] it is not difficult to find the nearest one.

K
KiriKiri, 2010-09-28
@KiriKiri

Thank you very much!

X
xSkyFoXx, 2010-09-29
@xSkyFoXx

I could also recommend the book Fundamentals of Analog and Digital Sound. Read a brief info about it and places where you can buy it - here .

Y
Yakhnev, 2010-09-29
@Yakhnev

I recommend a great example on Codeproject , a working tuner written in C#. For the fast Fourier transform, the FFTW library is usually used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question