Carla preset changes via Midi CC or Program Change?

All your LV2 and LADSPA goodness and more.

Moderators: MattKingUSA, khz

Post Reply
timg
Established Member
Posts: 6
Joined: Wed Dec 30, 2020 7:06 pm

Carla preset changes via Midi CC or Program Change?

Post by timg »

Hi all,
Please bear with me, this is my first post on this forum (and probably under 5 posts on any forums!)

I'm trying to build a live setup and it has progressed reasonably well: Konfyt (for quick, easy and seamless patch changes) and Carla, for mounting various plugins, including ZynAddSubFX. I use Ardour when I want to record, but prefer to generally keep it out of a live setup to minimise complexity and too many points of failure. I run Manjaro Linux.
Overall, I'm super-pleased with this setup and would highly recommend Konfyt and Carla together.

My main problem at present it having an easy way to call up ZynAddSubFX presets from within Konfyt patches. Konfyt can send Midi program changes, CC and SYSEX messages automatically upon patch change. In Carla, I can use "Load State" manually and see my own LV2 plugin presents as well as all the standard presets that come with ZynAddSubFX. So, I can manually select the presets in Carla (easier when using the "Presets" skin), but I prefer not to require to either go into Carla to change presets, or to have to load 10 or so separate ZynAddSubFX instances within Carla and map/route the sounds needed for a set. I'm familiar with mapping Midi CC controls to parameters slots, but struggle for controlling other functionality of Carla plugins.
(I've tried Program Change, but this routed through to ZynAddSubFX itself and I could only get one bank of Synth sounds.)
Screenshot_20201230_1.png
Screenshot_20201230_1.png (244.15 KiB) Viewed 2651 times
What Midi messages can be sent to Carla to change the "Load State" LV2 presets?

I have tried and searched, but not found answers and Carla documentation seems light.

Kind thanks,
Tim
Tim

Manjaro KDE Linux + Jack2, Konfyt, Carla, ZynAddSubFX and numerous other LV2 plugins.
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla preset changes via Midi CC or Program Change?

Post by noedig »

In the Carla plugin properties window, there are program change options:
- Map Program Changes: does not send the bank/program messages to the plugin itself, but uses it to change the "MIDI Program" (the combo box at the top).
- Send Bank/Program Changes: sends the bank/program messages through to the plugin itself for it to handle it.

The standalone application version of ZynAddSubFx supports patch changes with bank/program messages.
Sadly it seems that the LV2 version of ZynAddSubFx doesn't respond to bank/program changes properly. When it receives it, it just switches to the default sine wave patch (for me at least).
Furthermore, the LV2 plugin has no items in the "MIDI Program" list.

The Carla "internal" version of the ZynAdSubFx plugin, on the other hand, has a whole list under "MIDI Program". Thus, when "Map Program Changes" is enabled, bank/program messages will switch presets according to that list. The internal plugin does not seem to support "Send Bank/Program Changes".

So to summarize, the only way I found is to use the internal plugin version with "Map Program Changes" enabled.
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla preset changes via Midi CC or Program Change?

Post by noedig »

I found another way using OSC.

See Carla's supported OSC commands by going to Help -> About, OSC tab.

For example, if you have the ZynAddSubFx LV2 plugin as your first plugin, the OSC command required to change the preset is:

Code: Select all

/Carla/0/set_program 400
where 0 corresponds to the first plugin, and 400 corresponds to the LV2 Preset number 400 (the items listed when clicking Load State in the plugin properties window).

Thus, to change the LV2 plugin preset in Carla when switching a patch in Konfyt, you need something that translates a MIDI message from Konfyt into an OSC message to Carla.

One solution that comes to mind is using Python: mididings (for receiving MIDI) and liblo or pythonosc for sending OSC messages.

Another solution that I got working fairly easily is using JACK MIDI TO OSC: https://github.com/x42/jackmidi2osc
After building it, run the binary and provide a custom config file, e.g.

Code: Select all

./jackmidi2osc -c myconfig.cfg
The following rules in the config file translates CC 0, 0 to plugin preset 462, and CC 0, 1 to plugin preset 500.

Code: Select all

[rule]
CC 0 0
"/Carla/0/set_program" "i" "462" # Generic lead

[rule]
CC 0 1
"/Carla/0/set_program" "i" "500" # Funny pulse patch
You have to connect a MIDI output port in Konfyt to the MIDI input of jackmidi2osc, and then set up a patch to send the appropriate MIDI CC message.

When you have it set up correctly, a Konfyt patch change will trigger MIDI CC 0, 0 --> jackmidi2osc, sending an OSC message --> Carla, changing the plugin preset.
timg
Established Member
Posts: 6
Joined: Wed Dec 30, 2020 7:06 pm

Re: Carla preset changes via Midi CC or Program Change?

Post by timg »

Hi noedig,

Thank you so much. I recognised your name immediately as the creator and maintainer of Konfyt.
I couldn't get the first solution to work for me; I don't know what was meant by "native". but the only other Carla version of ZynAddSubFX was the VST plugin and it gave me no more options.

So, sticking with the LV2 plugin and using jackmidi2osc, I was able to get the solution working. Thanks!
I did find that I needed to add the [config] sections to the config file.
This then worked a treat.

I expect that what I will do with this approach is jackmidi2osc as a more flexible means to layer 2 or 3 ZynAddSubFX Carla plugins within a single Konfyt patch and drive both/all OSC changes with one CC message:

Code: Select all

[config]
## The OSC host and (UDP) port to send data to.
## format: [ <hostname> :] <port>
#osc=some.host.com:1234
#osc.tcp://tim-Manjaro:22752/Carla
#osc=//tim-Manjaro:22752/Carla
## send to localhost, port 3819
osc=22752

#Need to count through the carla patch top to bottom but starting with 0 as the first
#So with Zyn Dynamic being the third plugin, use a value of "/Carla/2/set_program"
[rule]
CC 0 0
"/Carla/2/set_program" "i" "000"
"/Carla/3/set_program" "i" "462" #another patch

[rule]
CC 0 1
"/Carla/2/set_program" "i" "001" #Tim...
"/Carla/3/set_program" "i" "500" #another patch

I tested this and it works fine, enabling you to then use Konfyt faders/mutes, etc. to balance the different Zyn syths layers dynamically.
The only downside to changing Zyn sounds directly is that there is no seamless switching between the sounds, but at least this solution is available and works, e.g. between playing.

@noedig : I do have a couple of suggestions for Konfyt enhancements that I believe would be well received:
a) fader pickup: meaning that if the fader assigned to "Layer 1 Gain" is changed while on another patch, when you come back and move the fader, there is a sudden volume jump. If Konfyt were the check the value and only respond once values pass through the current "Layer 1 Gain" value, this would eliminate the sudden jump.
b) Buttons to move Midi and Audio port layers up or down within a patch (like it can be done for patches within the project). Currently, you have to re-build a patch if you don't get the Audio in ports in the right order for the Layers/fader controls you want.

