Close

Initial software design thoughts

A project log for hgSynth

ESP32 based monosynth embedded in bass guitar

igor-brkicIgor Brkic 05/02/2018 at 20:490 Comments

ESP32 development is done using ESP-IDF (Espressif IoT Development Framework) which is official framework. But nice people also created Arduino framework for it which makes this really easy for anyone familiar with Arduino.

The standard Arduino IDE is nice and cute for small projects but the editor is really the weak spot for anything more complex so I decided to go with something else. PlatformIO is really nice tool which handles environment, compiling and uploading and it can be integrated with either Atom or VSCode as an editor. I chose to go with VSCode (the first MS product I've used in years :)) and it was a good decision.

After we've decided on dev env, let's start with code (or at least with code plans).

Components

So, from the DSP side we have pitch detection, oscillators, envelope generator and filter. Other than that, there needs to be a way to store and recall presets, there is user interface, ...

ESP32 runs FreeRTOS in the back and, even when Arduino framework is used, it's easy to create FreeRTOS tasks, use synchronization primitives, events and other goodies.

DSP

I have some previous DSP experience so this part was familiar. However, writing optimized DSP code is really hard. Luckily for me, ESP32 with its two cores and floating point support is here to help (yay, probably no need for fixed point arithmetic!). Other great thing is http://musicdsp.org/archive.php code archive - a great resource of great DSP code.

For pitch detection I decided to go with new method developed by Joel de Guzman from Cycfi Research. It is, so called, bitstream auto correlation which should be really computationally quite easy but promises exceptional results. I hope that will be the case.

For oscillators I was thinking about going with simple wavetable (actually, lookup table) design. But, since things can't really be simple, this complicates when we want nice sounding (i.e. alias free) sounds across the whole frequency range. So, ether approach with multiple wavetables is required or some band limited synthesis technique. For this I'll go with simple naive approach just to get something and later add the more advanced stuff.

I found nice series of articles on envelope generators (and a nice code) on EarLevel Engineering site: http://www.earlevel.com/main/2013/06/01/envelope-generators/. This will be more than enough for this part.

For filter I decided to start with Paul Kellet's simple design: http://musicdsp.org/showone.php?id=29 and later add better/more complex filter if needed.

GUI

First idea was to use BLE for user interface. This has a downside of requiring an app on a device so I decided that WiFi is much better choice (besides the power consumption). GUI will be a simple web app which uses websocket to communicate with backend.

Discussions