logo elektroda
logo elektroda
X
logo elektroda

Digital guitar multi-effect

Kwarcu  Cool? (+26)
STM32F746G-DISCO development board with a display showing the text GMFX and visible audio and network cables.

Hi

I`ve wanted to make my own digital multi-effect for electric guitar for a long time. I couldn`t get around to it for a long time due to various things, but it`s finally here. My project only concerns software for the ready-made STM32F746G-DISCO development board. It is a concept/prototype of a device rather than a ready-made device that can be taken on stage and played.

What is this?

For those who don`t know, a guitar effect is a device (or software) used to modify a guitar`s signal to obtain a characteristic sound. Such effects may be based solely on analog electronics, but they can also be achieved using digital signal processing, either on a microcontroller or in computer software.

How it`s working?

Below is a short video briefly showing how the device works. I add three effects there: overdrive, cab sim and reverb and then I play a short melody. An electric guitar is plugged directly into the multi-effects input and its output is connected to a regular portable speaker. Later, separate audio samples for each effect will appear in the description.





Equipment

I had no plans to build a dedicated hardware platform for this purpose, because I already had a development board with everything necessary, and I was more interested in signal processing algorithms. Therefore, as I mentioned earlier, the project works on the STM32F746G-DISCO board. From the user`s point of view, the audio line input and output as well as the graphic touch display are important here.

Software

It will be difficult for me (and I don`t want) to describe the code in detail here, so I will summarize it to the most important things. The project is written in C++17. The application code is separated from the hardware and RTOS using abstraction layers. We`ll see if I did it right when I need to move the code to something else ;) . In addition, the application is written in the MVC (Model-View-Controller) pattern to achieve separation between the main modules. Model includes an effects processor with algorithms, view contains everything related to the display and interaction with the user a controller is the intermediary between the two. Thanks to this, you can easily add another module, for example view where interaction with the user and device control will take place via e.g. a terminal. The mentioned modules communicate using events (event-driven), the mechanism of which is based on RTOS queues.

The source code is on mine github , a project created in Eclipse.

Effects

Currently, six popular guitar effects work: tremolo, echo/delay, chorus, reverb, overdrive and cab sim (speaker cabinet simulator). Effects can be added to the processing "chain" in any order from the menu. Audio signal processing is double-buffered and takes place in blocks, where the size of one block is 128 samples. The block size translates directly into the delay between input and output, which is approximately 6ms. Digital audio parameters are 24bit/48kHz.

In the following description of the effects, in a "pathological" way, I will summarize the basics of their operation (and for details, please refer to the literature provided at the end). The included audio samples contain a pure guitar signal at the beginning, and only in the second half the effect is active.

Tremolo

This is probably the simplest effect, which involves modulating the amplitude of the guitar signal using a low-frequency oscillator.



Sound modification controls:
- rate: oscillator frequency, range 1 - 20Hz
- depth: modulation intensity, range 0 – 0.5
- mode: modulation shape, sine/square

Echo

The main element of this effect is the delay line. As the name suggests, it is used to delay the input signal by a given amount of time, which can be adjusted. To obtain the effect of many repetitions (echo), the signal from its output is fed to the input, previously multiplied by a factor less than 1 so that the repetitions fade out. In addition to multiplication, a low-pass filter can be used here to suppress high repetition rates and obtain an effect similar to analog echo effects based on magnetic tape.



Sound modification controls:
- blur: blur repetitions (low-pass filter), range 2 – 8kHz
- time: delay time, range 0.05 – 1s
- feedback: repetition fading, range 0 – 1
- mode: selection of echo/delay mode

Chorus

It`s just a choir. The main mechanism of this effect is doubling the original sound source, then slightly shifting it in time (and possibly modulating this time) and finally summing it with the original. A delay line is also used here, but its delay time is modulated with a low-frequency oscillator.



Sound modification controls:
- depth: modulation intensity, range 0 – 1
- rate: modulation frequency, range 0.05 – 4Hz
- mix: mix of the original with the effect, range 0 – 1
- mode: selection of the effect type

Reverb

This is an effect that simulates the reverberation in a room, hall, etc. The task of the algorithm is to create a fairly large number of "reflections" of the original signal, circulate them, possibly modulate them, sustain them and then dampen them. A good-sounding reverb algorithm is difficult to develop and is usually computationally demanding due to its complexity. Here I used a certain well-known topology by J. Dattorro from the 1990s, simulating an analog plate reverb.



Sound modification controls:
- bandwidth: low-pass filter on the input, range 0 – 24kHz
- decay: reverb length, range 0 – 0.999
- damping: reflection suppression (DP filter), range 0 – 24kHz
- mode: effect mode without/with modulation

Overdrive

One of the most popular effects in rock and metal music. The main task of the algorithm is to change the shape of the signal in such a way as to "cut" or "flatten" the signal when it exceeds a certain value. In analog effects this is achieved, for example, by using diodes connected in anti-parallel (symmetrical clipping). In digital, however, a non-linear function is usually used, e.g.: y = tanh(kx)/tanh(k) where the argument x is the input signal and y is the output. Using such procedures introduces a number of harmonics into the signal, so it is necessary to remember to reduce the phenomenon of aliasing. Overdrive algorithms use oversampling and decimation for this purpose.



