CC Blog Projects Research & Design Hub

Building a Tri-Effect Guitar Pedal

Figure 1 The guitar pedal

Using a PIC32 MCU

Guitar pedals digitally manipulate input audio signals in real time, to generate modified sounds and create interesting sound effects during live concerts. Using a PIC32 MCU to control audio parameters for each effect and change the output sound, these Cornell undergraduates built a pedal with three effects, instead of the usual single effect.

  • How to build a tri-effect guitar pedal?

  • What are the effects of distortion, flanger, and delay?

  • How to design hardware and software?

  • What are the functionalities of the guitar pedal?

  • How does a tri-effect guitar pedal work?

  • PIC32 microcontroller

  • Light-emitting diodes (LEDs)

  • Analog potentiometer

  • High-pass filtering circuitry

  • Analog-to-digital converter

  • Digital-to-analog converter

From the addition of reverb to increase depth in vocal tracks to digital filters that remove noise from drum beats, nearly every modern song incorporates audio effects. When used with guitars, these effects are so ubiquitous that their sounds (such as distortion) have become directly associated with the instrument itself. Guitar pedals create these audio effects by capturing input audio (usually clean inputs from electric guitars) and manipulating it to create differently, and typically much more complex sounds.

Our guitar pedal project was an opportunity to implement concepts from digital signal processing, and to explore the capabilities of the Peripheral Interface Controller (PIC32) microcontroller. We created these effects by manipulating sound and reading external input (including audio and user input). This project also explored several different electrical and computer engineering concepts. On the computer engineering side, creating our guitar pedal required extensive use of the C programming language and interfacing with I/O devices. We used the PIC32 to execute digital signal processing algorithms, and implemented schedulers to sample and process audio at high speed. On the circuitry side, we used buttons, light-emitting diodes (LEDs), and analog potentiometers for the user interface and added high-pass filtering circuitry; this enabled the analog-to-digital converter (ADC) to read the guitar signal. Additionally, we soldered the components together and developed a physical container to house the microcontroller, breadboard, and wires in a single box.

We used the PIC32 microcontroller entirely for the project and programmed it in C using the microchip-provided Peripheral Software Library (PLIB). Our pedal worked successfully when tested using a guitar and a 0.25” jack connected directly to the pedal, with the output connected to an audio amplifier to broadcast the manipulated sound.

SYSTEM OVERVIEW

Our pedal produces three effects—distortion, flanger, and delay; all three effects can be user-modified by using adjustable knobs to change parameter settings. To activate an effect, the user presses one of three buttons on the control panel, and each parameter for the active effect can be adjusted separately using the three knobs on the panel. LEDs under each button inform the user of the active effect and the pedal power status (Figure 1). Input and output audio signals are acquired and transmitted using two standard 0.25” audio jacks on the sides of the pedal for ease of use.

Figure 1 The guitar pedal
Figure 1
The guitar pedal

Summary of Effects: The various parameters of each effect can be changed using the three knobs on the pedal. The middle knob sets the mix parameter for all three effects; this value determines how much effect is applied to the input signal. A low mix means that the clean, “dry” signal would be much louder in the output relative to the altered, “wet” signal, and the opposite for a high-mix value. The other two knobs are effect-specific.

Distortion: Distortion bestows a harsh, or “dirty” tone upon the guitar riffs that are the hallmark of classic rock music. This effect is created by clipping an audio signal when its magnitude surpasses a fixed threshold. Due to the higher-pitched harmonics generated by flattening the waveform, the altered audio has more aggression and “bite” compared to the clean (unaltered) sound. After clipping, we rescale the audio signal to its previous range to preserve the input volume. Because heavy signal clipping can generate harsh tones and render the original signal nearly unrecognizable, we also apply a low-pass filter (LPF) to the clipped signal. The LPF smooths the waveform to produce a gentler sound, and the cutoff frequency of the filter can be adjusted by the user to suit individual needs.

The user activates the distortion effect by pressing the red button on the pedal, and the red LED illuminates to indicate this.

In addition to the mix, this effect is also controlled by the Gain and Tone parameters.

Gain (left knob) controls the amount of distortion applied to the input signal (Figure 2). It effectively changes the threshold for clipping; higher gain means that more of the signal is clipped, yielding a more distorted sound.

Tone (right knob) allows users to set the cutoff frequency of the LPF applied to the distorted signal. A high cutoff frequency increases the harmonic content of the output signal, resulting in a harsher sound, whereas a low cutoff frequency attenuates loud harmonics to yield a gentler sound.