Please let me know if you'd like me to post this somewhere else or have a DM, etc.
But, mostly, a big thanks for this solution.
Tim

Manjaro KDE Linux + Jack2, Konfyt, Carla, ZynAddSubFX and numerous other LV2 plugins.
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla preset changes via Midi CC or Program Change?

Post by noedig »

Thanks, those are good suggestions.

a) Fader pickup - very good idea. Will probably only be able to add this a bit later.

b) Move layers up/down - this is now implemented on the testing branch on Github, so you can try it out if you want or wait for the official release (hopefully) later this month.
timg
Established Member
Posts: 6
Joined: Wed Dec 30, 2020 7:06 pm

Re: Carla preset changes via Midi CC or Program Change?

Post by timg »

Hi again all,

So, my setup is working very well (yet to use it for live use but this is planned for mid-July).
But, I do face an intriguing problem within Zynfusion LV2 preset changes - macro slot corruption/conflict

Setup summary...
Key applications:
Konfyt 1.1.4 - manages multi-layers patches, awesome midi and audio routing, filtering and auto-sending of CC events, etc.
Carla 2.3.0 - plugin host and receives OSC messages from Konfyt to "/set_program" of 3x Zyn plugin instances
Zynfusion - 3 instances of the LV2 plugin in Carla, enabling usually a lead, bass and pad for each Konfyt patch. Changing Konfyt patch changes all 3x Zyn presets simultaneously. This approach means that I can have infinite patches driving infinite Zyn preset combinations, since the song repertoire is ~200 songs and potentially ~50 patches, but I could have a separate one (even multiples) for each song if I wanted.
jackmidi2osc - drives Zyn preset changes by receiving MIDI CC from stored Konfyt patches and driving OSC messages to Carla to change Zyn presets.
OS: Manjaro KDE

