Developing on STM32

Posted on May 8, 2020

Over the past months I’ve been investigating moving away from Teensy to another microcontroller  ecosystem. I love Teensy, and I wouldn’t have made the majority of my projects without it, I’ve learnt so much from it, and I still think it has the best libraries of any of the alternatives. It’s always the first thing I recommend to get people started on doing digital audio electronics and I’m sure I’ll use it again in the future. But, it has a few, in my opinion, major downsides, once you get a bit more advanced.

Development Environment – Teensy uses the Arduino IDE, which is fine for writing small programs to flash leds, read sensors etc, but is a little basic for larger scale projects.

Debugging – This is the big one for me, Teensy doesn’t provide a method for debugging (other than using Serial Monitor). I’ve spent literally hours trying to debug audio glitches that would have been relatively straightforward to find if I could just set a breakpoint and step-through. I have seen people exposing the JTAG pins on the Teensy and using these, but I wanted something supported by the vendor.

Manufacture – If you want to do a manufacturing run of your project with Teensy you have 2 options. Either mount the Teensy itself on the board, which can become quite expensive if you’re doing more than a couple, or buy the bootloaders directly from PJRC and use the specific microcontroller to match the Teensy. I wanted to be able to make small runs of my boards (still less than 10), without the expense of buying many Teensy’s, and choose a chip specific to the needs of each project.



After chatting with Alex Evans, (mmalex on Twitter), who had already started working with the STM32 range of microcontrollers, I decided to check them out. They have a huge range of chips, ranging from arduino level all the way up to Teensy 4 capabilities. The Eclipse based IDE supports debugging, and they are fairly easy to include in your schematic (requiring a bunch of power-filtering caps but not much else.)

STM make their own range of dev boards, similar to Arduino and Teensy, called Nucleo. There are lots of them, and it takes a while to filter through the STM range and find the chip and associated Nucleo you are looking for. They’re very reasonably priced (I suspect they are sold as a loss-leader) and are the best way to get started. They have a fairly large form-factor, so it’s unlikely you’d want to include them directly in your project, like you would a Teensy. But they are perfect for experimenting with the hardware before you start on your own PCB.

I strongly recommend checking out mmalex’s youtube channel, where he has live streamed a series of videos explaining how to get into STM32 eurorack module design. They are super informative and well worth watching. Also this series by DigiKey on getting started with STM32 is essential viewing if you are interested in developing with them.


First experiences with the IDE weren’t great, unfortunately  it’s plagued with a number of small bugs and glitches. It really didn’t like me working in C++ and kept defaulting my project to C, which I then had to unpick in the project settings each time. Actually that bug has been fixed, and it does seem to be slowly improving, although each new update seems to introduce some fun new issues. It works ok-ish though, it’s free to use, and I can FINALLY debug!

The work-flow involves using the IDE to visually configure your chip, you can set which peripherals you want to use, and which pins to connect them to. This will then generate (lots) of code, which basically sets the correct registers to initialise the peripherals and provides you functions to use them. They use something they call HAL (Hardware Abstraction Layer), so that the functions look the same regardless of what underlying chip you are using. Beware though, I’ve heard that different chips seem to have their own foibles in terms of setup, and some of the code requires manual tweaking. I’m using an F446, and so far, the generated code seems to be fine.

Once this code is generated, you can start adding your own code. Any code added in the auto-generated files needs to exist between specific comment lines that the generator marks out for you. My first project was a PCB which connected the STM32F446 to a WM8731 audio codec, was powered by eurorack +12/-12V, and broke out many of the STM32 pins onto header. The intention is that this board will be coupled with another (module specific) board, which will add interface components (pots, jacks etc) and route them to the breakout pins. You can see the code here which initialises the STM32 and configures the WM8731 via I2C.

The SMT32 board with solder paste applied and components placed ready for the reflow oven.


I’ve just sent out some gerbers (PCB files) for manufacture, I will hopefully have them in a week or so, so look out for more news on my latest module!

Immersive Music Making

Posted on April 11, 2020

