Jump to content
  • Advertisement
Sign in to follow this  
Woody FX

Guitar Tuner Theory

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am planning to implement a guitar tuner in C++ but i need some help to go in the correct direction. I understand the over all concept. I need to take in a sound recording for example 10 times every second and find the pitch of the wav form and then compare it against what is the known pitch of the the note the person wants to tune the guitar to. What kind of algorithm is best suited to this. Would there be some kind of filter algorithm that is needed to be run to clean out back ground noise ? Are there any other proceedures needed to prepare the sqçple sounds? Any advice would be much apprecited. Thanks Guys

Share this post


Link to post
Share on other sites
Advertisement
Though you could do it with a fourier-transform, i think this would be overkill.
Search for 'Autocorrelation', that's what i would try. The idea is basically that you compare(multiply) your wave-data with a shifted copy of it. for each 'lag'-value you get a measure for the correlation. If you shift your wave-data one period your correlation should be high. so you can find the period of your wave-data by finding the biggest correlation. I hope that gets you started

Thies

Share this post


Link to post
Share on other sites
Either that, or just generate a pure waveform of whatever frequency your note is meant to be, scale it to be equal in amplitude to the incoming sound, and add it to the incoming sound. You'll get a resulting frequency which is the difference between the two, and if it's anywhere near in tune this frequency should be in the 10s of Hz, which you can then just sample directly at 100Hz or so to find out how close to 'in tune' your guitar is.

/end stream-of-conciousness. this may not work.

Share this post


Link to post
Share on other sites
I don't know other methods, but once I did this using Fourier Transform (FFTW as implementation). It was a bit hard because I never worked with sounds and FFT, but at the end I came out with something working (a little).
I used FMOD to record the sound, and then I processed it with FFTW that returns a buffer filled with coefficients. Using an equation on them you get the frequency of the sound. I tried with a diapason (<-don't know the english word) and it worked. With my guitar the result was not always correct, because sometimes it told 110hz or 220hz, other armonics of the 440hz of the A note, but there should be some alg. to filter out what you don't need.
If you want to have more infos you can look throught my previous posts where many people helped me. If you think it can help you I can send my code (but it is very bad designed and written) in a Dev-c++ project.

Share this post


Link to post
Share on other sites
When you get the basics working...:

My brother has a guitar tuner that (I think) takes into account the fact that the pitch changes as the note continues to sound. I _think_ his tuner locks onto the note a fraction of a second after it starts - which is presumably the pitch you tend to hear when playing.

If you use a FT to get a power spectrum, the pitch that you perceive isn't necessarily going to be at the frequency containing the highest power-density - it's probably offset a little bit because the ear/brain has its own frequency response. Maybe it's an insignificant effect... but I'd read up on it if I was doing this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!