logo elektroda
logo elektroda
X
logo elektroda
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • 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.

    tremol..wav Download (1.82 MB)

    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.

    echo.wav Download (1.85 MB)

    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.

    chorus.wav Download (2.09 MB)

    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.

    reverb.wav Download (3.05 MB)

    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.

    overdri...wav Download (2.2 MB)

    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.

    cab si..wav Download (2.28 MB)

    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.

    Cool? Ranking DIY
    About Author
    Kwarcu
    Level 13  
    Offline 
    Kwarcu wrote 78 posts with rating 65, helped 5 times. Live in city Kraków. Been with us since 2007 year.
  • ADVERTISEMENT
  • #2 20859473
    gulson
    System Administrator
    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 they will probably add artificial intelligence support.
    Contact me with a parcel locker and I will send you a small gift ;)
    I would also like to translate the presentation and post it worldwide: elektroda.com
  • #3 20859489
    Kwarcu
    Level 13  
    gulson wrote:
    Soon they will probably add artificial intelligence support.

    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.
  • #4 20859903
    austin007
    Level 17  
    Nice project and definitely a lot of work. Would it work on weaker platforms like STM32F7F4 or does it have to be on STM32F7F7?
  • ADVERTISEMENT
  • #5 20859962
    Kwarcu
    Level 13  
    austin007 wrote:
    Nice project and definitely a lot of work. Would it work on weaker platforms like STM32F7F4 or does it have to be on STM32F7F7?

    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 algorithm, because for me simple effects (tremolo, chorus, echo) take about 3 - 10% of the CPU time, and reverb and cab sim take about 25%. Cortex-M4 will be slower than M7 because it does not have, for example, branch prediction and I-Cache and D-Cache caches.
  • #6 20860036
    katakrowa
    Level 23  
    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 returning because the satisfaction must be considerable.

    1. From the code I see that you have WM8994 as a DAC or do you use the 12-bit built-in uC as an ADC?

    2. Have you considered building it on a slightly faster uC instead of 216MHz, e.g. 550MHz or 480MHz? Maybe instead of 6ms latency you would have 3ms. and this game is worth the candle because such 3ms while playing are almost negligible. What stood in the way of using a stronger system?

    3. Out of pure curiosity, I will ask about how to store graphics files (https://github.com/kwarc93/audio-multieffect/blob/master/app/view/lcd_view/images/ui_img_btn_1_inact_png.c)
    Can`t this be communicated in a less "butchery" way when programming the system? Does this FreeRTOS not provide any facilities for "human" people?

    4. Have you struggled for a long time with configuring your CMSIS DSP libraries? I once tried to tame them on STM32F446 on Nucleo, but I failed. Ultimately, I built the system on ADAU1701 - but the bad taste of failure and the lack of full freedom in signal processing remained :-)
  • ADVERTISEMENT
  • #7 20860088
    Kwarcu
    Level 13  
    @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 at hand and I know STM32 well. At the beginning, I didn`t know what and how many effects this CD would have. The latency can be reduced twice (by reducing the audio buffers), but then the CPU consumption will increase and the max. number of effects in the chain, GUI will be more frame-rate, etc. For me the current latency is acceptable.
    3. This method of storing an image is, of course, one of the possible options. You can upload JPEG to a microSD card. You can upload FLASH to an external chip (probably more troublesome). What I`m getting at is that this was the default way to store images in the LVGL graphics library. I will add that I designed the screens in a PC creator dedicated to this library (Squareline Studio), which generates code for the screen.
    4. I didn`t have to fight with CMSIS DSP. I only linked the library (I use it compiled as a *.a file) and defined the necessary macros (ARM_MATH_CM7 type).
  • #8 20860097
    katakrowa
    Level 23  
    Kwarcu wrote:
    1. Yes, the ADC/DAC is WM8994, the jack sockets on the board are connected to it.


    I`m blind... it actually has both ADC and DAC.

    Kwarcu wrote:
    4. I didn`t have to fight with CMSIS DSP. I only linked the library (I use it compiled as a *.a file) and defined the necessary macros (ARM_MATH_CM7 type).


    Sounds easy :-) I will have to approach this topic again.

    Thanks for the answers.
  • #9 20860512
    viayner
    Level 43  
    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 microcontrollers should be able to handle them.
    Regards
  • #10 20860652
    katakrowa
    Level 23  
    viayner wrote:
    I used to play around with dsPIC and delay effects


    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.
  • #11 20861492
    pierkwadrat
    Level 14  
    If there were also phase and flanger effects, it would be a dream set :)
  • ADVERTISEMENT
  • #12 20861541
    Kwarcu
    Level 13  
    pierkwadrat wrote:
    If there were also phase and flanger effects, it would be a dream set

    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 on the board).
    Anyway, the code is open source - you can try writing a phaser yourself :)
  • #13 20861681
    pierkwadrat
    Level 14  
    Unfortunately, I can`t :(
  • #14 20861994
    viayner
    Level 43  
    Hello,
    katakrowa wrote:
    ...Delay, echo and reverbs, however, require a lot of RAM (a lot for microcontrollers). To make a one second mono delay, a minimum of 88 KiB is needed.

    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 resolution, e.g. 12 bits, and this is enough, even an experienced ear cannot detect it, the same applies to the sampling frequency.
    - it all results from the fact that the modified signal is a small part of the main signal.
    - in typical delays/reverbs you don`t need as much as 1 second of delay, so the amount of memory needed quickly decreases.
    Regards
    PS, phaser support requires FFT and frequency analysis.
    With a vocoder it will be much more difficult, you have to divide the signal into several bands with a filter, change the envelope of each band and mix it.
  • #15 20862199
    Kwarcu
    Level 13  
    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 (as well as an image frame for the LCD). This board is a nice little piece of hardware for a non-Linux embedded device and that`s why I didn`t have to make any compromises. At the beginning, I had the audio set to 16 bit, but if the equipment provides full 24 bits, why not use it (of course, you can`t hear it by ear and the 24 bits are lost in the noise anyway and we effectively have 20 bits).

    viayner wrote:
    PS, phaser support requires FFT and frequency analysis.
    With a vocoder it will be much more difficult, you have to divide the signal into several bands with a filter, change the envelope of each band and mix it.


    From what I remember from the books, phasers can be made using allpass filters, but with a vocoder it will be difficult without FFT. I`m not worried about the lack of computing power because currently the guitar speaker simulation uses fast convolution, where first one FFT is made, then the multiplication of the complex spectra of the signal and the impulse and finally the reverse FFT. This effect takes approximately 25% of the CPU.
  • #16 20864815
    yogi009
    Level 43  
    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?
  • #17 20865148
    Kwarcu
    Level 13  
    yogi009 wrote:
    I`m wondering about the quality level, is this an acceptable signal on a big stage?

    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 have to spend some time tuning the algorithms (and this is often a process of trial and error). It`s enough for home gaming - it`s fun :D

Topic summary

The discussion revolves around the development of a digital multi-effect device for electric guitars using the STM32F746G-DISCO development board. The project focuses on software implementation of effects such as overdrive, cabinet simulation, and reverb. Participants share insights on the feasibility of running the software on different microcontroller platforms, emphasizing the importance of hardware support for floating-point operations and sufficient clock speed. The conversation also touches on the use of the WM8994 DAC/ADC, latency considerations, and memory requirements for effects like delay and reverb. Suggestions for additional effects, such as phaser and vocoder, are made, along with optimization tips for memory usage and signal processing. Overall, the project is seen as a promising prototype, though not yet stage-ready.
Summary generated by the language model.
ADVERTISEMENT