Some Experienced Guitarist And Beginners Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Some experienced guitarist and beginners alike find the tuning of a guitar time consuming and difficult. Throughout the 20th century many aids have been made available but none that fully automate the process.

This project aims to build a working prototype of a fully automatic guitar tuner using Matlab. The Automatic Guitar Tuner will take both the skill and the time involved out of the process by tensioning the guitar string once the string is plucked. All the user must do is select which string is to be tuned and place the tuner on the tuning peg of the string. It will also tune the guitar in a certain correct fashion the way a guitarist should i.e. "tune up".

A closed loop control system is to be used within this project. This control system will act on the frequency signal it hears. The input for this system is frequency. Therefore the system must be able to recognize a frequency being played, compare this frequency to the desired frequency and then send the error signal to an actuator to tension the string accordingly.

As the frequency signal to be analysed will be an analogue one, digital processing will be necessary in order to the track its frequency. Different methods of frequency tracking will be discussed in this project and then selected depending on which is most suitable or practical. Suitable filtering for the signal must also be researched and selected.

Tuning pegs are used to tension a string on a guitar which in turn changes its frequency when plucked. An actuator is to be used in the design which will turn these pegs. A coupler will need designed and built for this. It will also be necessary to calculate the relationship between tuning peg position and the frequency change. A tachometer could will be used for this and its measurement used in a feedback loop. Response time may be decreased and the accuracy increased by the addition of this extra feedback loop. This is a possible area of difficulty within the project as each tuning peg can act differently depending on its quality.

The feedback speed of the rate of sampling will be important when it comes to getting a quick and accurate response. These areas will also be researched further throughout the project for the design.

Project Aim

Main Goals

The aim of the project is to design and build a fully automated prototype electronic guitar tuner using MatLab. The main goals are:

Design a suitable control system to control a motorized actuator based on frequency.

Researching then implementing a method of frequency recognition using Matlab.

Designing a coupler to fix the actuator to the tuning pegs.

Testing the entire system to achieve the quickest and most accurate response.

Other Goals

Another important goal is to have fastest response time possible. In general the reason of automating any process is to speed it up or to perform tasks which are repetitive and time consuming. Therefore this automated process will not be different. The tuner should be able to tune a guitar faster than someone could do it manually.

It is also important that the accuracy of the tuning be as accurate within limits of human hearing sensitivity.

Lastly it is important that when the string is being tensioned that is "tuned up". This means that if the string happens to be at a higher frequency than that of the desired frequency, it is to be lowered beneath the desired frequency first and then "tuned up" to the required frequency. The reasoning for this is that when a guitar string is tuned downwards there is more tension between the bridge of the guitar and the head than which will cause the string to go out of tune quicker. It is better to have the tension between the head and the tuning peg.

Summary of Goals

To develop a method of frequency recognition.

To develop a control system that is to control an actuator to tension the string based on the error signal.

To ensure a quick and accurate response from the system.

To simulate the correct way of tuning a string.

Background research

Mathematics of Music

All the sounds we hear are waves of higher or lower air pressure. The frequency, measured in Hertz, that these that these waves hit our ear drum determines the pitch or note that will be perceived by the listener. For example the first note usually learned by pianists is usually "middle C" which corresponds to 261.626Hz

Audible sounds for human lies between the frequency ranges of 20 Hz to 20,000 Hz. Humans perceive frequency on a logarithmic scale shown in figure 1. For example, when human perceive a frequency of 110 Hz to 220 Hz it is perceived the same as the difference between 440 Hz and 880 Hz. These three frequencies are call A3, A4, A5, and A6 respectively.

The difference between two notes of the same name (A4 and A5) is called and octave. An octave is divided into twelve equally spaced notes on an equally tempered scale. These notes are denoted by the symbols A, A# or Bb, B, C, C# or Db, D, D# or Eb, E, F, F# or Gb, G, G# or Ab. An increase between two consecutive notes(C - C#) is called a semitone. One fiftieth of a semitone is called and centitone [1]. This is the smallest change in tone that humans can perceive. Different musical scales also exist but this is the modern scale used almost everywhere.

Figure - Logarithmic Increments of Notes in Semitones

