controlling integer enumeration of lv2 plugin with control surface


I am new to Ardour (and audio in general) and want to create a binding for amsynth to a template of a Novation Zero SLMkII midi controller.

I would like to control the oscillater waveforms from the surface too. lv2info shows that the oscillator waveforms are chose by enumeration (integers 0-4), and I noticed that, when mapping a “ctl” to the respective plugin parameter, then I can choose only between options 0,2,4, while 1 and 3 are missing.

I looked into the source code and guess this is because in (MIDIControllable::midi_to_control), the minimum and maximum (0 and 4) are output as 0.0 and 4.0, and due to the “fiddeling” (see comment in file), 2.0 is also hit.

The question is:
What’s a better way to do the mapping from the surface to an enumerate?

If this needs programming, can you give me an outline of how to do it? I’m not experienced, but still would like to try.

Thanks, Stefan

Today I saw that it might be easy to do, just by adding a new flag “Enumeration” in controllable.h. The flag is set in, just like “Toggle”. Then I can make the case distinction in MIDIControllable::midi_sense_controller and write a “midi_to_control_unscaled”. This sets an integer value between 0 and 127, and in case the user tries to set an out of bound value, I just map it to the maximum (or minimum).

I’m not sure if it works yet, I’ll report back. If it does work, it’s probably only useful for surfaces on which you can program a button to send out a specific CC value (i.e. the number between 0 and 127), like the one I have. Doesn’t work for rotary buttons I guess.

Thanks, Stefan

Setting the flag did not work. I thought that somehow a midicontrollable has access to what is set in insert_plugin, but I guess not.

I got it to work now by adding a new argument (bool) “isenum” to MIDIControllable. This is read from the XML file, just like “momentary”. Let me know if there is a better way.
Thanks, S