Intro to Ardour Lua Scripting for Noobs?

I’ve been using the manual pages, the class bindings page, and studying the built-in scripts to try and understand how to do Lua scripting in Ardour. But I still feel super out of my depth. My background: I don’t know C++ (is it futile to try scripting if I don’t?), did not initially build Ardour from the source code, and began learning Lua/Python/Bash a few months ago.

I was hoping that someone could help with the following:

  1. give me a broad overview of the class reference page, with its bewildering diversity of objects, and how to (roughly) use them in a lua script. (The page has a useful advice, but it seems to assume familiarity with C++!)
  2. walk me through an example script (see below, _export_tracks.lua)
  3. give me some broad advice on how to execute a script idea (see below, batch exports via solo track > master export)

Example script: _export_tracks.lua
Source code from the Ardour github page. It’s a pretty short script, which I want help understanding since I imagine the process for my export track script might be similar.

ardour { ["type"] = "Snippet", name = "Export Track XML" }

function factory () return function ()
	local rlp = ARDOUR.RouteListPtr ()
	local sel = Editor:get_selection ()
	for r in sel.tracks:routelist ():iter () do
		rlp:push_back (r)
	print (Session:export_track_state (rlp, "/tmp/rexport"))
end end 

My main confusions are:

  • What are RouteListPtr () and routelist ()?
  • Does get_selection () just return the selected range, or a choice of tracks, or editor objects (particular MIDI/audio files in the timeline?
  • What does the push_back function do?
  • My biggest confusion: why is the export carried about by a print operation?? Generally, how would I call an export via a Lua script? Is there anyway to also customize export options (times exported, audio format, export file name)?

Feedback on script idea: automating individual track stem exports
As mentioned, the first process I’ve been trying to automate is pretty simple (seemingly): export a bunch of individual track stems via solo > master export. (This is a workaround to stem tracks processed in common busses.) I imagine the process would be something like this:

  • get user selection of tracks, add them to a list (export_list)
  • for loop (for each track in export_list), do
    • solo track, mute all others
    • export master track (stereo) to export folder (or other destination)

Does that process make sense? What complications might there be with approaching it like this? And what are the relevant class objects I would need to call for executing this? (I imagine if my first two questions are answered, I’ll have a better sense as to how to do this.)

Thanks so much for the help, the Ardour community is the absolute best. :slight_smile: Have never felt so supported as a musician.

When I started with Ardour Lua I found the three best resources are the Ardour source code on github (use github’s search facility to look-up the Lua functions), the example scripts (also in the Ardour repo), and the Ardour IRC channel.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.