Close

Getting the engine to work on the ESP32

A project log for openSampler

a hardware sampler based on the raspberry pi running bare metal (so no Linux)

nick-verlindenNick Verlinden 11/14/2020 at 16:222 Comments

I just couldn't help myself. Remember the lengthy talk we had about perfection and OCD in one of the previous logs? Well, the demon strikes again. I was busy with work, that made me work on a modular casing system that is about 90% completed. I have to wait for some parts to come in from China, so that's put aside for now. Then I got sidetracked because I found this Hyperpixel 4 display, and that used up all pins on a Pi, so I decided to rewrite my graphics layer to allow for remote commands over i2c. And while at it, I decided I would do it in plain C, because then I can reuse my graphics layer on the esp32. I know you can use C++ on the esp. I just prefer not to.

I just bought this briliant watch, the Lilygo TWatch 2020. The graphics layer is also about 90% finished, and ready to be used. Then I thought, gee. I have all these ESP32's lying around and have got nothing to do with them. Wouldn't it be awesome if I could make some kind of a micro sampler reusing my existing (simplistic) audio engine? My Pi with touchscreen is a bit bulky to develop on and take with me for developing on the road, so I decided to go for it. First I made it work on the internal DAC, then using and external DAC. Then just for fun, I tried to get it to run on the watch. After some fiddling I realised that all examples for this watch are written with the Arduino framework. I'm using esp-idf, so I had to figure some things out. I discovered the reason it didn't work on the watch was because the DAC was not powered on when the esp32 boots. Makes sense, it's a watch, power management is very important there. You need to talk to the power management unit in order to power it on. I traced the code required to get it to power from several examples online. Once that was done, it was working on the watch as well. You would think the watch would use the internal dac to connect a speaker, but they decided to go with an all-in-one package i2s codec + amplifier.

Oh boy, that feeling of accomplishment... You see, I fell down this rabbit hole of side-quests. But I gained a lot of experience in doing so ;-). I also learned that I could get about 20 mono voices with pitching and gaining to work on a single core of the ESP32. Impressive, i thought it was gonna be a lot less.

Anyway, the plan is now to work more on the engine, so i hope to see some progress in there. I'm also still learning how to properly structure and organise a project targeting multiple hardware platforms, so unfortunately there will be a lot of refactoring along the way. But a tidy house, is a nice house :-)

Hope to talk to you soon.

Discussions

Holman Buenaventura wrote 06/06/2024 at 06:33 point

Hello, wow it's incredible, I congratulate you, it's a great project, I did something very similar and I just published it here on this site, I don't know if it would be possible for you to share your code for the esp32 and maybe you would like to take a look at my project. https://hackaday.io/project/196389-samplersynth-library or directly to github https://github.com/habuenav/samplerSynth

  Are you sure? yes | no

Craig Hissett wrote 11/15/2020 at 23:27 point

Thisbis awesome! That watch reminds me alot of the m5Stack. I have a few m5Stacks needing a project, and I'd love to try and use them in a similar way.

I've recently been experimenting with Pure Data writing a rather large loopstation patch. It's getting close to being ready and hopefully ran on a Pi 4 using PatchboxOS. 

  Are you sure? yes | no