Knowing that A4 corresponds to 440 Hz, the position of all other notes can be calculated from the formula [2]:

The tuning of the strings on a guitar are E4, B3, G3, D3, A2, and E2. These notes correspond to the frequencies 329.6 Hz, 246.9 Hz, 196 Hz, 146.8 Hz, 110 Hz and 82.4 Hz respectively. This is the frequency range that will be dealt with when tuning a guitar.

Due to the fact that a note on a scale increase logarithmically means that the control system will be a non linear system.

Existing Guitar Tuning Technology

Tuning fork

One of the early tools used for tuning musical instruments was the tuning fork. The tuning fork is used as a reference note to the musician. When the tuning fork is struck it outputs a reference note. The musician is then able to tell whether his instrument is too high or too low a frequency and adjust it accordingly.

Figure - Tuning Fork

Strobe Tuner

Strobe tuners are the oldest form of electronic tuning device. It was invented in 1936 by the Kohn Corporation. Many of them are still being used today. The display of a mechanical strobe tuner consists of a motor driven translucent disc with a strobe pattern printed on one side. Behind the spinning disc is a light source usually consisting of several lamps or L.E.D's. These lamps flash at the same rate of frequency as the signal entering the input jack or microphone. However the disc spins at a set speed dependent on which note the user is trying to tune. When the radial displacement of the disc matches the flashing frequency of light the resultant image appears to stand still. If there is any discrepancy between the frequencies of light flashes versus the repetition of the pattern on the wheel it will appear to drift radically clockwise or anti- clockwise. The speed of which will represent the inputs signals distance from the desired pitch.