Separate process: Ardour - due to problems saving presets under Carla ("Save state" greyed out), the Zyn LV2 plugin is used in Ardour to create and save presents into my .lv2 directory, e.g. /home/tim/.lv2/ZynAddSubFX_004_Guitar.lv2 . Carla then pulls from this .lv2 directory.

It all works well now, but Zyn slots are getting confused with the preset changes in Carla...

I understand that Carla saves the states of the plugins within the Carla .carxp project file.
I can go into each Zyn and clear down all the slots this this, prior to saving the Carla project.
Screenshot_20210618_161059.png
Screenshot_20210618_161059.png (72.1 KiB) Viewed 2600 times
If I trigger my first Konfyt patch, which in turn uses OSC to load a PIANO preset into Zyn1, the 3 macro automations in Slot1 are loaded into the LV2 plugin as you'd expect (same for automations in other slots).
Screenshot_20210618_170750.png
Screenshot_20210618_170750.png (115.89 KiB) Viewed 2600 times
However, if I then switch to another patch, it again uses OSC to load a GUITAR preset, but the 2 macro automation in Slot1 (yellow) of that preset do not replace the Slot1 automations in the LV2 plugin, but rather try to append after the automation of the previously selected PIANO preset (red).
Screenshot_20210618_170956.png
Screenshot_20210618_170956.png (110.98 KiB) Viewed 2600 times
The result is that now irrelevant or unhelpful macro automations still occupy 3/4 positions of Slot1, and only the first macro automation of the new GUITAR preset is added into position 4/4 of Slot 1.

Put another way, most of the sound aspects of the preset change works fine, but the macro slots are not cleared as I believe they should and one would expect.

This is easily reproduced:
1. Add Zynfusion LV2 into Carla
2. "Load State" a preset that has Macro Slot1 populated (I use the "presets" skin, since it is easy to see and change the state)
(easiest to see the issue if this preset one only has 1 or 2 of the 4 bindings connected, i.e. at least 1 "UNCONNECTED")
3. View the MACRO LEARN Slot 1 in Zyn and take note of how it is loaded in the 2x2 grid.
4. Use "Load State" to select a different a preset that also has Macro Slot1 populated
(it helps to know in advance what attributes are present in the macro bindings on slot 1, e.g. PART0 effect volume, cutoff, LFO rate, etc.)
5. View the MACRO LEARN Slot 1 in Zyn again, and now I believe you'll see the issue...
- The macro bindings of the 2nd preset are simple appended to the marco binding of the 1st preset loaded.
- I can't believe this is by design or at all desirable, since the result of the sound and the effect of the CC encoders is dependent upon the order in which presets are used.

Can someone please confirm this bug?
Is there a way to force a Carla LV2 plugin to be returned to default initialised state via OSC? If so, I could probably insert this step for each patch change to first clear (via OSC) the previous preset entirely, pause, e.g. with MidiDelayline for 0.5s, and then OSC-load the new preset.
Any other or cleaner ideas, remembering that this setup is live and clean preset change/clearing needs to be driven by CC/OSC?

Many thanks,
Tim

Once I have this setup working reliably and without this issue, I intend to make a YouTube video (aiming at ~15-20mins) to show how it is pieced together with a good voice-over.
Tim

Manjaro KDE Linux + Jack2, Konfyt, Carla, ZynAddSubFX and numerous other LV2 plugins.
User avatar
noedig
Established Member
Posts: 233
Joined: Wed Feb 12, 2014 4:39 am
Location: South Africa
Has thanked: 9 times
Been thanked: 52 times

Re: Carla preset changes via Midi CC or Program Change?

Post by noedig »

I can confirm that this bug happens on my system as well. Unfortunately I do not have a workaround.

Like you said, the preset slots simply aren't cleared on preset changes.
timg
Established Member
Posts: 6
Joined: Wed Dec 30, 2020 7:06 pm

Re: Carla preset changes via Midi CC or Program Change?

Post by timg »

I raised this bug earlier today and it has just been fixed. Wow! That was quick!
https://github.com/zynaddsubfx/zyn-fusi ... issues/286

Now to build and test :D
Tim

Manjaro KDE Linux + Jack2, Konfyt, Carla, ZynAddSubFX and numerous other LV2 plugins.
Post Reply