As previously mentioned, the distortion effect consists of two steps: clipping the signal to achieve a distorted sound and smoothing the signal with a LPF. To clip the signal, two thresholds (equidistant from the mean value of the audio signal) are applied to the ADC readings to restrict the signal to a user-defined range. The signal is then re-scaled to the minimum and maximum values of the original audio input to preserve its volume. The distance of the threshold values from the mean input value is set by the position of the right knob. After clipping and re-scaling, the signal is low-passed using a digital complementary filter, with a user-defined cutoff frequency set by the Tone parameter.

Delay: The Delay effect mixes in a delayed version of the audio signal with the current audio input. Longer delays are often perceived as having an echoing quality, whereas a shorter delay (“slapback”) can give a more complex sound to instruments when the copied sound lends a “bounce” to the original sound as it fades. With even shorter delay times, the duplicate sound is hard to distinguish from the original, so instead of creating a noticeable echo, the timbre of the sound changes. This change in timbre can be applied to help vocals sound fuller.

The user activates the delay effect (Figure 3) by pressing the blue button on the pedal, and the blue LED illuminates to indicate this.

In addition to the mix, this effect is controlled by two parameters: Feedback and Delay Time.

Feedback (left knob) adjusts how much of the echo is saved alongside, or fed back into, the new input signal. A low feedback parameter means that the sound is only repeated once, and a high feedback parameter generates a repeated echo that fades over time.

Delay Time (right knob) adjusts the temporal delay between the original signal and its echo. With a high Delay Time value, the echo appears after a longer delay (maximum 0.25 seconds), and a low Delay Time value can create slapback delays or timbre changes as previously described.

To implement the delay effect, an array stores the ADC readings of the input audio signal. The current input audio adds past values of the array to calculate its final output signal; the Delay Time parameter sets the amount that we look back into the array. To incorporate feedback, an array of output values is also maintained. Rather than simply summing the input with the time-delayed previous input, both the time-delayed previous input and past output are added to the current input to generate an echoing effect. The Feedback parameter controls the fraction of past output that is added to the current input, and the resulting sum is normalized to ensure that the Feedback parameter does not affect the output signal amplitude.

Flanger: Flanger is a type of modulation effect that uses a periodic low-frequency oscillator (LFO) to adjust the input signal. The LFO output gives the output signal motion even when the input stays constant. To generate the flanger effect, a short delay (typically less than 20ms) is applied, but the delay time is modulated by the LFO. Because the delay is quite short, an echo in the output signal is not audible; rather, the timbre of the sound is modulated as the waveform begins to interfere with itself. Here, the amount of interference changes temporally because the delay time is changing periodically. The effect is often described as lending a “whooshing” feeling or twang to the sound.

Our flanger effect is activated when the user presses the yellow button on the pedal, and the yellow LED illuminates to indicate this.

Besides the mix parameter, the flanger effect (Figure 4) is controlled by the Rate and Depth parameters.

Figure 2
 Distortion applied to a sine wave. The original signal (blue dashed curve) is restricted between two thresholds (dashed green lines) to produce the distorted output signal (solid red line).
Figure 2
Distortion applied to a sine wave. The original signal (blue dashed curve) is restricted between two thresholds (dashed green lines) to produce the distorted output signal (solid red line).
Figure 3
The delay effect applied to an input sinusoid. Both the time-shifted waveform (solid red curve) and original input waveform (dashed blue curve) are output by the pedal, and their relative amplitudes are modulated by the mix parameter.
Figure 3
The delay effect applied to an input sinusoid. Both the time-shifted waveform (solid red curve) and original input waveform (dashed blue curve) are output by the pedal, and their relative amplitudes are modulated by the mix parameter.
Figure 4
The flanger effect applied to an input waveform. The output waveform (red) is a delayed version of the input waveform (blue), but the amount of delay varies sinusoidally in time. The output signal is slightly forward-shifted in time because a negative delay is not physically possible.
Figure 4
The flanger effect applied to an input waveform. The output waveform (red) is a delayed version of the input waveform (blue), but the amount of delay varies sinusoidally in time. The output signal is slightly forward-shifted in time because a negative delay is not physically possible.

Rate (left knob) controls the period of the LFO, ranging from several seconds to tens of milliseconds. With a slow rate, the period of the effect is less noticeable, and the effect is perceived primarily as a change in timbre. As the rate decreases, the oscillation becomes noticeable, due to an effective change in the sampling rate of the input audio signal. Above 20Hz (the lower limit of human hearing), an audible frequency is produced by the LFO, which drastically changes the output audio.

Depth (right knob) controls the amplitude of the LFO. A higher depth parameter emphasizes the periodic nature of the effect and leads to a more noticeable change in sound.

