Scripting creation of MIDI tracks

Drawing on the work @Michael_Willis here, I’d like to be able to write a Lua script which, given an input of the root path of the Virtual Playing Orchestra sample library, plus a set of user-selected checkboxes (selecting instrument sections), configures a number of MIDI tracks, using sfizz, each with a given VPO section / articulation.

AFIAK, based on my reading of the (Lua scripting API)[The Ardour Manual - Lua Bindings Class Reference] docs, Ardour does not yet surface the API to Lua to support this use-case: I would need to be able to construct the instrument plugin, and provide it’s configuration details. Based on @Michael_Willis work, I might need to add other plugins to certain tracks, as well as configuring panning and trim.

Can anyone contradict me, or is there a chance that I might be able to help adding the required scripting support?

1 Like

As far as I can tell, all this is already possible. Where are you stuck?

I suggest to have a look at various example snipppets at ardour/share/scripts at master · Ardour/ardour · GitHub

This is a great idea. I haven’t maintained that template for a long time, and I would make some different decisions if I did it all over again. I never liked that it uses an absolute path in the filesystem, but I didn’t find a way to allow people to specify the path. I also like the idea of customizing sections.

AFAICT, the Lua API offers no way to set the value of any of the string parameters for the sfizz plugin. In particular, my notional script would need to set the sfzfile parameter is the filesystem path to the SFZ file defining the instrument.

I see. Since debian does not package sfizz, I cannot check myself. For LV2 this seems to be available as LV2 Plugin Property (patch:writable), but other variants (VST, AU, etc) do not expose this to the host.

Meanwhile, you could you make a plugin-preset with the path and then load the preset to sidestep this?

Based on the past discussion of this (https://discourse.ardour.org/t/update-to-vpo-template/89288/9), I’m wondering if the best first step would be to make a script which would create appropriate “placeholder” lv2 entries (based on @Michael_Willis setup), which then would be used by any templates or template-making operations.

Not necessarily an Ardour operation.

I’ll give that a try.

BTW, the Session.new_midi_track method is documented as returning a MIDITrackList, but I can’t seem to use it that way: E.g.:

local track_list = Session.new_midi_track(....)
print(track_list.size())

raises this execption:

LuaException: [string "ardour {..."]:43: bad argument #1 to 'size' (MidiTrackList expected, got table)

Both Session as well as the returned List are instances of a given class, so : (not .)

local track_list = Session:new_midi_track(....)
print(track_list:size())

Sigh. Twenty-five years of daily Python programming makes for hard-to-defeat muscle memory.

1 Like

you could you make a plugin-preset with the path

Is there a way to do that via LUA? The VPO library provides 454 different SFZ instrument definitions: I don’t intend to use all of them, but might use a bunch.

You would first have to create the preset manually, and then you can load it, either directly when creating the instrument track (Session:new_midi_track) or later using load_preset (see ardour/share/scripts/s_pluginutils.lua at 4d5175e32e5890d116a84cef7bf046203243a7f3 · Ardour/ardour · GitHub).

Now since Ardour 8.4-103-g0bb3c166e8 you can directly set sfizz path, an example can be found at ardour/share/scripts/_lv2_plugin_property.lua at master · Ardour/ardour · GitHub

1 Like

Awesome! It took you less time to add that than for me to write the Python script to generate the SFZ presets.

1 Like