Inspiration

Musical instrument players often need to adjust the pitch of the instrument according to the standard frequency. For musicians who are not so accurate, a tuner is indispensable. An electronic tuner can provide accurate and fast sound pickup and frequency judgment, to inform the user whether the note is sharp, flat or in tune.

Metronome is also an important tool for musicians. Traditional mechanical metronomes have a pendulum that swings back and forth to produce beats, but they are bulky and not easy to carry. By integrating the metronome function into an electronic tuner, the tuner can produce beats according to the rhythm and speed set by the user so that it is portable and easy to use.

What it does

This project integrates an electric tuner and metronome. This system is mainly an auxiliary tuning tool for guitars and violins to gather sound through a microphone and tell the user whether the pitch is accurate. At the same time, it has a metronome function, which can produce beats of different speeds and rhythms. An LCD screen is used as an output device to provide an interaction interface.

How we built it

I use a sound sensor to transfer sound signal into electric signal. This can be done by a condenser microphone. The module of microphone with MAX4466 amplifier is used as a sound sensor for this project. The gain is adjustable from 25x to 125x.

After sampling the signal, I take the average of every 5 samples as a data point and do 300 point autocorrelation. A state machine is used to detect the first peak of the autocorrelation function. Then, I tested a set of data and use data fitting to find the relationship of the output of the state machine and the real frequency. After the frequency measurement, the system finds the closest frequency, show the name of the pitch, and tell the user whether it is too sharp, too flat, or just in tune.

Two timers of the Atmega328P are enabled to generate beats.

Challenges we ran into

The most difficult part for me is to process the data from the ADC. At first, I tried to collect 512 data points from the ADC and do the autocorrelations, but I found that Arduino's memory is not enough to open a 512 long type array. Because we do not require too much data accuracy and only care about the frequency, I changed the ADC into left align and read ADCH only.

However, this brings a new problem that calculating 512 points autocorrelation causes the system to respond very slowly. When processing the data, I found that the sampling rate of Arduino ADC is too high for the sound signal which has low frequencies like 80Hz. To solve these problems, I took the average of every 5 samples and use 300 data points as a data set for autocorrelation, which makes it possible to measure low frequencies and increase processing speed at the same time. The average operation also acts as a low-pass filter to suppress high frequency noise.

The interface is also a challenging part because there are many display pages involved, and it took me a lot of time to correctly design the display logic.

Accomplishments that we're proud of

Overall, the project achieved the expected goal. The tuner provide tuning for guitars and violins. In the frequency range of 70Hz-500Hz, the system can measure the relatively accurate frequency, with an accuracy of about 5Hz. On the metronome page, the user can generate a beat with adjustable speed and pattern. The bpm ranges from 40 to 220. The rhythmic pattern can be changed among 4/4, 3/4, 6/8, 2/4, 1/4, 8/16, and 7/8.

What we learned

In the process of doing this project, I learned how to design, build and debug an entire system. I learned to read the datasheet carefully to use a chip correctly and thoroughly.

What's next for Musical Instrument Tuner with Metronome Function

Limited by the number of data points, this system is more accurate for frequency measurement from 70Hz to 500Hz. In the next step, I think the sampling rate can be adjusted by an adaptive method to make the measurement frequency range larger. At the same time, the accuracy of frequency measurement is not enough to tune a dense instrument like a piano. This is also a place that can be further explored.

Built With

Share this project:

Updates