Building an electronic guitar digital sound synthesizer using a programmable SoC

Sree Harsha Angara, Cypress Semiconductor

February 24, 2014

Sree Harsha Angara, Cypress SemiconductorFebruary 24, 2014

Digital sound synthesis has always been a subject of interest to me as a hobbyist. Recently, my interest was further piqued by a wiki page on the Karplus-Strong Guitar synthesis. I was intrigued by the simplicity of the synthesizer design. Here's the diagram from the Wiki page (Figure 1):


Figure 1: K-S block diagram from the Karplus-Strong Guitar synthesis Wiki

Also mentioned was the pitch of the note was decided by the delay L by a simple relationship,



Equation 1

where the filter coefficients determine the ‘stringiness’ of the note.

A noise burst? That’s it? That can’t be right! No way it’s that simple!

Like all hobbyists, I began by jumping right in to the implementation. The code took only a couple of hours to put together and I hooked up the DAC output to an oscilloscope. I could tell it looked vaguely sinusoidal with harmonics put together but had no clue what it would sound like (obviously).

A quick search later, I hooked up a pair of old head phones. I wasn’t expecting much, a lot of us know, the first time most projects either don’t do anything or if you’re really down on your luck, emit a tiny puff of white smoke(I prefer to think of it as the spirit of the chip passing on to the great beyond). I was really surprised when it actually did sound like a guitar pluck.

Something was up. Math ahead - you have been warned.

Let’s take a closer look at the diagram in Figure 2 below:


Figure 2: K-S block diagram - Annotations

The output of the synthesizer is a simple summation of the low pass filter output and the noise burst. In all the equations below a subscript ‘n’ indicates the current sample.


The Filter is a simple low pass filter of the form,


We’ll get back to what the exact coefficients a and b are a little later.

So essentially we get,


But since the input of the filter is nothing but the output delayed by L samples,


Rewriting the output of the filter as a difference of the output and input and moving things around a bit we get,



Changing this to time domain is achieved simply by substituting


where Ts is the sampling time.

After a little more effort we end up with a quite a large expression,


Thankfully, it’s pretty easy to find the magnitude response by sweeping the frequency ω with Excel.
The sampling rate is set to 44.1ksps (being the least amount which can sweep the whole range of hearing).

From Equation 1, to generate a 200Hz tone the delay ‘L’ will be 44100/200 = 220.5

Since our delays are digital, A close value of 220 is chosen. I arbitrarily chose the pole of the low pass filter value of 10KHz to start off with. This pole frequency decides the value of ‘a’ and ‘b’ we mentioned earlier.


Figure 3: Frequency Response

From the response shown in Figure 3,, we can clearly see that if we pass a wide-band noise signal (or as I prefer to look at it: a signal whose energy is spread across all frequencies), the output you would see is a fundamental of 200Hz followed by the 2x, 3x, 4x…. harmonics. This is almost exactly how an actual guitar behaves when plucked; The fundamental is followed by the associated overtones as shown in Figure 4.


Figure 4: Guitar Overtones

< Previous
Page 1 of 2
Next >

Loading comments...

Most Commented

  • Currently no items

Parts Search Datasheets.com

KNOWLEDGE CENTER