Because the flanger effect is essentially a delay effect with a sinusoidally varying Delay Time parameter, the underlying code structure is similar to the delay effect. A sine table is precomputed to minimize time-consuming computations in the interrupt service routine (ISR). The Delay Time parameter is then selected based on the sine table value, which is multiplied by the Depth parameter. The Rate parameter determines how fast the program iterates through sine table entries. The output waveform is also slightly delayed in time to avoid negative values of delay.

HARDWARE DESIGN

For ease of use, we modeled our user interface on standard guitar pedal designs. The electronics are encased in a 7”×5”×3” steel box, and the user interacts with the system via a set of buttons, knobs, and LEDs. To allow for interchangeability with commercial guitar pedals, our device is equipped with an industry-standard 0.25” jack for audio input and output. Power (5V DC) is supplied to the PIC and peripheral circuitry through a barrel connector port.

To allow the user to switch between different effects, three large arcade-style buttons are mounted on the pedal box. Each button is mechanically coupled to a limit switch, which connects to a GPIO pin on the PIC32 with a pull-down resistor to the ground. When the user presses a button, it drives the GPIO pin high. Each of the three knobs used for parameter tuning turns a 1kΩ potentiometer connected to an ADC input pin on the PIC32. We utilized a low-resistance potentiometer to prevent the formation of a voltage divider with the input impedance of the ADC. An LED is situated below each of the three buttons to indicate which effect is currently active, and a green LED in the top left corner of the pedal indicates if power is being supplied to the PIC.

Signal Pathway: The input audio signal from the guitar jack is acquired through a standard 0.25” jack and passed through a biased high-pass filter (HPF) before being sampled by the PIC32 ADC. The corner frequency (~1Hz) of the HPF was chosen to remove DC bias from the guitar pickups while preserving the audible signal. After signal processing on the PIC, the digital output from a GPIO pin is converted to an analog audio signal using a 12-bit digital-to-analog converter (DAC). The DAC output is directly wired to another 0.25” jack, which can be connected to an external speaker for amplification and sound production. A high-level block diagram is given in Figure 5, and the schematics of the guitar pedal circuitry are shown in Figure 6.

Figure 5
Block diagram of the guitar pedal and signal pathway
Figure 5
Block diagram of the guitar pedal and signal pathway
Figure 6
 Schematics of the guitar pedal circuitry. The PIC32 component includes the PIC32 microcontroller (including its internal ADC), a 12-bit DAC, and a 3.3V voltage regulator.
Figure 6
Schematics of the guitar pedal circuitry. The PIC32 component includes the PIC32 microcontroller (including its internal ADC), a 12-bit DAC, and a 3.3V voltage regulator.
SOFTWARE DESIGN

Sampling and digital processing of the input audio signal are performed at 44kHz. To ensure precise timing, these computations are performed inside an ISR that is executed when a selected timer overflows. We configured this 16-bit timer, incrementing at 40MHz, to overflow every 909 clock cycles, yielding an ISR execution rate of 44kHz.

Polling of the button and potentiometer states is performed using two threads that execute every 100ms in a round-robin fashion. In the button thread, the PIC simply reads the state of each button to determine if the active effect should be changed. In this thread, a function to illuminate an LED-based on the active effect is also called. In the potentiometer thread, the ADC is used to read the value of each potentiometer, and the parameters for each effect (delay time, distortion gain, and so on) are computed based on the potentiometer states. The ADC onboard the PIC is configured to automatically scan and record channels corresponding to the three potentiometers and input audio pin. The system begins in Bypass Mode, in which the input audio signal recorded by the ADC is sent directly to the DAC without any modification, producing a clean sound. When one of the three buttons is pressed, the pedal applies the corresponding effect to the input audio. A Finite State Machine diagram illustrating the process of switching effects when a button is pressed (Figure 7).

Figure 7
 A Finite State Machine diagram illustrating the process of switching effects when a button is pressed
Figure 7
A Finite State Machine diagram illustrating the process of switching effects when a button is pressed
RESULTS

Our guitar pedal successfully implemented the three desired effects (distortion, flanger, and delay). Each of the three effects was modulated by three knobs on the device, and the ensuing changes in parameter values were clearly audible. Each effect worked as intended. Figure 8 shows the final guitar pedal in use. A video demonstration of the project is available on YouTube [1]. The code file for this article is available on Circuit Cellar’s Article Materials webpage.

An oscilloscope recording of the output response to a single input note (leftmost spike) delay effect with various settings is shown in Figure 9. A frequency spectrum of the distorted output in response to a single note being played in high-tone and low-tone parameters is shown in Figure 10.

