Keybinding Questions

I’m new, just finished my custom build of zynthian, with a rpi2040 keyboard with a similar layout to the official v5 and I have some questions for the keybinding part.:

  • Is it possible to map a keyboard button to load a preset in the preset screen without actually loading the control view? Similar to what the preload option does but manually triggered

  • And another quick one, is it possible to set up a “key” to behave like a V5_ZYNPOT_SWITCH with all 3 states? example, key C would trigger push, short, bold depending on the time pressed instead of one per key. V5_ZYNPOT_SWITCH %i, %t Simulates V5 rotary-switch %i action of type %t (Push ,Short, Bold, Long)

  • Is there any action to page_up / page_down in the list of presets?

  • TOGGLE_ALT_MODE doesn’t work? Is alt in keybindings supposed to work with this or it is just a keyboard alt?

Thank you for your hard work on Zynthian, it is amazing!!

1 Like

Hi @baj! A warm welcome to the Zynthian community.

It would be interesting to see details / pictures of your rpi2040 keyboard. You don’t really explain what that is.

Please be explicit when you use the word “keyboard”. Although Zynthian is a musical instrument and hence the “keyboard” usually means a musical keyboard (manual, pedals, etc.) it may also mean a computer keyboard or switch panel. Either way, mapping commands to functions in Zynthian is done with a kind of API called CUIA. (We are enhancing this but currently it is possible to control a lot of the UI and some of the core functions.) Webconf is used to map computer keyboard keybindings, MIDI keyboard bindings and hardware switch bindings. (Note: These are all done in different ways in different places. We want to rationalise this.) To answer your question… the preload occurs when a MIDI note is received. We currently do not have a way to preload a preset other than this. This needs some attention. Loading presets can be slow, especially if the processor (e.g. synth) needs to reconfigure, e.g. select and load different banks of sounds. This is why the preload is not done automatically as we move between presets and why the first MIDI note often sounds the wrong preset. We are considering how this might be improved, e.g. identify processors that can load their presets quickly so that they may preload on cursor change but this is not yet being actively worked on.

Yes! The CUIA command is ZYNSWITCH and its parameter is the switch index (zero based). By default MIDI notes 90…126 are configured to do this.

This is not implemented but scroll on arrow button hold is implemented in a development branch so should arrive at some point in the future.

This relates to the ALT key on the V5, not computer keyboard alt key. There are alternative actions triggered by the hardware buttons when ALT is enabled. On a V5 the releavant keys change colour (purple) when ALT is enabled. Example change of functionality is that the transport controls point at the MIDI player / recorder instead of the audio player / recorder.


Hello @riban, thanks for the answer!!

You are right I should have make it more evident that my questions are about “computer keyboard”.

The keyboard is just a rpi pico based diy mechanical keyboard (with KMK firmware) that is connected to the rpi4 via usb. But after reading your reply I now wonder if I should consider convert this into a midi device!

this is a pic of my build, the encoders are connected directly to the gpio but without the switches as they have some issues on the navigation.

I’m open to suggestions/ideas on what is the best approach so that the keyboard behaves as close as possible as the official v5 kit, or/and the 1/2/3/4 keys behave like the 4 encoder switches (3 states)

1 Like

The keypad could be connected via USB as MIDI or HID or you could implement an I2C target device. The latter would be just like the Zynthian hardware, i.e. a button is presented as a I2C register but this may take some low-level tinkering.

Presenting as HID (as you have already done) is fine. The keybinding is well supported and I would suggest may be a better solution to MIDI control. MIDI requires a dedicated control (master) channel which by default is channel 16. In webconf INTERFACE->UI Keybindings you can assign any HID keyboard key to any CUIA. It can be learned by pressing the hardware key then assigning the command and parameters in webconf or manually added. The config is implemented immediately after saving and is persistent. Similarly there is a configuration screen for MIDI note-on/off to control the same set of commands.

One issue with USB control is the conflicting need to present USB ports externally, e.g. for USB MIDI controllers which means bringing the internal keypad’s USB out and back in.

I wonder why you are having problems with the encoder switches. They should just work. Maybe there is some debounce issue that a small capacitor / resistor filter might help.

Off-topic: I see that you have resused some tounge and groove flooring to support devices. Isn’t it useful to have such offcuts :smile: . I pull out pieces from my stash often for this kind of use. Never throw anything away!

Thanks for the info @riban!

This is what I’m trying to use to replicate (what I think) the official keyboard does, I’m struggling, however to set up:

  • a proper “alt” mode, I think I will just remap a key to behave as momentary pc keyboard alt and move on…
  • The “select” button.
  • Pressing and holding the arrow button works on my end! I’d really love a page down/up functionality though . Do you guys accept PRs? how complex the developer onboarding is? could this be a “good first issue?”. I could Create a CUIA and expose it to the interface. … wait… I think I can achieve this with the “SELECT” action as it accept %i as how many items to move!!! Will try it out later.

Well. I’m “happy” to report that I failed to find a proper 90 degrees hdmi adapter so I had to rotate the pi making the carefully measured 3d support mount thing for it unusable :sweat: . The good thing is that I do not have USBs going out and in, as Im using a usb touchscree, usb audio card and the usb keyboard. For external connectivity I just have a cable hanging now :sweat_smile:

Actually I hit this issue and never tried to fix it as I supposed it was a bug, I will give it another look, any info is appreciated!

Ahhh those bits of flooring are super useful, I have a leftover box that I use for everything!. they are supposed to be… hmm… temporary. I like the wood finish though! I actually tried to build the case with those, but I couldn’t make a proper straight line with my tools :laughing:

Thanks for your time!!

@baj ,

I’m working on a USB HID keyboard based upon 2 macro keypads ch75x github The keybindings seem to work fairly well, but it’s still a work in progress. The encoders and encoder buttons are all keypresses, and as @riban mentioned the long presses work as expected.

Here’s my design next to a v5 printout for comparison. I’m using mine as external components on a headless zynth, with a portable HDMI display to build out a full system using a Geekwork DACPi case

CH57x Keymaps:
upper_right_enc_zynth.yaml (1.8 KB)
lower_right_enc_zynth.yaml (1.9 KB)

Zynthian Keybinding:
macropad_zynth_keybinding.yaml (1.9 KB)

I set up one Zynth using the UI, then copy /zynthian/config/keybinding.yaml between systems.


I had a similar idea.