I sincerely hope this post finds you healthy. I’m sure, like me, you’re feeling your fair share of existential angst. Being on lockdown is vitally important, but it can be very difficult. It does give us all a bit more time to focus on some indoor creative pursuits, so this (Good) Friday, myself and a few friends did an Immersive Music Session. The premise is simple, you isolate yourself (already on brand), and try to write 20 pieces of music in 12 hours. I’ve been occasionally doing these for more than a decade. It’s based on an idea from this book, which I highly recommend. It’s an emotional and physical trial, but the results are often surprising. Once the day is done, you come out of isolation and meet up with the other participants and share your tracks over a few beers. Obviously that was replaced with a video chat this time around, but it worked surprisingly well. It’s lovely to hear and discuss everyone’s original material that didn’t even exist the day before. The idea of the process is that you are under such time pressure to create that you have to turn off your ‘internal quality filter’ which can sometimes filter ideas before they have time to develop. By the time you get to the end of the day, the tracks you composed in the morning seem like a distant memory, and listening to them again at the end of the of the session, it’s almost like they were composed by another version of you.


I managed 11 tracks (I’ve never managed more than 12). I started the day trying to work exclusively with my live rig in preparation for a live stream performance I hope to do later in the month. As time progressed I decided to try different approaches, including sitting in the sun with my laptop in the garden. Including the tracks below, unedited from the time they were recorded, so bear in mind some of these tracks were made in less than an hour!



IMM 1: This was recorded live (pretty much), with spring box and guitar being processed by my DIY eurorack effects.

IMM 2: This piece was inspired by my anxiety about my asthma given the Covid situation. My breathing has been a bit worse since I had a cold recently, so it’s on my mind.

IMM 3: This was made using a music box I bought cheap from eBay where you can feed in paper, which you hole punch to make the notes play. I wanted to make use of the fact that I’d made up another one of my looper modules, so could have 2 loops running at once. I didn’t quite get the counter-point between them I was hoping for.

IMM 4: This was made by processing a kalimba which I’d hacked to add a contact mic and jack socket. This was processed with glitch delay and audio freeze, as well as reverb and delay. I’m quite pleased with this one.

IMM 5: Wanted to make something with a bit more energy that I could play live. These drums were done in Logic after the fact (worked out the tempo from the recorded file). Not sure how I can do these drums live. Might see if I can achieve something similar with RadioDrum.

IMM 6: This was the first track I made sitting outside. My laptop doesn’t have any of the sound packs for logic installed, so I had to make everything with the built in synths. ES2 is actually a great little synth I think!

IMM 7: Just wanted to make something quick and fun, at a much higher tempo than I normally work at!

IMM 8: Wanted to try my own version of Steve Reich’s Piano Phase using Logic’s Piano in EXS24 and a simple piano line. I bounced it down, and duplicated it, panning left and right, and slightly stretching the right channel’s audio to achieve the phasing. I like the result, but obviously can’t really claim credit for the idea!

IMM 9: Back in the house again (temperature had dropped a bit), and using the DIY eurorack live rig to record again. The main sound here was a contact mic taped to a singing bowl, which I scraped and struck.

IMM 10: I had in my notes (I normally jot down some potential ideas the night before), “Create a sample as if sampled from vinyl”. I made a loop with drums and strings, bounced it out, and then degraded it to sound more like an old record (ran it through an amp simulation). I then cut it up, and made a new loop. I was running out of time at this point (had about 30 minutes left). I wanted to accompany it with the Hyve synth, but the 2 didn’t work, so I did a little jam for the last track.

IMM 11: Hyve synth run through some reverb and delay, and also, Valhalla Shimmer.


Posted on February 16, 2020

Recently, I’ve been working on a new firmware for the RadioMusic by MusicThing Modular.  I wanted to get some drums into my case using as little HP as possible, so came up with this. The drum patterns are stored as text files on the SD card. Currently it only supports one pattern, going to be working on multiple patterns next. Some of the samples were recorded from a vintage adding machine I found. You can use your own samples, but they have to be compiled into the hex executable file. You can find the source code on my GitHub if you want to check it out.


New workshop incoming

Posted on February 12, 2020

I’m going to be doing another workshop on using the Teensy to work with digital audio. Come along and build and program circuits, and make some NOISE. It’s at the Sonics 2020 festival in Hastings. I’ve been involved in the festival for the last few years, it’s great, and I really recommend checking it out. Lots of lovely pubs in the old town part of Hastings too! Sign up here.


First workshop done

Posted on October 20, 2019

