📜 ⬆️ ⬇️

Guitar effects: algorithms, first experience in hardware implementation

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

In the article there is a description of some guitar effects, as well as a compilation of the bitter experience we obtained in 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


Below is a classification of effects, depending on the characteristics of their implementation:

1) Filters - low pass filter, high pass filter, bandpass filter, equalizer
2) Parametric filters - wah-wah (frog), phaser
3) Effects over the delay line - vibrato, flanger, chorus, echo
4) Modulators - tremolo, vibrato
5) Nonlinear 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 gross an intervention.
The equalizer, on the other hand, amplifies or weakens certain frequency bands without changing the rest of the spectrum. Equalizers are based on a series of shelving and peak filters.

List of frequently used filters
Lowpass filter


Highpass filter


Bandpass filter


Bandreject filter


Shelving filter


Peak filter



Parametric filters


Some effects can be realized 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 operation. The input signal is stored in the section of memory, which is here called the delay line. The output is the sum of the input sample and the sample from somewhere in the delay line. The number and location of samples from the delay line determine the unique sound of the effect.

Effects that do not save the result of their work to 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 infinite impulse response.

The “Flanger” effect is a selection from the delay line in the region from 0 to 15 ms, and the exact location is determined by the low-frequency (about 1 Hz) sinusoidal law. The use of low frequency sine waves is a popular technique for creating effects and has its own name - Low Frequency Oscillator or simply LFO. Demo .

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

The “Chorus” effect is an imitation of playing multiple tools. Several samples (by the number of instruments) at a random distance of 10-25 ms. Demo .

Modulation


Modulation is the process by which the parameters of a sinusoidal signal (amplitude, frequency, and phase) change 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 amplitude modulated sound with an LFO up to 20 Hz. Demo .

Nonlinear effects


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

However, such filters are not included in 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 strength and different goals.

Overdrive You could hear at the beginning of the article. How his older brother sounds, the king of metal - distortion, can be found under the spoiler.

Distortion example


The implementation of this effect is simple, and at the same time full of tricks, which makes the creation of a 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 from the output of electronic components in non-linear modes of operation, but over time, the musicians began to take advantage of this.

Hardware implementation: theory


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



The 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 an analog form. DAC does this. DAC and ADC can be executed in one chip - in this case it is called a Codec. Obviously, the same requirements are imposed on all three microcircuits:



A guitar processor is a real-time device. A musician should not feel the delay between striking the strings and the sound from the speakers. In the first approximation, this also means that the overlay block 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 an - for the time being purposely abstract - handler.



Typical SPI connection

As practice shows, microcontrollers with sound processing in real time can not cope. Here come to the aid specialized processors called DSP (digital signal processor). As in the case of codecs, there are general purpose DSPs and specialized DSPs.

General Purpose DSP:


Sound DSPs:



Typical DSP firmware of the ADAU family.

Hardware implementation: practice


Let us now turn to the scheme of a specific implementation of the guitar processor:



The project consists of three main blocks - FreeDSP, Arduino, LCD. Here it is worth making an important note right away - the FreeDSP project can hardly be called a good choice for creating a guitar processor. Why this is so below, but in general any developer who is inexperienced in electronics is recommended to replace FreeDSP with another evaluation board with specialized DSPs.

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

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

FreeDSP


image
FreeDSP is a low-cost, real-time digital signal processing solution designed for researchers and the DIY community. The fee is based on ADAU1701 . The programming of the ADAU1701 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. The benefit of the project site contains all the necessary schemes, as well as lists of components.

Below 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 the Arduino Nano (for it there is a slot in the project) or write it yourself. For self-firmware fit programmer PICKit v2 or its clone. When using PICKit: SigmaStudio compiles the project to a file with the .hex extension. This is not true . This is not a file in Intel Hex format, it is a text file with a 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. Coupled with an unusual graphical programming language, it gives a lot of headaches when trying to create a guitar processor with truly custom effects.
  3. The ADAU1701 has very little internal memory — only 21 milliseconds. Nothing but the Chorus effect with such a delay line is possible. ADAU1701 is designed to work with a signal in the frequency range (filters and the like). You can bypass 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 fee should undergo major changes.


Hardware implementation: work on bugs


The following diagram is a summary of our modest experience and is proposed as a starting point for novice workers with real-time sound.



Here is how to avoid problems with short delay lines and IO. We suggest 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 do not fit, there are several of them. When setting up the effects, the microcontroller gets the firmware with different effects from NVRAM and writes them into the EEPROM chips, and then restarts the ADAU.

From the expected advantages of such a scheme, I would like to note the high configurability of the processor. Among the shortcomings - ready-made boards are not enough 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 one originally planned 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 with this article we will help people who are starting to develop their own guitar effects, to avoid those rakes that we stepped on.

Source: https://habr.com/ru/post/369391/


All Articles