Back to Home

Guitar effects: algorithms, first hardware implementation experience

dsp · freedsp · diy · guitar · bguire · navy

Guitar effects: algorithms, first hardware implementation experience

The electric guitar has long become an integral attribute of almost every musical group. At the same time, the market for devices whose main function is the processing of guitar sound has also been actively developed. As you might have guessed, the article will focus on guitar effects.

The article contains a description of some guitar effects, as well as a summary of the bitter experience we received while developing the guitar processor . By the way, we developed the guitar processor as a course project at the university.

What are guitar effects? What are they needed for? Let the following video answer for us:



Sound effects


The following is a classification of effects depending on the features of their implementation:

1) Filters - low-pass filter, high-pass filter, band-pass filter, equalizer
2) Parametric filters - wah-wah (wah), phaser
3) Effects over the delay line - vibrato, flanger, chorus, echo
4) Modulators - tremolo, vibrato
5) Non-linear effects - overdrive, distortion, fuzz
6) Spatial effects - reverb

Filters


Filters, by definition, remove part of the spectrum above or below the cutoff frequency. For many situations, this is too rude an intervention.
Equalizer, on the other hand, enhances or attenuates certain frequency bands without changing the remainder of the spectrum. Equalizers are built on a series of shelving and peak filters.

List of commonly used filters
Lowpass filter


Highpass filter


Bandpass filter


Bandreject filter


Shelving filter


Peak filter



Parametric Filters


Some effects can be implemented by changing the parameters of simple filters over time.

The Wah-wah effect is a narrow bandpass filter in which the center (resonant) frequency moves with time. The filtered sound is mixed with the original. Demo .


Effects over the Delay Line


All effects of this class are united by one principle of work. The input signal is stored in a section of memory, which is here called the delay line (delay line). The output is the sum of the input sample and the sample from somewhere in the delay line. The number and locations of samples from the delay line determine the unique sound of the effect.

Effects that do not store the result of their work in the delay line (that is, it contains only a clean input signal) are described by filters with a finite impulse response. Effects that change the delay line are described by filters with an infinite impulse response.

Flanger effect- sampling from the delay line occurs in the region from 0 to 15 ms, and the exact location is determined by the low-frequency (about 1 Hz) sinusoidal law. Using low-frequency sinusoids is a popular technique for creating effects and has its own name - Low Frequency Oscillator or simply LFO. Demo .

The “Echo" effect - one or several samples at the same distance, more than 50 ms. The one-sample option actually doubles the number of notes played. With the help of several samples, you can simulate a game in a spacious room. The Reverb effect also achieves a similar goal. Demo .

Chorus effect- imitation of playing several instruments. Several samples (by the number of instruments) at a random distance of 10-25 ms. Demo .

Modulation


Modulation is a process in which the parameters of a sinusoidal signal (amplitude, frequency and phase) are changed based on the audio signal.
Amplitude modulation is defined as y (n) = (1 + a LFO (n)) x (n) , where a is the modulation depth, a number from 0 to 1.

The Tremolo effect is the amplitude modulation of sound from LFO to 20 Hz. Demo .

Nonlinear effects


The essence of nonlinear effects is to introduce new harmonics into the sound. Nonlinear sound processing allows, for example, to weaken loud sections so that subsequent equipment does not introduce unwanted distortions (or so as not to wake neighbors when watching a movie); amplify quiet areas, making the sound more saturated.

However, such filters are outside the scope of the article, so in this section we will focus on a line of three similar, very guitar, very effective effects - overdrive, distortion, fuzz. In fact, this is one effect with different strengths and different goals.

Overdrive You could hear at the beginning of the article. As his older brother sounds, the king of metal is distortion, you can find out under the spoiler.

Distortion example


The realization of this effect is simple, and at the same time full of tricks, which makes creating good distortion a kind of art. The effect is based on a simple idea - sounds of too high amplitude should be cut off. At first it was an undesirable effect of electronic components entering non-linear operating modes, but over time, musicians began to use this to their advantage.

Hardware implementation: theory


In general, the architecture of a guitar processor can be represented as follows: A



guitar processor is a digital device. This means that the incoming analog signal (sound) must be converted to a digital signal. This is done by a special ADC chip . After processing, it is necessary to return the signal to its analog form. This is done by the DAC. DAC and ADC can be performed in the same chip - in this case, it is called Codec. Obviously, the same requirements are applied to all three microcircuits:

  • Sampling frequency : 44.1 kHz or 48 kHz. This follows from Kotelnikov’s theorem and the fact that when working with sound we are interested in frequencies from 20 Hz to 20 kHz. There are codecs for working with sound and sampling rates of 96 kHz and 192 kHz. They can also be used, but they create an increased computational load on the DSP, which is undesirable if the developer wants to get by with budget components. A lower sampling rate will cut out the harmonics felt by the person from the signal, distorting the signal.
  • Bit : 24 bits. Such, according to observations, is the standard for audio codecs. Too low a bit rate cuts out useful information. Too high a bit is useless if it is not a precision or low noise device. Otherwise, only the noise will fall into the lower bits of the digital signal.