Sound modification controls:
- gain: signal gain, range 1 – 200
- tone: tone change (bass/treble), range 0 – 1
- mix: mix of the original with the effect, range 0 – 1
- mode: selection of soft/hard clipping type

Cab sim

This is a simulation of the sound of a guitar cabinet. It is usually "applied" directly after the overdrive, so that we do not hear the terrible clamor of the distorted signal in the headphones. ;) . It is actually a graphic equalizer without the possibility of adjustment. The algorithm involves convolving the impulse response of a given column with the audio signal. Such a convolution for long impulse responses is computationally expensive, therefore the so-called "fast" convolution using FFT.



Sound modification controls:
- list with impulses of guitar columns

What can be added/improved

I have a list of a few things I plan to add in the future:
1) guitar tuner
2) saving/reading effect settings (presets).
3) designing unique effect panels (currently each panel looks almost the same)
4) Vocoder effect
5) footswitch support for changing effects

What are your suggestions?

Photos

Below are a few photos of the screen (sorry for their quality, but it`s hard for me to take a good photo of this LCD screen :/)

STM32F746G-DISCO touchscreen displaying Chorus effect settings
Guitar multi-effect screen with chorus effect setting.
Touch screen showing a list of guitar effects: Tremolo, Chorus, Reverb with editing options.
Touchscreen displaying audio volume settings and 6% CPU load.

Sources

I found most of the theories about audio effects in the following sources:

1) Udo Zölzer, DAFX: Digital Audio Effects ,Second Edition
2) Will C. Pirkle, Designing Audio Effect Plugins in C++ ,Second Edition
3) J. Dattorro, Effect Design, Parts 1 – 3

and beyond that, all corners of the Internet.

If I forgot to write about something important - ask in the comments.

About Author
Kwarcu
Kwarcu wrote 78 posts with rating 65 , helped 5 times. Live in city Kraków. Been with us since 2007 year.

Comments

gulson 13 Dec 2023 13:27

Thanks for the presentations! Only modernity has crept in. Recently, my friends` kids had an electric guitar connected to a tablet and headphones, they were strumming it and the effect was amazing. Soon... [Read more]

Kwarcu 13 Dec 2023 13:36

Such things are already happening. A recently created project called "Neural Amp Modeler" (as a DAW plug-in) uses machine learning to model the sounds of amplifiers. Apparently it sounds really good. [Read more]

austin007 13 Dec 2023 18:19

Nice project and definitely a lot of work. Would it work on weaker platforms like STM32F7F4 or does it have to be on STM32F7F7? [Read more]

Kwarcu 13 Dec 2023 18:48

Single effects can be easily achieved on Cortex M4 with FPU. It is important that it has hardware support for float numbers and some decent clock speed, above 100MHz. However, a lot depends on the effect... [Read more]

katakrowa 13 Dec 2023 19:26

Great stuff and congratulations on your determination. A nice piece of programming work. However, I have a few questions because I got stuck in a very similar topic... and as you can see, it is worth... [Read more]

Kwarcu 13 Dec 2023 20:10

@katakrowa Thanks for showing interest ;) As for the questions: 1. Yes, the ADC/DAC is WM8994, the jack sockets on the board are connected to it. 2. I did it on this platform because I simply had it... [Read more]

katakrowa 13 Dec 2023 20:14

I`m blind... it actually has both ADC and DAC. Sounds easy :-) I will have to approach this topic again. Thanks for the answers. [Read more]

viayner 14 Dec 2023 06:53

Hello, bravo for the idea and execution, I used to play around with dsPIC, delay effects, thermolo modulations, simple filters and overdrive can be calculated quite easily and without FFT, even simpler... [Read more]

katakrowa 14 Dec 2023 09:43

Delay, echo and reverbs, however, require a lot of RAM (a lot for microcontrollers). To make a one-second mono delay, a minimum of 88KiB is needed. [Read more]

pierkwadrat 14 Dec 2023 19:44

If there were also phase and flanger effects, it would be a dream set :) [Read more]

Kwarcu 14 Dec 2023 20:10

Nothing stands in the way, but I`m more interested in the vocoder effect, e.g. the one in the video: The microphone signal can be fed to the second channel of the line input (or use MEMS microphones... [Read more]

pierkwadrat 14 Dec 2023 21:30

Unfortunately, I can`t :( [Read more]

viayner 15 Dec 2023 07:02

Hello, It`s actually not that bad: - the effects of mixing the original signal with the modified one can be achieved more easily and many serious companies do it. - the signal is sampled with a lower... [Read more]

Kwarcu 15 Dec 2023 11:49

Interesting optimization tips ;) When it comes to RAM, I had no worries about running out of it because there is an external 8MB SDRAM chip on the board in which I keep large buffers for delay lines... [Read more]

yogi009 17 Dec 2023 00:02

More and more from Lem`s novels in these electrode projects :-) Big applause for this presentation. I`m wondering about the quality level, is this an acceptable signal on a big stage? [Read more]

Kwarcu 17 Dec 2023 11:35

I think it`s not at that level yet. I have just entered the field of DSP in audio and my effects are rather basic topologies described in the literature. To achieve a really interesting sound, you would... [Read more]

%}