Pitch Detection on Arduino using Autocorrelation

This is the second part of the article about the Arduino Pitch Detector. It describes the signal path starting with the instrument sound and ending with the sound produced by a MIDI synthesizer, possibly driven by auto-accompaniment software.

Signal Path

In the prototype, the signal passes from a music instrument and is played as MIDI events on an external synthesizer. Various hardware and software components make up the signal path. This page gives a brief description of each of these components.
Pitch detector signal path

  1. Musical instrument. Playing a clarinet, pan flute or piano.
  2. Microphone with automatic gain control.
  3. The microcontroller is responsible for:
    1. Digitizing the analog signal (microphone.cpp).
    2. Detecting the fundamental frequency and pitch of the signal (pitch.cpp).
    3. Determining the beginning and duration of the notes. (segment.cpp, segmentbuf.cpp )
    4. Displaying the notes on a tremble staff or piano roll. (pianoroll.cpp, staff.cpp)
    5. Sending MIDI events to an attached synthesizer. (midiout.cpp).
  4. An external synthesizer interprets the MIDI messages to create sound. The MIDI signal can also be sent to auto-accompaniment software (e.g. Band-in-a-Box) or Notation software (e.g. MidiEditor).

To test the MIDI functionality of the Arduino, it needs to be connected to a synthesizer. A synthesizer interprets MIDI messages to create sound. Synthesizers to range from all-in-one hardware synthesizers, to software synthesizers (Cool Virtual Midi, Nano, GarageBand).from http://learningworksforkids.com/apps/garage-band/
A synthesizer interprets MIDI messages to create sound. There are many synthesizers to choose from:

  1. Hardware. I found an old SynthStation25 in our garage and use that with an old iTouch running the Nano app.
  2. Microsoft Windows comes with a “Microsoft GS Wavetable Synth”. It has horrible latency and sounds bad.
  3. I ended up using, and iPad with Garage Band. The messages can be carried over USB (requires the Apple iPad Camera Connection Kit) or over possibly over the network (AppleMIDI). When using USB, connect the USB cable first, and then plug the adapter into the iPad. For the connector, refer to the corresponding section above.

The next page of this article describes the compile toolchain required.

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. 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. 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 :)

  3. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

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