Go Down

### Topic: Reading Guitar Frequencies (Read 2546 times)previous topic - next topic

#### MKona

##### Jul 06, 2015, 04:54 pm
Hi everyone, I'm building an electric guitar in one of my engineering classes over the summer.  The goal of the class is to modify an existing object or create your own project.  My idea is to make an electric guitar that teaches by sight and sound.  I want to use the Arduino so that each time a different note/frequency is played a different color LED light lights up.  I've done a lot of research but I can't find any websites/posts in the forum explaining how to set up the Arduino to do this, any suggestions?

#### tmd3

#1
##### Jul 06, 2015, 09:07 pm
Your project's primary task is to estimate the frequency of a signal.  That's also the first task that a guitar tuner performs.  You might have luck looking for a guitar tuner on the forum, or an Arduino guitar tuner on the web.

#### gruberator

#2
##### Jul 12, 2015, 04:45 pm
To take out frequencies out of the signal use Fast Fourier Transform FFT library  - google it and understand what it does.

The library i recomend for arduino is FHT library link

In the pasted link you will find code example on how to use it.

Learn what sampling rate and nyquist frequency is.

What you want to do is to detect 12 musical tones out of few guitar octaves.
Check table with tone frequencies
You can also find a formula to calculate notes in each octave:
frequency calculation formula

Fht will give you FHT_SIZE/2 bins of output data which can be calculated into frequencies from the formula:
bin_freq = sampling_rate * bin_nb / FHT_SIZE
Read library description as there are few output types like linear, logarithmic, etc...

The bigger sampling rate is, the more bandwidth is sampled (bandwidth from 0 to SR/2 Hz), but
each bin width is greater too so you loose on frequency resolution.
In my project i use sampling rate = 1760  as the max frequency is 880 Hz which gives me decent resolution to detect sounds from the beggining of the fretboard.

Now i met a lot of code examples in which sampling is done in main loop. If program does only this its ok, it works, but don't be a noob and use timer interrupt to do proper sampling. Otherwise if your program does something else than sampling and processing, for example you add some interrupt handlers for some external communication signals - your sampling rate may change - or you may sample not in right moments, so the FHT output will be distorted.

Hope it helps, keep on diggin !

Go Up