2 ["type"] = "EditorHook",
3 name = "Save Extra Data (instruments)",
4 author = "Ardour Lua Task Force",
5 description = "Export custom data when the session is saved",
8 -- subscribe to signals
9 -- http://manual.ardour.org/lua-scripting/class_reference/#LuaSignal.LuaSignal
12 s:add ({[LuaSignal.StateSaved] = true})
16 -- create callback functions
17 function factory () return function (signal, ...)
18 assert (signal == LuaSignal.StateSaved)
20 local all_instruments = {}
22 -- iterate over all routes
23 for r in Session:get_routes():iter() do
24 local proc = r:the_instrument() -- get instrument processor (if any)
25 if proc:isnil() then goto nextroute end -- skip tracks/busses without instrument
26 local pi = proc:to_insert() -- check if it's a plugin-insert
27 if pi:isnil() then goto nextroute end
29 local pp = pi:plugin (0) -- get first instance
30 all_instruments[r:name()] = string.format ("%s (%s)", proc:name(), pp:unique_id())
35 if next (all_instruments) ~= nil then -- check if table is not empty
36 -- write to a file in the session-folder
37 file = io.open (ARDOUR.LuaAPI.build_filename (Session:path(), Session:name () .. ".instruments.txt"), "w")
38 for nme, nfo in pairs (all_instruments) do
39 file:write (nme .. ": " .. nfo)