A guitar processor is a real-time device. The musician should not feel the delay between hitting the strings and the sound from the speakers. In a first approximation, this also means that the effect superposition unit must receive a 24-bit sample from the ADC, process it, and transfer the result to the DAC before a new sample appears on the ADC. Let us now try to generalize the requirements for such a - so far deliberately abstract - handler.
  • Simple calculations show that at a sampling frequency of 48 kHz, the processor has 21 microseconds per sample.
  • If the codec is not built into the processor, then you will have to connect to the codec using one of the generally accepted protocols. Most often these are SPI or I2C protocols. The SPI and I2C buses are serial, bit by bit per clock. This means that the frequency of the input-output should be at least 24 times higher than the sampling frequency of the ADC. For 48 kHz, this is at least 1,152 MHz.



Typical SPI connection

Practice shows that microcontrollers cannot handle real-time audio processing. Here specialized processors called DSP (digital signal processor) come to the rescue. As with codecs, there are general-purpose DSPs and specialized DSPs.

General purpose DSP:
  • Easy to program. Most likely, there is a C compiler for such a DSP.
  • Computing power from modest to “on the brink of the possible” + a large number of interfaces. For example, the top DSP from Texas Instruments contains 12 cores (8 DSP cores and 4 ARM architecture cores). Budget DSPs usually do not contain ARM cores.
  • Powerful DSPs place high demands on the surrounding circuitry and cannot be used on the knee.


Sound DSPs:
  • Provide a guaranteed number of sample instructions. Typically, the user is given from 256 to 6,000 instructions. This simple warranty meets the two processor requirements described above.
  • Low cost - up to $ 30.
  • Easy installation on board.
  • Not programming, but some kind of circus. DSPs are built on architectures other than x86 and ARM - often this is VLIW. The sound DSP architecture may be so different that writing a C compiler loses all meaning. Therefore, the use of assembler or graphical programming languages ​​is often used here.
  • Most likely there is no interface for external RAM.



Typical DSP firmware for the ADAU family.

Hardware Implementation: Practice


We now turn to the diagram of a specific implementation of the guitar processor:



The project consists of three main blocks - FreeDSP, Arduino, LCD. An important point to make immediately here is that the FreeDSP project can hardly be called a good choice for creating a guitar processor. Why so - below, but in general, any inexperienced in electronics developer is recommended to replace FreeDSP with another evaluation board with a specialized DSP.

The key advantage of the project is its simplicity; the developer does not require the ability to breed boards. At the electronics level, basic knowledge and some common sense are required. Also, the developer is spared from working with ADC / DAC - both are built into ADAU1701.

Here we will not dwell on the Arduino and the display. What I would like to note - Arduino Due is preferable here to other options due to the fact that the level of the logical unit here is 3.3 V, and not 5 V. This is important because many modern DSPs do not withstand five volts. You can use any LCD, but a model with the SSD1305 driver is recommended - firstly, excellent OLED displays are produced with such a driver, and secondly, the corresponding high-level library is available for Arduino .

Freesp


image
FreeDSP is a low-cost, real-time digital signal processing solution for researchers and the DIY community. The board is based on the ADAU1701 . ADAU1701 programming is done in the SigmaStudio IDE. More information about the project can be found at www.freedsp.cc .

The creators of the project offer for a modest amount to purchase from them all the components for assembly. However, we decided to do everything on our own. Fortunately, the project website contains all the necessary schemes, as well as lists of components.

The following is a list of pitfalls when working with FreeDSP:
  1. Firmware for ADAU1701 is stored in the EEPROM 24LC256 chip. To write data to this chip, you can use Arduino Nano (a slot is provided for it in the project) or record it yourself. For independent firmware, the PICKit v2 programmer or its clone is suitable. When using PICKit: SigmaStudio compiles the project into a file with the extension .hex. This is not true . This is not an Intel Hex file, it is a text file listing comma-separated hexadecimal numbers. A special utility is used to convert Sigma Hex to Intel Hex .
  2. The ADAU1701 has very low I / O capabilities. Together with an unusual graphical programming language, this causes a lot of headache when trying to create a guitar processor with truly customizable effects.
  3. The ADAU1701 has very little internal memory — only 21 milliseconds. Nothing but the Chorus effect with such a delay line can be done. ADAU1701 is designed to work with a signal in the frequency range (filters and the like). You can get around this drawback by replacing ADAU1701 with ADAU1452 (the older chip in the line has a delay line of 800 milliseconds, which is a lot). The board must undergo major changes.


Hardware implementation: error handling


The following diagram summarizes our humble experience and is offered as a starting point for novice workers with real-time sound.



Here's how to avoid problems with short delay lines and IO. We propose replacing ADAU1701 with something from the ADAU14xx family, since these chips have enough internal memory (up to 800 ms). Since it turned out that in one ADAU all the options and settings of the guitar processor cannot be accommodated, there are several of them. When setting up the effects, the microcontroller takes out the firmware with different effects from the NVRAM and writes them to the EEPROM chips, after which it restarts the ADAU.

Of the expected advantages of such a scheme, I want to note the high customizability of the processor. Of the shortcomings, there is no way to get ready-made boards here and you will have to spend considerable time on development.

Conclusion


In the end, we still managed to make a modest guitar processor, but the final version was fundamentally different from the originally planned one and deserves a separate article. Part of the processor features shown in the video:



Photos of the development process
freedsp development

freedsp development

freedsp development

image


We hope that this article will help people who begin to develop their own guitar effects to avoid the rake that we stepped on.

Read Next