I have made a weird musical instrument. It is some kind of electronic just intonation kalimba I guess? With stars?

I have zero musical skills so I made it pentatonic, which means I can just bash keys at random and it will sound quite pleasant.

For the technical details, it's built around a Sipeed Longan Nano microcontroller module, connected up to a small amplifier, some little pill box speakers, and a bunch of microswitches. The microcontroller itself is a GD32VF103, a weird Chinese creation of dubious legality that stuffs a RISC-V core into a clone of an STM32F103 to replace the original ARM core.

It's pretty fast, and can run the built-in tiny LCD at 60 FPS along with 10 voices of Karplus-Strong synthesis.

I love the Karplus-Strong algorithm, it is a completely bullshit way to simulate a stringed instrument cheaply:–

It can be a bit tricky to tune that algorithm since in its simplest form it can only be tuned to integer divisions of the audio frequency. Using just intonation helps here!

The sample rate is 48000 Hz, and the "strings" are tuned to that divided by 54, 64, 72, 81 and 96, and then double those.

@WAHa_06x36 I dunno about bullshit... it looks pretty close to how a string instrument works to me.

@WAHa_06x36 this algorithm makes no sense and yet it appears to produce pretty good results

@WAHa_06x36 "bullshit ways to simulate instruments cheaply" is a good summary of physical modeling synthesis in general.

@WAHa_06x36 it's legality isn't dubious anymore, and as a result ST has moved all their code over to the (i am not making this up) ULTIMATE LIBERTY LICENSE.

you may be surprised to learn that the definition of "liberty" has been changed in the terms of the license.

@WAHa_06x36 wait so is the CPU emulating the arm ISA? or does it just match the pinout?

@aeva No, it's fully RISC-V. I didn't check the pinout, it might match. But the thing is, a microcontroller like this contains a lot more of hardware than just the CPU core, used to talk to the outside world. SPI and I2C buses, ADC and DACs, and just regular IO pins all need silicon to drive them. So what they did was take STM's design for all that, and just cut out the CPU core, and dropped in a RISC-V instead.

@WAHa_06x36 ear training mod:

solder leads to the microswitch contacts. repurpose esd bracelets as grounds. have it go through scales, compositions, &c: you play along & it shocks you if you get the notes wrong

@wren Hahahah. I was already wondering if you could use the metal switch arms for some kind of secondary sensing, but that is a funny inversion of the idea!

@WAHa_06x36 that does require some musical skill to know, if you ask me.
The public xylophone in my hometown central plaza is also tuned pentatonic for the same reason 😄

@korgmatose I only have weird theoretical musical knowledge, and no Finger Skills!

@WAHa_06x36 Hehe, gatekeeping musicians behind the notion of "having dexterity to perform manually on an instrument" was thankfully disintegrated with the advent of electronic instruments :) I'm super-impressed by the electronic kalimba.

@korgmatose I mean, I ALSO don't know how to put notes in an order that makes them sound good.

Thank god for the pentatonic scale where the answer to that is "any".

@WAHa_06x36 This is awesome!! Will you be opensourcing the specs/software and write some docs on it?

@witt I could opensource the code and designs, sure, although the latter aren't much to write home about. Thinking about making a more mass-produceable version that can be manufactured as a single PCB in the future maybe, we'll see.

@witt I put the code up on for now. Didn't set up a license but it'll probably be CC0 when I get get around to it.

@WAHa_06x36 Hah, well, considering I haven't put together my mechanical keyboard which is mostly just diodes, *any* hardware hacking seems really epic to me 😅😃

@galleywest I've been pondering moving over to using the RP2040 instead of the highly weird GD32V, so not a bad idea! The RP2040 is faster too, and could dedicate one core entirely to audio and the other to graphics.

WaveShare does a similar module to this one, with the same tiny little screen, but it's a lot more expensive than the Longan Nano, which is a shame.

But if you don't care about a screen, then the stock Pico module should work perfectly.

@WAHa_06x36 now just do it in reverse where you have to match the notes falling down on the screen and you have a training system/clone hero built in!

@Ranjit That was a strict design parameter!

Trying to come up with some other cheap and weird synthesis techniques to add some other kinds of sounds to it. Would be nice to have some kind of percussion backing maybe?

@WAHa_06x36 @ranjit

You mean, other than the castanet effect of the microswitches?

@publius @Ranjit I was looking at finding quieter switches for a bit, but the clickiness is also incredibly satisfying.

Excellent! Karplus-Strong is such a wonderful algorithm ... see also the works of Ron Berry who uses the same techniques in hardware.
Karplus-Srong has some variations that make drum like sounds. More resonant drums like bass drums can also be made with Karplus Strong and shorter decay times. Try tapping the delay line at multiple points to add additional resonances to the K-S algorithm.

@Steveg58 Hmm, interesting. I was reading the original paper and tried the drum effect they used there, but it seemed to just end up in practice being white noise with a really short decay, which didn't sound very interesting. But adding multiple resonances, hmm...

If you look at the circuits for something like a TR808 you will see that the drum sounds are just a bunch of slightly detuned Twin Tee filters which is a similar result to the K-S algorithm. By varying the probability of inverting the signal in the K-S drum algorithm you will get something more or less tonal. Do you do anything to guard against energy leakage during the averaging process (carry forward remainders etc)?
Do have a look at the Ron Berry acoustic modelling pages: You can implement most of his stuff in software

@Steveg58 I replaced the two-tap box filter that the original algorithm used with a three-tap sort of Gaussian filter, which lets me tweak the amount of damping and decay a lot more, and gives me an one-sample delay instead of the annoying half-sample delay of the original design.


does it have midi support? 😜 😂

serious: do you plan on integrating some sort of filter, modulation and/or fx in a future revision?

@pmj No MIDI, and since it doesn't use the standard equal temperament tuning, MIDI would be kind of awkward.

I did consider trying to implement USB audio though so that you could record it by connecting it to a computer. Let's see if I can be bothered though.

Some kind of FX might be nice, but not sure what exactly would fit in with the rest of it... I'd more like to make some alternate instrument modes with some weirder sounds!


you can never go wrong with delay/echo, distortion or room fx 😎

alternate instrument modes sounds interesting 👍

as for the recording part - a jack output would be largely sufficient since most people who create or work with music already have some sort of audio adapter
personally, i find it quite annoying that every single device needs to have its own usb audio interface
if you plan on adding usb, use it for editing tones/fx only

@pmj The audio output here is most definitely not great quality! It's just a PWM signal at, like, 12 bits, fed through a single capacitor. It works for the little speakers on the board but I think if you recorded it it would sound pretty awful.


that could even make it a real steal - some of the appeal of old synths is their quirkiness and unique sounding caused by their analogue components and wiring
and some synth purists are looking for some kind of imperfection since the new/current digital or hybrid stuff sounds too clean/perfect

@byteborg I need to figure out how to make it a bit more mass producible!

It looks very neat and the ergonomics are quite nice, I think.

@byteborg Still want to figure some way to shape it if I use a bigger PCB so that it's easier to grip. Probably would end up looking like a game controller though...

Sign in to participate in the conversation

The original server operated by the Mastodon gGmbH non-profit