Thanks to everyone who came to my ‘Digital Audio with Microcontrollers Workshop’ last weekend. I hope everyone had as much fun as I did! The first workshop sold out pretty quickly, so we ended up running another one back to back. A pretty exhausting day, but definitely a rewarding one. I was pleasantly surprised how far the groups got in 3 hours. Everyone got the Teensy to make sounds, and some people created some amazing noise-scapes! For anyone interested in what we covered, the workshop is on GitHub here. Thanks to Brighton Digital Festival and Platf9rm for making it happen!


Teensy Workshop

Digital Audio with Microcontrollers Workshop

Posted on September 30, 2019

I’m going to be running a workshop on Saturday October 12th for Brighton Digital Festival. See here for tickets. It will be an introduction to creating and processing digital audio using microcontrollers. The workshop will centre around the Teensy, which if you read this site, you’ll know I’m quite keen on! Teensy is a development board similar to Arduino. You will ‘bread board’ (a method of quickly prototyping circuits without soldering) your own circuit, which will utilise the Teensy along with buttons, leds, and potentiometers, which you’ll patch together to create a circuit. You’ll learn how to use the Teensy’s audio library and visual design tool, to connect together audio effects, and download the result onto your circuit, allowing you to experiment with sculpting and distorting sound.

The workshop will not require any specialist knowledge. There will be some programming and connecting of components, but you will be taught everything you need to know.

You must bring :

  • Laptop (capable of running Arduino IDE, it runs on Linux, macOS and Windows and doesn’t require a particularly powerful machine)
  • Headphones



Posted on August 23, 2019

I’m really excited to be featured as part of the ‘Hackoustic: Presents’ nights at Iklectik in London on September the 21st. I’ll be doing a small talk about my DIY instruments followed by a performance, and will then give any interested members of the audience a chance to try out the instruments for themselves.



View this post on Instagram

We have Gravity Synths, Bouncy MIDI controllers, generative music talks, inductive pendulums and DIY noise boxes run through DIY effects for DIY noises! @oddballism @leolodreamland @cutlassesmusic @vulpestruments @barryslounge @iklectikartlab

A post shared by Hackoustic (@hackoustic) on

Looper Version 1 Complete

Posted on July 11, 2019

If you’ve been paying attention to this site, you’ll have seen I’ve been working on a eurorack looper for sometime. The first version of this is now done. You can find the source code here.



What is it?

A looper module in the eurorack format inspired by the MLR app which ran with the monome. It records audio to an SD card, so is not limited by RAM constraints. It supports unlimited overdubs, only limited by headroom (e.g. if you layer over too many overdubs, the audio will begin to digitally clip). Once the loop is recorded, you can switch from Record Mode to Play Mode. This allows you to ‘cut’ the loop using the 8 buttons. Each button will jump to a section of the loop, essentially dividing the loop into 8 equal size segments.


How does it work?

The version shown in this video uses Version 2.0 of my Teensy 3.5 based audio board. This uses the in-built ADC and DAC to process audio. The audio is recorded to SD card. As SD cards are rather slow, especially when writing, I need to use 2 circular buffers. One for reading audio, and one for writing. SD cards are slightly unpredictable in terms of read and write speed (e.g. writing the same size block can take varying amounts of time each time you do it), I had to experiment to get buffer sizes that worked. These may need to change when using other SD cards.

I achieve overdub by keeping 2 copies of the audio loop, whilst one is being played, the other is being written to. At the end of the loop, the files are swapped (read file becomes write file and visa versa), and the loop starts again. When the Record button is pressed again, to engage overdub, the incoming signal is added to the recorded signal, and written to the write file.

I designed a separate PCB to deal with the 8 LED buttons. This communicates with the Teensy via I2c. The code is here. It uses a technique borrowed from the Le Strum by 64pixels which uses a shift register to scan the buttons and turn the LEDs on and off. Take a look at this schematic to see how it’s setup. Essentially a single bit at a time is shifted all the way through the 8 bit shift register. Each output of the shift register is connected to the LED and the switch of one of the buttons. So the single ‘bit’ will visit each of the buttons in turn. For each button we can read the value of the switch (is it pressed or not), and decide whether to turn on the LED or not (this is done by turning on the transistor). This is done very quickly, so you can give the impression a button is continuously lit, even though it is actually flashing on and off very fast.