Figure 8
The guitar pedal in use; an electric guitar (not pictured) is connected to the input 0.25" jack, and the output is fed to a guitar amp for sound production.
Figure 8
The guitar pedal in use; an electric guitar (not pictured) is connected to the input 0.25″ jack, and the output is fed to a guitar amp for sound production.
Figure 9
An oscilloscope recording of the output response to a single input note (leftmost spike) with various settings. (a) The input note is repeated once by the delay effect with high mix and low feedback parameters (right spike). (b) The amplitude of the repeated signal is much lower than in (a) due to a lower mix parameter. (c) With a high feedback parameter, the single input note is repeated with an exponentially decaying amplitude set by the feedback knob.
Figure 9
An oscilloscope recording of the output response to a single input note (leftmost spike) with various settings. (a) The input note is repeated once by the delay effect with high mix and low feedback parameters (right spike). (b) The amplitude of the repeated signal is much lower than in (a) due to a lower mix parameter. (c) With a high feedback parameter, the single input note is repeated with an exponentially decaying amplitude set by the feedback knob.
Figure 10
A frequency spectrum of the distorted output in response to a single note being played. (a) Without low-passing the output audio signal (high tone parameter). Note the significant content at high frequencies, which produce a more grainy, distorted signal. (b) A low-passed output audio signal (low tone parameter). The frequency content of the signal rapidly drops off, producing a smoother sound.
Figure 10
A frequency spectrum of the distorted output in response to a single note being played. (a) Without low-passing the output audio signal (high tone parameter). Note the significant content at high frequencies, which produce a more grainy, distorted signal. (b) A low-passed output audio signal (low tone parameter). The frequency content of the signal rapidly drops off, producing a smoother sound.
CONCLUSIONS AND FUTURE DEVELOPMENTS

To expand on our pedal, we considered adding a looper effect. This effect would allow users to record long (about 15-20 seconds) audio samples and mix them into currently played sounds. Because the memory available on the PIC (and the external RAM available in the lab) was quite limited, this would require a larger storage device such as an SD card. In the future, an improved framework could be developed for interfacing with the SD card over SPI to read and write data.

Although all the effects that were implemented are fully functional, the distortion effect volume is much louder than that of the other effects and bypass, so equalizing volume across all effects would be another avenue for improvement. Future work could also encompass chaining several of our pedals together or activating several effects at the same time. Decreasing noise in the output signal (presumably due to the rather low-quality DAC) would be another opportunity for expanded work on this project. Adding a graphical display, such as a TFT to display sound animations or provide some form of interaction could be interesting as well. 

Acknowledgments: Much of our source code handling PIC setup, peripheral initialization, protothreads, and other low-level functions are adapted from the ECE 4760 SECABB developed by Dr. Bruce Land. The PIC32 and peripheral devices were mounted on the course development board designed by Sean Carroll. Many thanks to Hunter Adams and Bruce Land for their guidance on our project and help in the lab. In addition, our project would have been much harder to use (and less aesthetically pleasing) without the assistance and components provided by Andrew Tsai for the final prototype.

REFERENCES
[1] Demo video of guitar pedal project.
https://www.youtube.com/watch?v=UL1ZJhQVSd0&list=PLDqMkB5cbBA7F_Rn8Jfj8CVBKGlAzMNA3

Code and Supporting Files

PUBLISHED IN CIRCUIT CELLAR MAGAZINE • AUGUST 2022 #385 – Get a PDF of the issue

Keep up-to-date with our FREE Weekly Newsletter!

Don't miss out on upcoming issues of Circuit Cellar.


Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine.

Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.

Sponsor this Article

Kingsley Odae (ko334@cornell.edu) grew up in Ghana, West Africa, and is currently an undergraduate senior in Electrical and Computer Engineering at Cornell University. He has a wide range of interests in embedded systems and renewable energy.

Jade Pinkenburg (jpp242@cornell.edu) is an undergraduate senior studying Electrical and Computer Engineering at Cornell University. His primary research interests lie in sensor design for biomedical systems, but he loves tinkering with microcontrollers and playing instruments in his free time.

Jake Sanders (jas2223@cornell.edu) is from New York, NY, and is an undergraduate senior studying Computer Science at Cornell, with a minor in Electrical and Computer Engineering. He is especially interested in the overlap between music and technology.

Supporting Companies

Upcoming Events


Copyright © KCK Media Corp.
All Rights Reserved

Copyright © 2024 KCK Media Corp.

Building a Tri-Effect Guitar Pedal

by Kingsley Odae, Jade Pinkenburg, and Jake Sanders time to read: 12 min