Contents

Melancholytron: Writing the Firmware

A while ago my brother Allard Krijger asked me if I wanted to write the firmware for a new instrument he was designing. The instrument is called the Melancholytron: a book about melancholy and an instrument that can play it. Most of what I have to tell is about the firmware.

Introduction

The book is a large coffee table volume of 72 pages with stories, poems and illustrations about melancholy, published by FRAKnoise. The instrument is not a synthesizer in the sense of oscillators and filters that you dial in. It plays samples, one for each key, and the whole thing is built around the idea that it should always sound melancholic.

The team for the first version was small: Allard, Edwin van den Oetelaar and me. Allard did the overall concept and the sound design, and wrote the stories and illustrations in the book. Edwin did the circuit board design. Bram Bos had built the first version of the audio engine for Allard before I was involved, the part that plays the samples, and Allard asked me to write the rest of the firmware around it. My part is listed as software design. That started with reading the keys and knobs and managing the presets, but the bulk of the work went into the sample playback: the effects, the loops and the crossfades, and making the whole thing play without clicks and survive an SD card that sometimes takes its time.

For the production version Roy Gilsing joined the team. The aluminium case is his design and so is the website, and he worked from what we had learned with the lasercut version.

The Melancholytron was first shown at Superbooth in May 2025, as a book with an instrument beside it, in a lecture concert and on the FRAKnoise booth. What stood there were prototypes of the lasercut version, which later became the classic Melancholytron. A year later, in May 2026, Allard brought the production version and introduced the desktop model next to the keyboard version, and the pre-order opened around that show.

My Role

My part of the project came down to three things.

  • The firmware running on the Teensy inside the instrument. It was the largest of the three, and it is where the difficult problems were.
  • The case of the first version. It was built from lasercut panels, and I made the drawings so the boards, the keyboard and the front panel would fit together. That is the classic version, and all eleven that were built have been sold.
  • The packaging of the production version, with my friend Emiel. Emiel did the original design. I built and tested the prototypes, fixed what did not work, and made the final drawings for the manufacturer.

The instrument ships in a cardboard box, one for the version with the keyboard and one for the version without it. Inside, the instrument sits between folded cardboard buffers around the book, the ends and the corners. Emiel had two warnings about the cardboard: its corrugation has to run across the fold lines of the buffers, or the folds come out the wrong size, and the board has to be the good grade, because the cheap kind is not the same board. The buffers went to the box maker as DXF drawings.

I did not design the sound. The samples and the presets are Allard’s work. My job was to make the instrument behave predictably around them, which was not trivial.

Most of the work on the production instrument was done without a case. This is a prototype of the production version: a keyboard, the board that scans the knobs, a small mixer for the output, and nothing built around any of it.

/posts/melancholytron/melancholytron-setup.jpg

The Instrument

The instrument has 25 keys, and they are not velocity sensitive. There are eight knobs, a slider that the documentation calls the “looming” slider, and two buttons to shift the keyboard up or down an octave. On the left there is a small round button marked “paradigm” and a single LED that shows what the instrument is doing.

The classic version also has two wheels to the left of the keys, a pitch bend and a modulation wheel. They came with the keyboard it was built around, and the production version has no equivalent. That is the clearest difference between the classic and the production panel when you see them side by side.

The published panel legends are poetic: darkness, context, waiting, linger, clouding, stress, weight and focus. In the firmware those are just MIDI control changes with numbers and a range of 0 to 127. The names describe what the knob does to the sound, not what it does to the signal path, and that is a good thing. It means the sound design could change without me having to rename anything.

On the classic panel the knobs sit in two rows of four, with the octave buttons and the word altitude to their left, and the drawing to the right of them, engraved rather than cut: concentric circles around a pivot, a large disc, hatching that runs off its lower edge, a flag, and the name in outline letters underneath.

/posts/melancholytron/melancholytron-cover-plate.jpg

There are around 400 presets, each one a sample per key, which is why the sample library does not fit in the memory of the microcontroller and lives on an SD card.

There is MIDI In, MIDI Thru that can be configured as MIDI Out, a mono jack output, and a 9 to 15 volt power input.

Classic and Production Melancholytron

There are two designs. The case is the obvious difference, but the one that matters for the firmware is the keyboard, and MIDI follows from it.

The first version is built from those lasercut panels, and eleven of them were made. At Superbooth in 2025 there were prototypes of it, not finished instruments.

The case was drawn in FreeCAD, as one assembly with the boards, the keyboard and the cover plate in it, and the panels were exported to DXF for the laser cutter. The plates are kept apart by printed supports, and the keyboard rests on printed feet, so the case is lasercut panels with a handful of printed parts between them.

