summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-04-25 16:46:21 +0200
committerRobin Gareus <robin@gareus.org>2017-04-25 16:46:21 +0200
commitb8a7b444e2bef48a57cd6ffa70aa6c76ef340574 (patch)
tree2882b3bec8a5882c0b99a44577da0467afe2084c /scripts
parent35aa4f692a60394fe2756be44661a411e80c7f69 (diff)
Update LuaDialog scripts
Diffstat (limited to 'scripts')
-rw-r--r--scripts/_dialog_test.lua2
-rw-r--r--scripts/midi_cc_to_automation.lua (renamed from scripts/_midi_cc_to_automation.lua)34
2 files changed, 28 insertions, 8 deletions
diff --git a/scripts/_dialog_test.lua b/scripts/_dialog_test.lua
index 15bb67b4f7..87156826a7 100644
--- a/scripts/_dialog_test.lua
+++ b/scripts/_dialog_test.lua
@@ -74,6 +74,8 @@ function factory () return function ()
default = 500
},
+ { type = "heading", title = "Heading" },
+
{ type = "number", key = "number", title = "Whatever", min = 0, max = 10, step = 1, digits = 2 }
}
diff --git a/scripts/_midi_cc_to_automation.lua b/scripts/midi_cc_to_automation.lua
index 28967dc37d..26fdd48a1b 100644
--- a/scripts/_midi_cc_to_automation.lua
+++ b/scripts/midi_cc_to_automation.lua
@@ -1,22 +1,26 @@
-ardour { ["type"] = "Snippet", name = "MIDI CC to Plugin Automation" }
+ardour { ["type"] = "EditorAction", name = "MIDI CC to Plugin Automation",
+ license = "MIT",
+ author = "Ardour Team",
+ description = [[Parse a given MIDI control changes (CC) from all selected MIDI regions and convert them into plugin parameter automation]]
+}
function factory () return function ()
-- find target parameters
local targets = {}
local have_entries = false
for r in Session:get_routes():iter() do -- for every track/bus
- local i = 0;
+ local i = 0
while 1 do -- iterate over all plugins on the route
local proc = r:nth_plugin (i)
if proc:isnil () then break end
- if not targets [r:name ()] then targets [r:name ()] = {} end
- targets [r:name ()][proc:display_name ()] = {};
local plug = proc:to_insert ():plugin (0)
local n = 0
for j = 0, plug:parameter_count () - 1 do -- iterate over all plugin parameters
if plug:parameter_is_control(j) then
if plug:parameter_is_input(j) then
local nn = n
+ if not targets [r:name ()] then targets [r:name ()] = {} end
+ if not targets [r:name ()][proc:display_name ()] then targets [r:name ()][proc:display_name ()] = {} end
targets [r:name ()][proc:display_name ()][plug:parameter_label(j)] = function () return {["p"] = proc, ["n"] = nn} end
have_entries = true
end
@@ -29,23 +33,25 @@ function factory () return function ()
-- bail out if there are no parameters
if not have_entries then
- LuaDialog.Message ("CC to Plugin", "No Plugins found", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
+ LuaDialog.Message ("CC to Plugin Automation", "No Plugins found", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
collectgarbage ()
return
end
-- create a dialog, ask user which MIDI-CC to map and to what parameter
local dialog_options = {
- { type = "dropdown", key = "param", title = "Target Parameter", values = targets },
+ { type = "heading", title = "MIDI CC Source", align = "left" },
{ type = "number", key = "channel", title = "Channel", min = 1, max = 16, step = 1, digits = 0 },
- { type = "number", key = "ccparam", title = "CC Parameter", min = 0, max = 127, step = 1, digits = 0 }
+ { type = "number", key = "ccparam", title = "CC Parameter", min = 0, max = 127, step = 1, digits = 0 },
+ { type = "heading", title = "Target Track and Plugin", align = "left"},
+ { type = "dropdown", key = "param", title = "Target Parameter", values = targets }
}
local od = LuaDialog.Dialog ("Select Taget", dialog_options)
local rv = od:run()
if not rv then
od = nil collectgarbage ()
- return;
+ return
end
-- parse user response
@@ -91,5 +97,17 @@ function factory () return function ()
Session:commit_reversible_command (nil)
else
Session:abort_reversible_command ()
+ LuaDialog.Message ("CC to Plugin Automation", "No data was converted. Was a MIDI-region selected?", LuaDialog.MessageType.Info, LuaDialog.ButtonType.Close):run()
+ collectgarbage ()
end
end end
+
+
+function icon (params) return function (ctx, width, height, fg)
+ local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil(width * .45) .. "px")
+ txt:set_text ("CC\nPA")
+ local tw, th = txt:get_pixel_size ()
+ ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg))
+ ctx:move_to (.5 * (width - tw), .5 * (height - th))
+ txt:show_in_cairo_context (ctx)
+end end