Guitarists often seek the perfect sound for their setup and are willing to introduce intentional distortion into the signal to achieve it. While this may seem counterintuitive, when done correctly, it can work wonders. But have you ever wondered what exactly happens to the signal during distortion? And can it be simulated? The answer is yes, and it can be done with some basic math and Arduino code.
The Diode Clipping Circuit
One of the simplest techniques for modifying the signal from an electric guitar is the diode clipping circuit. This circuit involves using an op-amp with antiparallel diodes either in series in the feedback loop or shunting the output to ground. The diodes clip the tops and bottoms of the sine waves, transforming them into something closer to a square wave. This square wave adds extra harmonics and depth to the sound, resulting in the desired distortion effect. It is this straightforward technique that explains the wide availability of commercially available distortion pedals.
Simulating Distortion with Algorithms
In a video, [Sebastian] explains how distortion can also be simulated using algorithms. He breaks down the math behind it, which is surprisingly easy to understand. The algorithm consists of a step function with a linear part, a quadratic section, and a hard-clipping function. Additionally, [Sebastian] derives a second, more computationally efficient algorithm from the Schockley diode equation, taking advantage of a natural exponent step function. To implement these models, [Sebastian] chose an Arduino GIGA R1 WiFi, using an ADC to convert the guitar’s analog signal to digital and dedicating a DAC to each of the two algorithms. Each distortion effect has its unique qualities, appealing to different preferences. While some may prefer the harshness of the step function, others may gravitate towards the exponential algorithm.
Image credit: Natalia Krasnova @ Shutterstock