# Guitar String frequency

I'm making a guitar tuner for iOS.Due to the fact I'm Beginner I'm struggling a bit to gather all the resources and information about it. I know the theory like ( correct me if I'm wrong ) :-

1. First I need to get the input from microphone.
2. Then need to apply apply FFT algorithm to get the frequency
3. Then compare the frequency with the fundamental frequency of notes.

according to my research the fundamental frequency of the guitar are measured as:-

String  Frequency
1 (E)   329.63 Hz
2 (B)   246.94 Hz
3 (G)   196.00 Hz
4 (D)   146.83 Hz
5 (A)   110.00 Hz
6 (E)   82.41  Hz


and from an test app example I'm getting the frequency:-

String  Frequency
1 (E)   333.02  Hz
2 (B)   247.60  Hz
3 (G)   398-193 Hz    (398 when start and 193 when end)
4 (D)   290-150 Hz    (290 when start and 150 when end)
5 (A)   333-215 Hz    (333 when start and 215 when end)
6 (E)   247-161 Hz    (247 when start and 161 when end)


One thing to notice the example was showing the Max Frequency.

So what I'm asking here is there anybody who have implemented this before and give me the direction and some detail information about the topic so In future nobody have to research more and more to gather all the resources.I need help with the following topics:-

1. What is the best possible way to get the accurate frequency of guitar string.
2. Which type of frequency need to tune a guitar like maxFrequency, is there a role of altitude, magnitude (i have less information about this topic).
3. What to do after getting the right frequency.

Any help would be truly appreciated and my apologies in advance if i'm asking something stupid .

• You need to look up how to detect/estimate/measure pitch, not FFT frequency peak. Two different things. – hotpaw2 Feb 22 '17 at 5:07
• soo there is no role of fft? @hotpaw2 actually i'm making an ios app for that i need to capture sound from mic and use fft algorithm to convert it to frequency. – dreamBegin Feb 22 '17 at 5:14
• An FFT can have a role as a component of another pitch estimation method. Don't just use the magnitude peak. Maybe H.P.S. or Cepstral analysis, et.al. Or a time domain lag/match based estimator. – hotpaw2 Feb 22 '17 at 5:27

## 1 Answer

The fft provides the spectrum of the audio signal, which tells you the frequencies your signal is made of. In the case of harmonic signals like guitar, violin and other musical instruments, the spectrum exhibits peaks that are (almost) equally separated. For example, 110, 220, 330, 440... Hz. These peaks are called harmonics and they have different amplitudes, which contribute to the perception of timbre.

The perceived note (aka the pitch) depends on the frequency of the first peak, that is the fundamental frequency. It could happen that the fundamental frequency, which is what you want to retrieve with your tuner, is not the strongest one in terms of amplitude. For this reason, you need more complex techniques than just retrieving the maximum of the spectrum. I suggest you to google pitch detection, which is the problem you are working on. There is a lot of material and possible solutions that you can compare and implement.