Alright, after weeks of being too busy to do anything, it's finally time again for some #LuBuildsAMonosynth today!

My goal for today is to test the DACs built into the STM32F446 if they're suitable for producing at least passable audio and to maybe experiment a bit with generating different waveforms, depending on how much time is left.

And since #VimClassic was released a couple of days ago, I'll use this as an opportunity to install and test-drive that as well.

#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

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

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

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

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

#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

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

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

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

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

#LuBuildsAMonosynth

monosynth

A Monophonic Synthesizer (work in progress)

Codeberg.org
@lu_leipzig A few days ago, I needed a few capacitors for a project I didn't have new on belt any more, but I found them in an old Kobo mini with a broken screen.
@deBaer Yep that would be an option but I don't think I have any broken electronics (*that would yield me through-hole components) lying around at the moment.
@lu_leipzig πŸ‘πŸΌ Genau. Morgen kommt die LΓΆsung von allein ... πŸ™‹πŸΌβ€β™‚οΈ