/posts/melancholytron/melancholytron-cut-parts.jpg

The parts, pulled apart: the cover plate on top, with the holes for the keys and the controls cut into it, and the bottom, the sides, the back and the brackets that carry the boards underneath. The plates join with fingers and slots cut into their edges.

Both instruments are called the Melancholytron, so I only use a name when I have to tell them apart: the classic Melancholytron for the first version, the lasercut one, and the production Melancholytron for the one with the aluminium case. The rest of the time it is just the Melancholytron. In the firmware they are two branches, the classic build and the production build.

The two versions differ in the firmware as well as the case, and the difference starts at the keyboard.

The classic Melancholytron uses an existing keyboard with MIDI built in, so the firmware listens to that keyboard: notes, pitch bend and knob movements arrive as messages on a serial port. The only switch the firmware reads itself is the paradigm button. Everything that comes out of that keyboard takes the same path as a note or a control change from outside, so the classic board is really a MIDI controller with an audio engine attached.

For the production version the firmware scans the key matrix itself and reads every knob, the slider and the octave buttons through a multiplexer. That is more direct control over the panel. There is no second processor between a key and the note it makes, the two octave buttons are in the firmware instead of in a keyboard, and the LED is an addressable one that the firmware uses for colour instead of a single brightness on a fixed pin.

That keyboard has no MIDI in it, so the production version has nothing native to listen to. I wrote the keyboard scanner and the firmware generates its own note and control events, and MIDI became something the instrument speaks rather than something it is built around. It therefore has more MIDI functionality than the classic one, not less: MIDI In with a selectable channel, a Thru that can be switched to Out, and a local on and off that decides whether the keys also play the internal engine while MIDI is connected.

Both builds come from one codebase. The scanned keys and the MIDI input end up in the same note buffer and the same voice engine, and the same preset format and the same setting names work on both. What differs is where the notes and the knob movements come from: a scanned panel on one side, a MIDI keyboard on the other.

The classic instrument did not stay on the old firmware. When the production build was done I backported it, so the lasercut units can run the same voice engine, the same archive reader and the same settings as the production one. Only the code that reads its panel and its MIDI input stays its own, because that is all its hardware needs.

The triangular octave buttons are where the firmware difference is clearest. On the classic instrument the keyboard moves its own octave and sends higher or lower note numbers, so the firmware never sees it and the note numbers simply arrive shifted. On the production version the octave lives in the scanner, the firmware shifts the key position by an offset itself, and that offset is stored in the preset and reset when both octave buttons are pressed together.

The production version has an aluminium enclosure, designed by Roy Gilsing. Getting it manufactured took longer than any other part of the project. The panels are bent by a Dutch company. The wooden side panels Allard cuts himself, from floorboards of demolished Philips workers’ houses in the Edison district of Eindhoven.

That version comes in two sizes: with the keyboard, and the No-Keybed Construct, which is the tabletop model with a shorter book of 40 pages.

/posts/melancholytron/melancholytron-workshop.jpg

The Hardware

The instrument is built around a Teensy 4.0. The classic version carries the Teensy Audio Adaptor board on it, with the SGTL5000 codec and the SD card slot. For the production version Edwin designed a board of our own, with the same codec and the same kind of card slot. Either way the Teensy gives a 600 MHz Cortex-M7, and the Arduino audio library is well supported on it. For a sampler that streams from an SD card and needs to do a bit of DSP on top of that, it is a very comfortable place to be.

In the production instrument there is a second board with an analog multiplexer, which is how the firmware reads the knobs, the slider and the three buttons. Its keyboard has no microcontroller of its own. It is a matrix of contacts, and the firmware generates the clock and reads out the rows and columns itself. That is where the firmware job became an electrical one, and it is also the part the classic instrument does not have.

By the time the production layout was done there was no pin to spare. The key matrix, the multiplexer, the MIDI ports and the audio board take every pin on the header. The LED was the last thing to place, and for a while there was no pin left for it at all. One turned up in the end, and the LED runs on that single wire, which is the other reason it is addressable.

The project is a PlatformIO project targeting teensy40, using the Arduino framework. That choice was mostly practical: the Teensy Audio Library is written for the Arduino environment, and PlatformIO gives me a normal build system and a platformio.ini to keep the build flags in one place.

The Audio Path

The solid core of the engine is still Bram’s, the classes he wrote in 2017 for playing samples out of a buffer. That core is the interpolation of a sample as it plays. Everything around it I changed or added: the streaming from an SD card, the decoding, the envelopes, the pitch envelope, the wobble, the looping, the crossfading between voices and the mixing structure. His six files came to just under five hundred lines. The same three classes are twelve hundred now.

