summaryrefslogtreecommitdiff
path: root/share/scripts/_export_plugins_on_save.lua
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-02-23 20:48:02 +0100
committerRobin Gareus <robin@gareus.org>2020-02-23 20:48:02 +0100
commit180843f9bd28b191c7404245ba0a121107992511 (patch)
treec60312dc09f76c2f55ba2383245c427e15c38dea /share/scripts/_export_plugins_on_save.lua
parentbf649cd68ad46c34a656700aa6cb89416d648c64 (diff)
Also move Lua scripts to share subfolder
Diffstat (limited to 'share/scripts/_export_plugins_on_save.lua')
-rw-r--r--share/scripts/_export_plugins_on_save.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/share/scripts/_export_plugins_on_save.lua b/share/scripts/_export_plugins_on_save.lua
new file mode 100644
index 0000000000..c732717bd8
--- /dev/null
+++ b/share/scripts/_export_plugins_on_save.lua
@@ -0,0 +1,44 @@
+ardour {
+ ["type"] = "EditorHook",
+ name = "Save Extra Data (instruments)",
+ author = "Ardour Lua Task Force",
+ description = "Export custom data when the session is saved",
+}
+
+-- subscribe to signals
+-- http://manual.ardour.org/lua-scripting/class_reference/#LuaSignal.LuaSignal
+function signals ()
+ s = LuaSignal.Set()
+ s:add ({[LuaSignal.StateSaved] = true})
+ return s
+end
+
+-- create callback functions
+function factory () return function (signal, ...)
+ assert (signal == LuaSignal.StateSaved)
+
+ local all_instruments = {}
+
+ -- iterate over all routes
+ for r in Session:get_routes():iter() do
+ local proc = r:the_instrument() -- get instrument processor (if any)
+ if proc:isnil() then goto nextroute end -- skip tracks/busses without instrument
+ local pi = proc:to_insert() -- check if it's a plugin-insert
+ if pi:isnil() then goto nextroute end
+
+ local pp = pi:plugin (0) -- get first instance
+ all_instruments[r:name()] = string.format ("%s (%s)", proc:name(), pp:unique_id())
+
+ ::nextroute::
+ end
+
+ if next (all_instruments) ~= nil then -- check if table is not empty
+ -- write to a file in the session-folder
+ file = io.open (ARDOUR.LuaAPI.build_filename (Session:path(), Session:name () .. ".instruments.txt"), "w")
+ for nme, nfo in pairs (all_instruments) do
+ file:write (nme .. ": " .. nfo)
+ end
+ file:close()
+ end
+
+end end