Figure - Mechanical Strobe Tuner (

Digital Guitar Tuner

Advance in technology brought about the invention of the first fully electronic guitar tuner. An electronic guitar tuner can be used with an electronic or acoustic guitar either with a guitar jack or with the microphone on the tuner. When using the tuner the musician sets the reference note that they want to tune to. They then strike a string on their guitar and the electronic tuner displays to the musician on an L.E.D screen. The screen shows a needle that tells the user by how much the guitar is out of tune and by how much. The main advantage of the electronic tuner over the strobe tuner is the smaller size. The first electronic tuner was invented in 1948, 10 years after the invention of the strobe tuner. Chicago-based Peterson Electro-Musical Products began building instrument tuners under the direction of Dick Peterson, a pioneer of solid state electronics. [3]

Figure - Digital Guitar Tuner (

Areas of research for Design

Digital Signal Processing

Digital signal processors (DSP's) take real world analogue signals like audio, video or temperature process them into digital signals. These signals can be then mathematically manipulated.

Figure - A Digital Signal Processing System

A DSP consists of three main components as shown above. The analogue-to-digital (A/D) converter transforms the analogue signal x a (t) at the system input into a digital signal x d [n]. A/D converters can be thought of as consisting of a sampler which creates a discrete time signal and a quantizer which creates discrete levels. The digital system performs the desired operations on the digital signal x d [n] and produces a corresponding output y d [n] also in digital form. The digital-to-analogue (D/A) converter transforms the digital output y d [n] into an analogue signal y a (t) suitable for interfacing with the outside world. [4]


The Selection of appropriate controllers will be necessary to control the actuator and tuning peg. The controller is the part of a closed loop control system which has an input of the error signal and produces an output which will correct that error signal.

"The output and input to the controller is often called the control law. There are three forms of such law, proportional, integral and derivative. In some system it is necessary to enhance the performance of the controller and this is achieved by introducing additional elements, called compensators" [5]

Proportional Integral Derivative controllers (PID) are used extensively control engineering. At least one if not all parts of this type of control will be used within the project.

Systems that require positioning of object often require a second feedback loop to reduce oscillations or overshoots. A tachometer for the instance of this project could be used to measure the tuning peg position and supply the system with a feedback. This will be a minor feedback of the system. "The term velocity feedback is used to describe a feedback loop that is not the value of the output but the rate of change of the output with time" [5]

Fuzzy Logic Control

Fuzzy logic is similar to Boolean logic. The difference being that Boolean logic deals with complete statements, either true or false. Fuzzy logic allows partial truth of partial falseness. Instead of mathematical relationships fuzzy logic expresses the relationship of inputs and outputs linguistically by the use of if/then statements. This can make the design of the control system simpler.

Design steps for a fuzzy logic controller:

Specify the ranges of the manipulated and controlled variables

Deduce the linguistic labels that can be used to describe these variables and specify the appropriate ranges of each label, along with the fuzzy steps.

Select the type of membership function and the parameter in that function for the manipulated variable and output variable

Determine the rules that will relate the linguistic labels of controlled variables. The execution of these rules gives the fuzzy output.

Select a suitable defuzzification algorithm to calculate the non fuzzy (crisp) value of the manipulated variable to be implemented in the process. [6]

Frequency Detection Methods

Fundamental frequency detection is an ongoing topic of research. "The basic problem is to detect the fundamental frequency ( form an analogue signal which is usually the lowest frequency component or partial, which relates well to most of the other partials. In a periodic waveform, most partials are harmonically related, meaning that the frequencies of most of the partials are related to the frequency of the lowest partial by a small whole-number ratio. The frequency of this lowest partial is of the waveform." [7]

Many algorithms are available for this process which can be implemented on a computer.

Time Domain Methods

The most basic form of frequency detection is to look at a waveform over time. Assuming that a waveform is perfectly periodic, the waveform can be looked at and the oscillation counted. The amount of oscillations in one second is inversely related to the frequency.

Another method is to measure the zero crossing rates of waves. This is a measure of a waveform crosses zero over time. There are problems with this method because most waveform will be made up of different frequencies which may cross zero giving inaccurate results especially with noisy signals.

Frequency domain Method

The Fourier transform decomposes a waveform into in sinusoids. This means that that Fourier transforms gives us another way to represent a waveform. As most waves don't have just one frequency the Fourier transform is a good tool to deconstruct the waves into each sinusoidal component.


"The Fourier Transform is a mathematical prism, breaking up a function into the frequencies that compose it, as a prism breaks up light into colors." - The World According to Wavelets (Barbara Burke Hubbard) [8]

The discrete Fourier transform (DFT) is used analyzing digitalized signals. The Fast Fourier transform (FFT) is a discrete Fourier transform algorithm. These are both known algorithms that can be implemented on computer through code.

Significance of Research

During the course of the project it is hoped to research and compare different methods of frequency recognition and to implement the most useful one for this project. Many of the methods researched thus far have been complex. A further understanding of these methods and how to implement them will be researched.

This research also aims to seek the difference between simulated results of the control system and the practical results. Tests will have to be carried out on the string of a guitar discover what characteristics it has and to predict how it will act in the control system to be designed.

The relationship between the input and output is non-linear for the Automatic Guitar Tuner control system. The project aims to be an explanative example of designing this type of system by detailing techniques used.

Physical Apparatus in System

Motor actuating device

The most important part of the system is the actuating device used to turn the tuning peg of the guitar. It was decided to use a DC motor with position feedback via an encoder. Before selecting a motor the torque required to tuner the tuning peg needed to be calculated.

Calculating the torque

The torque required to turn the tuning pegs of the guitar was too small to measure with the torque gauges available. In order to estimate the torque a small experiment was necessary. The guitar stood in a vertical position and the tuning pegs were turned so they were in a horizontal position. A copper pipe slot cut out in the center was attached to the tuning peg. A 70 gram weight was then hung from the pipe with a piece of string near the center. The weight and string were then slowly moved away from the center of the pipe until the tuning peg began to turn and the distance was measured. This was done multiple times for each string. The formula Torque = Mass x gravity x radius was used then to calculate the torque. Below are the results:

Table here.

The specification for the motor torque was set to double the maximum torque required to turn the peg which is 0.3 Nm.

Maximum Output Speed

The speed of the motor output is required to be similar to that of a human turning a tuning peg. It is possible to turn the peg one revolution in in 8 seconds or roughly 8 rpm. It was found that turning the tuning peg 1 radian is the equivalent of changing the frequency of a string by one semitone. If a guitar string is out of tune by two semitones the string could be tuned within 1.57 seconds.


The diameter of the motor and its shaft was to be small enough so as to be able reach a tuning peg without touching of moving the adjacent tuning pegs.

Motor and gear selection

Selection started with the gearbox. The chosen gearbox was the 275:1 planetary gearbox from Maxon.

The power on the motor to be selected was set to double 0.18W. The Re 13 e motor6V was the motor chosen.

Check power :

Check T stall :

Current at operating point :

Speed at operating point :

Output speed of gearbox :

The only compatible encoder :


Check resolution :

Motor Attachment to Tuning Peg

It is required to have a device which coupled with the motor shaft and that could also be temporarily attached on and off to the tuning pegs. This device was made from the handle of an old screwdriver. A hole was bored through the centre of the handle to match the size of the motor shaft. One end the handle was then filed to fit around the tuning pegs. With this arrangement the handle of the screwdriver is permanently fixed to the motor shaft and the motor can be moved from peg to peg.

Motor Board

The motor is used to perform functions that the PC is incapable of. It is going to be used to power the motor through an H-bridge. The direction of the PWM is to come from an Arduino microcontroller. The Arduino is also to be used to convert signals form the encoder into position. The software for the Arduino is to be written in C++.


Simulink is to be used to control the motor. The motor and gearbox are going to be represented in one Simulink block. This block is to be a single input, single output block that has a PWM input and output.

Flow Diagram Needed

The Motor Control System

This section is to describe the methods used to developing the motor control system. This involves modeling the motor as a transfer function and then developing the controller.

Modelling the system

Before it can be started to develop the controller the physical system must be modeled mathematically. Transfer functions must be derived for each part of the physical system that will form the control loop. Luckily there are only two components that need to be modeled, the gearbox and the motor. The tuning peg is not included as it lies outside the control loop and doesn't affect the system. The encoder is also not included as it is a sensor which provides the feedback part of the control loop. The closed loop system is shown in Fig.988798 below with the controller included in the forward path. The input to the system is the required position of the gearbox shaft in radians and the output is the current position. Subtracting the input from the output gives the feedback.

Fortunately the transfer functions for DC motors are derived in many books. A methd by Nise[kHHHHHHHHHHH] is used here to and derives G motor (s) as:

Where Output motor position

Input Voltage

Torque Constant

Back E.M.F constant

= Armature Resistance

Moment of Inertia of Motor and Load

Damping at Motor output

J m and Dm are calculated by combining inertia/damping of the rotor with the inertia/damping of the load projected onto the motor as follows:


The exact load of the load is not know so and estimation is to be used. The tuning peg itself weighs about 30g and its radius is 10cm. Using Jl = mr2 = 0.03 x 0.12 = 3 x 104 Kgm2. Then using J m = J r + J l /N2 it is found that J1 / N2 = 3 x 10-9. As this is so much smaller than J m it is safe to ingnore. There is also no specification for D r in the specification sheet and Dl is also unknown. Again as the gear ratio is so large it is safe to assume that Dm is negligible compared to . Subbing in the remaining values for in the G motor (s) equation gives:

The transfer function of the gearbox is the just a simple relationship of the gear ratio:


Now, combining Gmotor (s) and G gearbox (s) give the transfer function of the forward path:

Controller Design

For the moment, when designing the compensator the standard definition of 2% for the time it takes the system t reach steady state is to be used. This may change due to the specification laid out at the start of the project. Until further research and design is done this is the settling time used. The goal of the compensator is to achieve an over damped response from the motor in the shortest amount of time.

The forward transfer function G f(s) has one pole at the origin. This make the system have a zero steady state error. When this is true only a P or PD compensator is needed to improve the time and shape of the motor response. It is more than likely that the motor and gearbox system will experience nonlinearities that will change this response and move the pole form the origin. This may then require the use of a PID controller.

The program to be used in designing the compensator is "SISOtool", a program in Matlab. This program allows the user to quite easily make and use root locus plots. Figure 6 below shows the uncompensated system with closed loop pole at -1 and -80. By increasing the gain to 19 the response becomes critically damped and the closed loop pole move to -40.5 with a settling time of 0.15 seconds as shown in figure 7.

Further design is to be done using SISOtool.

Figure - Uncompensated step response (left) and root locus plot and bode plots (right)