summaryrefslogtreecommitdiff
path: root/scripts/_template_example.lua
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-08-09 15:04:42 +0200
committerRobin Gareus <robin@gareus.org>2017-08-10 02:26:16 +0200
commit8fbc2c64842d5dc637dbe16e2d312545d1cff18b (patch)
tree9690d8c22003506a357212d3c4f1788719fd36f2 /scripts/_template_example.lua
parente983e08f1d70bc872aa4c8cc11afb2c739e9981d (diff)
Add some more Lua script examples
Diffstat (limited to 'scripts/_template_example.lua')
-rw-r--r--scripts/_template_example.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/_template_example.lua b/scripts/_template_example.lua
new file mode 100644
index 0000000000..e219cb209e
--- /dev/null
+++ b/scripts/_template_example.lua
@@ -0,0 +1,40 @@
+--
+-- Session Template setup-hook
+--
+-- If a script named 'template.lua' exists in a session-template folder
+-- the `template_load` function of the script is called after
+-- creating the session from the template.
+--
+-- (e.g. ~/.config/ardour5/templates/Template-Name/template.lua
+--
+
+function template_load ()
+ local e = Session:engine()
+ -- from the engine's POV readable/capture ports are "outputs"
+ local _, t = e:get_backend_ports ("", ARDOUR.DataType("audio"), ARDOUR.PortFlags.IsOutput | ARDOUR.PortFlags.IsPhysical, C.StringVector())
+ -- table 't' holds argument references. t[4] is the C.StringVector (return value)
+ local tracks = t[4]:size();
+
+ local dialog_options = {
+ { type = "heading", title = "Customize Session: " .. Session:name () },
+ { type = "number", key = "tracks", title = "Create Tracks", min = 0, max = 128, step = 1, digits = 0, default = tracks },
+ { type = "checkbox", key = "recarm", default = false, title = "Record Arm Tracks" },
+ }
+
+ local dlg = LuaDialog.Dialog ("Template Setup", dialog_options)
+ local rv = dlg:run()
+ if (not rv or rv['tracks'] == 0) then
+ return
+ end
+
+ -- create tracks
+ local tl = Session:new_audio_track (1, 2, nil, rv['tracks'], "", ARDOUR.PresentationInfo.max_order, ARDOUR.TrackMode.Normal)
+ -- and optionally record-arm them
+ if rv['recarm'] then
+ for track in tl:iter() do
+ track:rec_enable_control ():set_value (1, PBD.GroupControlDisposition.NoGroup)
+ end
+ end
+
+ Session:save_state("");
+end