I’ve written a Lua plugin script that changes my session settings (active tracks, active plugins, plugin presets) based on MIDI Program Change messages.
I think it’s similar to what was discussed here: Change plugin presets with Lua DSP script
A suggestion in that discussion thread was to put Program Changes in a MIDI track, but I want to handle Program Changes from my controller, so I push a button on the keyboard and trigger actions in Ardour.
I haven’t found anything else that quite does this. Have I missed something?
My plugin works fine, but I’ve got some questions.
-
If I update the code in the script file, how can I easily load the new code into the plugin? Right now, I’m deleting the plugin and re-adding it to the track.
-
Same question for Editor Actions. It seems like if I change an Editor Action script, even restarting Ardour doesn’t pick up the change. I have to remove the action and re-add it. Are the scripts cached somewhere?
-
How can I add an “Edit…” GUI to a Lua plugin script?
I know that the quick answer to #3 is, “you can’t”, at least not without modifying the C++ code. That’s what I’m asking - where should a call to a Lua plugin GUI function (using an Lua plugin API call that doesn’t exist yet) be added to the C++ code? It seems like some of the non-Lua plugins map a GUI window when has_editor is called (vst3 calls try_create_view from has_editor), but that doesn’t seem like the right place to do it. has_editor should just return true, I think, but when should an actual dialog box be displayed?
My code currently looks like this:
if d[2] == 0 or d[2] == 29 then
Session:route_by_name("OT P1ANO II"):set_active(true, nil);
deactivate_processor_by_name(Session:route_by_name("OT P1ANO II"), "MIDI Velocity-Range Filter")
Session:route_by_name("Dexed"):set_active(false, nil);
Session:route_by_name("Yoshimi"):set_active(false, nil);
Session:route_by_name("Yoshimi 1"):set_active(false, nil);
elseif d[2] == 1 then
Session:route_by_name("OT P1ANO II"):set_active(true, nil);
activate_processor_by_name(Session:route_by_name("OT P1ANO II"), "MIDI Velocity-Range Filter")
Session:route_by_name("Dexed"):set_active(false, nil);
Session:route_by_name("Yoshimi"):set_active(false, nil);
Session:route_by_name("Yoshimi 1"):set_active(false, nil);
elseif d[2] == 2 then
Session:route_by_name("OT P1ANO II"):set_active(false, nil);
Session:route_by_name("Dexed"):set_active(true, nil);
load_preset(Session:route_by_name("Dexed"), "Dexed", "BWB GLOCK");
Session:route_by_name("Yoshimi"):set_active(false, nil);
Session:route_by_name("Yoshimi 1"):set_active(false, nil);
etc, etc.
I want to put those if-blocks into text boxes in a dialog box so that they can be changed from the GUI.
Lua really does seem like the best way to go. We certainly can’t set routes and processors active or inactive from any other kind of plugin (VST3, LV2, etc).
Any feedback is welcome.