Chirp: dynamic MIDI router 5x5 with USB and scripting engine in Wren

atom

New member
I bought this breakout board 5x5 MIDI some time ago, but never done anything with it.
1774376250857.png
Now that I had access to a coding agent (github copilot in this case) I decided to give it a whirl and implement something that was in my head for some time.

This is mostly AI generated coded for now, be warned.

A dynamic subsystem with custom scripts I can update without restarts/MIDI losses, each script can access all ports and other scripts. First i was looking into Lua but as I was interested in something new, i found Wren. It seems to work, i'm getting decent performance after tuning the Wren GC and VM settings for Teensy. I'm testing display interaction to get some visual feedback from each script and a simple encoder for menu navigation (though most of configuration will happen through custom MIDI messages for each script). I ad to add a SD card reader as the internal flash is not suitable to hold a lot of small files and i ran out of space very quickly. That is not to say you can do that, the needed .wren code is generated and minified on built and placed on the Teensy if the SD card init fails it uses the internal flash.

1774376223611.png

Most stuff can be configured in the Makefile, and yes it's a makefile project using arduino-cli and a lot of hacks, but I wanted to use my IDE work my way. There is a bug in the Teensy core 1.60 i think (i will try to open an issue asap) that will ignore the extra build parameters you want to pass in arduino-cli this is because the platform.txt of the Core does not include those parameters in it's build steps for Teensy, I had to patch that manualy.

The project is at: https://github.com/RomanKubiak/chirp there is still a lot to do as it's mostly LLM generated code, so i'm trying to make it usable/readable/maintainable. Any feedback/feature requests/bugs are always welcome.

ps.
The first thing I implemented is a kind of MIDI CC mapper, i have a broken beatstep PRO that i can't reconfigure (i burned the USB interface and it's only configurable through it) so the control section has 16 knbos with CC values i can't change BUT :) I can change the MIDI channel. I want to control all parameters of my Novation DrumStation synth and there is a lot of those, so i created a linear map of 16 CCs on different channels (16x16) to a map of all instruments and parameters on the NDS, now I can easily program the synth live, i added a simple display so I can see what parameter i'm editing and what are next/previous ones so I know where to go to edit a certain instrument. That's what I needed this for. This is the NDS.wren script in the repo and there is a corresponding .json map that the script loads.
 
Last edited:
Looks like an interesting project. I spent some time tinkering with adding scripting to a MIDI controller project as well a few years ago. I passed on Wren at the time but maybe I need to revisit. I ended up using the Elk javascript engine at the time which worked alright.

I never considered having custom scripts call into other custom scripts. I just wanted to be able to apply custom mapping to MIDI messages. Seems like a more open system could lead to some unexpected new features!
 
Most stuff can be configured in the Makefile, and yes it's a makefile project using arduino-cli and a lot of hacks, but I wanted to use my IDE work my way. There is a bug in the Teensy core 1.60 i think (i will try to open an issue asap) that will ignore the extra build parameters you want to pass in arduino-cli this is because the platform.txt of the Core does not include those parameters in it's build steps for Teensy, I had to patch that manualy.

This is an intentional design choice by Teensyduino. Here's how I get around it:

References:
* This is what I do: https://forum.pjrc.com/index.php?th...d-options-using-arduino-cli.77536/post-364774
* This is how to change platform.txt: https://forum.pjrc.com/index.php?threads/teensy-with-arduino-cli-and-make.75944/post-350527
* Request for a change: https://forum.pjrc.com/index.php?threads/request-for-arduino-ide-extra_flags-support.72556/
 
Back
Top