summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-08-20 00:18:58 +0200
committerRobin Gareus <robin@gareus.org>2017-08-20 00:18:58 +0200
commit1a70a2f9773512b9828e4d11f0c3c72ec3d0c4d0 (patch)
treee51ecd40f33ce8cd0a7a1974a0f417a8c3c454cf /scripts
parent9f1350a833b0e6b11c451870f135c9fa0153464d (diff)
Cont'd work on route-templates
Diffstat (limited to 'scripts')
-rw-r--r--scripts/_route_template_generic_audio.lua (renamed from scripts/_route_template_example.lua)0
-rw-r--r--scripts/_route_template_generic_midi.lua78
-rw-r--r--scripts/route_template_interactive_audio.lua (renamed from scripts/_route_template_interactive_audio.lua)2
3 files changed, 79 insertions, 1 deletions
diff --git a/scripts/_route_template_example.lua b/scripts/_route_template_generic_audio.lua
index a3642bf54d..a3642bf54d 100644
--- a/scripts/_route_template_example.lua
+++ b/scripts/_route_template_generic_audio.lua
diff --git a/scripts/_route_template_generic_midi.lua b/scripts/_route_template_generic_midi.lua
new file mode 100644
index 0000000000..a62197d137
--- /dev/null
+++ b/scripts/_route_template_generic_midi.lua
@@ -0,0 +1,78 @@
+ardour {
+ ["type"] = "EditorAction",
+ name = "Generic MIDI Track",
+ description = [[Example]]
+}
+
+-- If a route_setup function is present in an Editor Action Script
+-- the script is also listed in the "add track/bus" dialog as meta-template
+--
+-- The function is expected to return a Lua table. The table may be empty.
+function route_setup ()
+ return
+ {
+ -- keys control which AddRouteDialog controls are made sensitive.
+ -- The following keys accept a default value to pre-seed the dialog.
+ ['how_many'] = 1,
+ ['name'] = 'MIDI',
+ ['channels'] = nil,
+ ['track_mode'] = nil,
+ ['strict_io'] = true,
+ -- these keys just need to be set (to something other than nil)
+ -- in order to set the control sensitives
+ ['insert_at'] = ARDOUR.PresentationInfo.max_order,
+ ['group'] = false, -- return value will be a RouteGroup*
+ ['instrument'] = true, -- return value will be a PluginInfoPtr
+ }
+end
+
+-- The Script can be used as EditorAction in which case it can
+-- optionally provide instantiation parmaters
+function action_params ()
+ return
+ {
+ ['how_many'] = { title = "How Many tracks to add", default = "1" },
+ ["name"] = { title = "Track Name Prefix", default = "MIDI" },
+ ["instrument"] = { title = "Add Instrument", default = "true" },
+ }
+end
+
+
+function factory (params) return function ()
+ -- When called from the AddRouteDialog, 'params' will be a table with
+ -- keys as described in route_setup() above.
+
+ local p = params or route_setup ()
+ local name = p["name"] or 'Audio'
+ local how_many = p["how_many"] or 1
+ local insert_at = p["insert_at"] or ARDOUR.PresentationInfo.max_order;
+ local group = p["group"] or nil
+ local strict_io = p["strict_io"] or false
+ local instrument = p["instrument"] or nil
+
+ -- used in 'action-script mode'
+ if instrument == "true" then
+ instrument = ARDOUR.LuaAPI.new_plugin_info ("http://gareus.org/oss/lv2/gmsynth", ARDOUR.PluginType.LV2) -- general midi synth
+ if instrument:isnil () then
+ instrument = ARDOUR.LuaAPI.new_plugin_info ("https://community.ardour.org/node/7596", ARDOUR.PluginType.LV2) -- reasonable synth
+ end
+ if instrument:isnil () then
+ LuaDialog.Message ("MIDI track add", "Cannot find instrument plugin",
+ LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run ()
+ return
+ end
+ end
+
+ -- add no instrument
+ if type (instrument) ~= "userdata" then
+ instrument = ARDOUR.PluginInfo ()
+ end
+
+ Session:new_midi_track(
+ ARDOUR.ChanCount(ARDOUR.DataType ("midi"), 1),
+ ARDOUR.ChanCount(ARDOUR.DataType ("audio"), 2),
+ strict_io,
+ instrument, nil,
+ group, how_many, name, insert_at, ARDOUR.TrackMode.Normal)
+
+end end
diff --git a/scripts/_route_template_interactive_audio.lua b/scripts/route_template_interactive_audio.lua
index e53eab4587..99cdf7f3cb 100644
--- a/scripts/_route_template_interactive_audio.lua
+++ b/scripts/route_template_interactive_audio.lua
@@ -1,6 +1,6 @@
ardour {
["type"] = "EditorAction",
- name = "Create Audio Tracks interactively",
+ name = "Create Audio Tracks Interactively",
description = [[
This template creates audio tracks.