What’s next?

I’m already working on Version 2 of this looper. I’ve split the buttons out onto a separate module which I plan to mount horizontally in the 1U section of my eurorack case, to save space in the 6U section. Features of the upcoming version 2 are.

  • Separate audio codec (WM8731) for improved sound quality,
  • CV control of the module, will allow for gates to control loop position, as well as controlling some of the functions mapped to the dials.
  • Option pedal input so you can record without having to press the button.

First experience with SMD reflow soldering

Posted on June 4, 2019

The newest version of the Cutlassiezer eurorack board is entirely SMD. This was to allow it to be as compact as possible. The component count has grown with each iteration. The concept is it’s a flexible back board that can support multiple ‘break-out’ front boards. So far, I’ve only made one front board, which breaks out, audio in, and audio out, 6 pots, and 6 CV inputs. Most of the SMD components on this board are 0805 size, which is totally doable to solder by hand, the audio codec is 0.5mm pitch which is trickier, but possible, a microscope is handy though. I wanted to be able to assembly a bunch of these, both for myself and to give to friends. Doing these all by hand would be time consuming, so I wanted to find a quicker option. I’m very lucky to have access to a friend’s workshop with a reflow oven and a laser cutter. If you don’t have access to such well-kitted out and generous friend, then check out your local hackspace, they’re likely they have both.

I wanted to try out using a reflow oven. A reflow oven is basically similar to a standard oven but has a well controlled ‘thermal profile’ which regulates the heat, so the temperature ramps up and down in a controlled manner, as ICs can be damaged if heat up or cooled down too quickly.


Reflow oven

The reflow oven I used


The reflow process is essentially:

  1. Make a stencil to allow you to apply solder paste only to the areas of the board where the pads on the PCB are. Solder paste is just ground up solder mixed with flux.
  2. Align the stencil over the PCB so the holes match in the stencil match the pads exactly. Normally you’d have some sort of frame to make alignment straightforward, but I did mine by eye and a rudimentary gig made of other PCBs (see below).
  3. Smooth the solder paste over the stencil onto the PCB so a very thin layer of PCB sits on each pad. This is similar to applying paint to a screen print.
  4. Painstakingly place each component on the board with tweezers.
  5. ‘Cook’ in the re-flow oven. This will melt the solder paste, and when finished you should be left with a beautiful and professionally finished board.

The Stencil

Generally you would use an aluminium stencil, they have to be very thin (sub 1mm), so need to be strong enough to withstand multiple uses. You can often get these machined by the PCB labs you have your board made at. As I was just experimenting I was happy with something relatively disposable. I cut my stencil out of Mylar sheet using a laser cutter. I exported only the pad positions from Eagle as a PDF, and set the laser cutter to ‘etch’ these out of the sheet. I used etching to avoid that added thickness of the laser that would result when cutting.


Laser cutting stencil

Stencil about to be laser cut


SMD Stencil

The finished stencil


A rudimentary ‘jig’ for aligning stencil



I made 2 boards. The whole process (including cutting the stencil), took less time than soldering a single board by hand, and the process was fun. On one of the boards the audio codec had some bridged contacts, presumably because I hadn’t aligned it well enough, but this was reasonably easily solved with a hot air gun (to re-align the chip), and a soldering iron with desolder braid.


SMD reflow board

The finished board after reflow

Case and new module finished

Posted on May 16, 2019

Nothing is more motivating than an imminent deadline, and my gig in Berlin served as a good end point to get my new case finished, and a brand new module into it.

The case was built out of a Habitat trunk, see more details here. I’m pretty pleased with how it turned out. It’s nice and light, and hopefully pretty sturdy. It survived the flight back from Berlin anyway.



The new module is actually just a re-working of the GlitchDelay, but it’s using the new PCB I’ve designed. Which uses Teensy 3.5 (again) coupled with an external WM8731 codec (for reduced noise), and has 6 buffered CV inputs. It’s all SMD to keep the size down. The idea is that I’ll be able to produce different front panels, for different module functionality, but keep the back panel the same. I laser cut a panel on ply-wood for the first time. The contrast between the etched and non-etched material is much higher than with the acrylic, which I like.



Next on the agenda is to modify the case to squeeze a row of 1U modules in. Ideally I can just use this case, with external noise boxes/instruments when playing out live.