(code for this is available on Codeberg btw: https://codeberg.org/lhinderberger/monosynth)

#LuBuildsAMonosynth

monosynth

A Monophonic Synthesizer (work in progress)

Codeberg.org

The problem is: A couple of years ago, I got rid of my old electronics components when moving to Leipzig. And that means that I don't have any capacitors at the moment.

So I'll spend the next couple of days planning ahead a bit on which components I might need and then I'll make an order at $some_electronics_shop.

And this concludes this weekend's monosynth adventures.

#LuBuildsAMonosynth

Sat down this evening to research line level audio and to generate a quick test pattern on the DAC, and I'm pleased to see that it worked on the first try ๐Ÿ˜ƒ!

Now I need a way to get rid of the DC offset. I'm thinking about a simple high-pass RC filter (hopefully it won't affect the sound too much though).

And I need to add a series resistor so that I don't immediately exceed the pin's current limits when connecting a speaker, plus a potentiometer for volume control.

#LuBuildsAMonosynth

Found the culprit - I used the wrong address offset for NVIC_ISER1, leading to the interrupt never actually being enabled. I also forgot to reset the interrupt flag in my handler, which gave me the opposite problem: it made the interrupt fire way too often (once the input actually fired ๐Ÿ™ƒ).

Now it works and I went from a blinky LED to.... a blinky LED ๐Ÿ˜„. But one that is now driven by a timer! I should be able to easily extend this into driving the DAC with a timer now.

#LuBuildsAMonosynth

That timer interrupt just won't fire. I tried pretty much everything: The timer itself is running and seems to auto-reset at roughly the correct interval (verified the counter register in GDB), the interrupt is enabled in the timer control register and in the NVIC and the handler is placed in the interrupt table at the correct location (otherwise my fallback handler would have fired). But still, no luck.

I'll get some sleep now and try again tomorrow.

#LuBuildsAMonosynth

oh, it was easier than I thought. just had to hold down the reset button while connecting the debugger. :-)

#LuBuildsAMonosynth

welp, managed to lock myself out of the STM32 ๐Ÿซ ...

Probably has something to do with my program entering sleep mode inhibiting the programmer/debugger to connect.

I'll try and find a fix today, but probably it will have to wait until tomorrow.

#LuBuildsAMonosynth

Got sidetracked a bit, but sat down again in the evening to read the docs on the DAC and timer. Spent waaay too much time figuring out what clock the Nucleo board actually uses too ๐Ÿ™ƒ. But I think I now have a clear-enough picture of how things work to be able to proceed. So the next steps are modifying my blinky LED program to use a proper timer and then setting up the DAC with the timer at ~44100Hz to output a simple sawtooth wave.

#LuBuildsAMonosynth

Before writing any code, I wanted to see if a 12bit DAC would even theoretically be enough to produce decent-sounding audio. So I went ahead and made a little experiment by exporting raw audio data as signed 16bit samples from Audacity and filtering that with a quick-and-dirty C program that ANDs all samples with 0xFFFC. The result sounds indistinguishable to the original, at least to my ears, so I'll go right ahead with testing the built-in DAC next.

#LuBuildsAMonosynth

Built and installed Vim Classic now. Got Editorconfig and Wayland clipboard integration to work again after a bit of head-scratching and installing two plugins from source.

I usually don't install software from outside the Debian repos, so not too sure how I feel about this yet.

#LuBuildsAMonosynth