Pitch Detection on Arduino using Autocorrelation

In this first part of Arduino Pitch Detector, I describe the hardware parts and their interconnects.

Hardware

The Arduino receives input through a microphone, displays results on display and outputs the MIDI commands through USB Serial on the Arduino itself.

Schematic

This project uses input from amplified microphone and outputs to a TFT display and USB-midi connection. It reuses the USB connector by replacing the firmware on the ATmega16U2 companion chip as described on the page Sending MIDI Events.

Materials

The components listed below are available from hobby stores like Adafruit and Sparkfun, or from electronic supply shops like Mouser and Digikey.

Materials
part price
Arduino UNO R3 $6.22 Push button$0.15
Microphone $7.50 Total$13.87

The optional screen costs \$19.95.

Microphone

For the microphone, I use the Adafruit microphone breakout. because it has a 1.25V DC bias and includes an automatic gain control. Other microphones will work for as long as they have a DC biased output, and the output signal is strong enough.

Arduino

The popular Arduino UNO R3 forms the heart of the system. Note that the REPLAY signal was only used during debugging.

If you’re going to reprogramming the Atmega16u2, you need access the companion chip header (ICSP1) as marked in the illustration below.

Display

For the display, I chose an 1.8″ TFT LCD screen. I went back and forth between using the Adafruit breakout and Shield. The advantage of this particular LCD screen is that it comes with a library and includes a μSD card reader. The module connects to the Arduino using the SPI interface. More details about SPI can be found in the article Math Talk.

Replay Push push button

Occasionally, I use a push button to replay stored MIDI notes. The push button is active low. To use this, you need to enable USB_MIDI in the config.h file.

USB-midi switch

When this switch is closed during power-up, the companion chip functions as a UART/USB-MIDI bridge. Otherwise, it does its usual UART/USB-SERIAL conversion. Refer to MIDI events for details.

The next page of this article describes the signal path and introduce the software modules.

Student at MVHS
I see education as the foundation upon which entrepreneurs are able to build innovative organizations and execute their vision for the future.

4 Replies to “Pitch Detection on Arduino using Autocorrelation”

1. Brecht Humasol says:

Hello,

I want to know the frequency of the power grid, but harmonic frequencies in the power grid are a huge problem.
Can you send me a code for ‘filtering’ fundamental? (0-150Hz max)
Thanks!

2. achala says:

great works !!!

3. Romain says:

Hello,

First of all, this a great work ! Not only just a sample stuff but very documented, you shoudl be proud !

I’d like to use it for a guitare. Do you think it will work ? Did you test it ?

Finally, did you make a video of it to see how good it works ? :)

Thanks for the sharing and keep having fun making all these things :)

4. Denis Bélières says:

Hello. Bravo for this work …
I am a retired electronic engineer, and I designed a tuner working with FFT on a PC with a professional tool : Labview from National Instrument, which offers huge signal processing libraries. I wanted a very precise instrument to tune the reeds of a vintage italian accordion (Paolo Soprani, 1915). I am also playing bassoon, and then concerned with bass notes. I encountered many difficulties with low frequency cut off of the microphones, giving signals with harmonics far higher than fundamental (up to 20 dB). The lowest note of my accordion is a Bb at 58.27 Hz, on the left hand chords. This is also the lowest note of the basson. Precise measurement need very long sampling of several seconds !
Well, now, I want to buid a little funny gadget which will animate a “snake” poping out of a basket in relation with the recognised notes … I am very interested by your work, but I think i will use a more powerfull processor than the Arduino uno, and then higher sampling frequency and 500 or 1000 samples.

This site uses Akismet to reduce spam. Learn how your comment data is processed.