I wanted controllers for my self-hacked Zynthian which were fully midi-implemented, and I built said controls on the Teensy platform. I have made the sketch available on github for anyone who wants to do the same for any reason. The README file is not done yet, but the sketch is already there and the GPIO-savvy will understand what’s going on, it’s ultimately quite a simple sketch, depending:
The sketch is designed based on the current testing branch, and is ready for V5 from the controls standpoint - there’s no RGB leds just yet, and unlikely I’ll go that much effort, from here on I’ll rely on the official hardware for the official UI, though I’ve got some zynthian-based devices of my own planned.
For switches (up to the 20 required for v5) you only need to provide the pin numbers to the array in the indexed order of the CUIA binds currently present on the testing branch. Which is to say, assigned to Note 90 and up, so index 0 = 90, index 1 = 91, etc. Tip of the hat to the devs for implementing those actions all in a row like that.
The encoders are a moving target at the moment, because testing does not assign them by default, so anyone implementing this code today will need to assign each encoder’s up and down actions manually. There is a 9-key run of free notes starting at E1, and I mapped them down/up starting from there. Hopefully future updates don’t mess with that in any way.
If the user does this same implementation, my code will work as is. If Zynthian is planning to use those keys for something else by default, this will become more difficult - at the very least, an array of note assignments would have to be maintained and implemented in the code by the person setting this up. Hopefully they either use those control notes the same way I did, or at least leave them free by default.
The good news is that if this rigorous sequentiality is maintained in assigning CUIA actions, the setup() and loop() functions can be completely ignored, just setup your CUIA right, assign your pins in the correct order, make sure it’s set as a MIDI device, and go. It is unlikely, as I said, that this code will be updated to handle the LEDs for V5, but in all other respects it should work fine for V5 layouts as long as the indexing is maintained.
I am toying with the idea of trying to make this smarter - talk to the Zynth with OSC, find out which notes are assigned to the required actions, and send notes intelligently - but it will largely depend on how much I need to hack on the zynthian end of things, it’s still a big scary codebase, but I’m getting more used to big codebases as I go…