The audio path through the firmware is not very complicated, and that is on purpose.

Each voice streams losslessly compressed samples from the SD card through a decoder. The decoding happens in the main loop, on the same core as the keyboard scanning and the SD card I/O. The audio engine renders in blocks of 128 samples, which the audio library pulls at a fixed rate.

The interesting part is the handover between those two worlds. The Teensy audio library wants to be fed on its own schedule. The rest of the firmware wants to read the keyboard, scan the knobs, handle MIDI and do SD card I/O, which occasionally takes a long time. If a note starts while the SD card is busy, the queue of rendered audio runs dry, and an underflow is audible as a click or a gap.

The way I solved that in the end is to render audio ahead of time into a queue and to refuse to start a new note unless the queue has enough lead. Starting a note means opening a file, decoding the first block and setting up the stream, and that is exactly the moment the queue would starve. So a note that arrives when the queue is too short is not dropped. It is put in a note buffer and retried on the next iteration of the loop, and only when the queue reports enough lead does the loop take a note out of that buffer and start it.

The queue has sixteen slots, and a note may only start when at least twelve blocks are rendered ahead. If a player hits a chord, the notes are started one per loop iteration instead of all at once, which spreads the cost of opening files over a few milliseconds. It is a small trick, but it is the difference between an instrument that clicks when you play fast and one that does not.

/posts/melancholytron/melancholytron-book.jpg

Presets

Allard recorded the raw material as 16 bit mono WAV, one file per key. A sample is between 3 and 16 seconds long, and a preset has at least 25 of them, usually more, because some presets cover a wider range of octaves. A Python script I wrote turns a directory of those files into what the instrument reads. It compresses each recording losslessly, packs the samples of one preset into a single archive, and builds the tree that goes onto the card: one folder per preset, named after its program number, with the archive, a file carrying the preset name and its settings in it.

A preset is selected with a chord. A short press on the paradigm button arms the selection, the LED turns green and the keys stop playing. When every key is up again, the firmware takes the keys that were released in the last 200 milliseconds, builds a bitmask out of their pitch classes and uses that as the program number. G sharp and A sharp together is program 1280. It is a strange interface, and it works remarkably well, partly because the instrument has no display to show you a menu.

More Information

The project has its own site. The about page has the credits, and the news page has the occasional update from the workshop about the production.

Allard’s own channel is FRAKnoise on YouTube. It has the first introduction from early 2025, when there was no production model yet, and clips from the workshop such as sampling a tired citer for the Melancholytron.

Superbooth Berlin recorded both lecture concerts. The 2025 one is just under twenty minutes, from 9 May 2025, and is the best explanation of the idea that exists: the book, the sounds and the panel legends in one go. The 2026 one is twenty eight minutes, from 8 May 2026, and it introduces the current version with the desktop model. The exhibitor page has the official text for the show.

The videos from the booth are the closest thing to a demo:

  • Sonicstate talks to Allard for twelve minutes and plays through the knobs while the names are explained.
  • Let’s Play Synths is twelve minutes as well and covers the same ground, but the playing is different.
  • CatSynth TV has four minutes from the booth.
  • Project Kachimizu is seven minutes on the book and the instrument as one concept.

In the press there was Synthtopia at the announcement in 2025 and again at the release in 2026, and Sonicstate wrote it up as well. Elektronauts has the longest thread, started by a forum member who reposts the newsletters, and that is where I would look for shipping news.

There is also music made with it. EAR released an album of six pieces created with the Melancholytron, and it is on Bandcamp. It is a good way to hear what the presets do for someone who is not the designer.

On social media the project lives on Instagram. Facebook has Allard’s own profile and the hashtag #fraknoise, which mostly collects what the press posted. There is no page for the project itself.

To be continued

This is where I will stop for now. The next part covers the voices: the envelopes, the pitch envelope that gives the instrument its slightly unstable character, the Perlin noise that is used as a slow pitch wobble, and the crossfade that keeps the voices from clicking when they overlap. It also covers the knob scanning on the production instrument, the key matrix, and what the project came to mean to me.

Credits

Allard Krijger took the photographs of the production and desktop instruments on the workbench, and of the book. They come from melancholytron.com, where he has a nice write-up of the project. The cover plate was photographed by Synthtopia.

The first photograph is a still from the Sonicstate interview with Allard at Superbooth 2026. The prototype photo is mine, and so is the exploded view of the case, which I rendered from the FreeCAD assembly.