diff --git a/share/scripts/_add_gx_tuner.lua b/share/scripts/_add_gx_tuner.lua new file mode 100644 index 0000000000..0d8a00e597 --- /dev/null +++ b/share/scripts/_add_gx_tuner.lua @@ -0,0 +1,21 @@ +ardour { + ["type"] = "EditorAction", + name = "Add Guitarix Instrument Tuner", + license = "GPL", + author = "Vincent Tassy", + description = [[Adds a tuner on the current track]] +} + +function factory () return function () + local sel = Editor:get_selection () + if not Editor:get_selection ():empty () and not Editor:get_selection ().tracks:routelist ():empty () then + -- for each selected track + for r in sel.tracks:routelist ():iter () do + if not r:to_track ():isnil () and not r:to_track ():to_audio_track ():isnil () then + local proc = ARDOUR.LuaAPI.new_plugin(Session, "http://guitarix.sourceforge.net/plugins/gxtuner#tuner", ARDOUR.PluginType.LV2, ""); + assert (not proc:isnil()) + r:add_processor_by_index(proc, 0, nil, true) + end + end + end +end end diff --git a/share/scripts/_add_x42_compressor.lua b/share/scripts/_add_x42_compressor.lua new file mode 100644 index 0000000000..049602377b --- /dev/null +++ b/share/scripts/_add_x42_compressor.lua @@ -0,0 +1,34 @@ +ardour { + ["type"] = "EditorAction", + name = "Add x42 Dynamic Compressor", + license = "MIT", + author = "Vincent Tassy", + description = [[Adds a x42 Dynamic Compressor on the current track]] +} + +function factory () return function () + local sel = Editor:get_selection () + local proc = nil + -- for each selected track/bus + for r in sel.tracks:routelist ():iter () do + local i = 0; + local pos = 0; + repeat + proc = r:nth_processor (i) -- get Nth Ardour::Processor + local plugin = proc:to_plugininsert () + if not plugin:isnil() then + pos = pos + 1 + end + i = i + 1 + until (proc:display_name() == "Fader") + -- select mono or stereo version of the plugin + if proc:input_streams():n_audio () == 2 then + proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/darc#stereo", ARDOUR.PluginType.LV2, ""); + else + proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/darc#mono", ARDOUR.PluginType.LV2, ""); + end + assert (not proc:isnil()) + r:add_processor_by_index(proc, pos, nil, true) + proc = nil; + end +end end diff --git a/share/scripts/_configure_master_bus.lua b/share/scripts/_configure_master_bus.lua new file mode 100644 index 0000000000..b095b7a9a9 --- /dev/null +++ b/share/scripts/_configure_master_bus.lua @@ -0,0 +1,43 @@ +ardour { + ["type"] = "EditorAction", + name = "Configure Master Bus", + license = "GPL", + author = "Vincent Tassy", + description = [[Adds meters post-fader and limiter pre-fader on Master Bus]] +} + +function factory () return function () + + local mb = Session:master_out () + local i = 0; + local pos = 0; + repeat + local proc = r:nth_processor (i) -- get Nth Ardour::Processor + local plugin = proc:to_plugininsert () + if not plugin:isnil() then + pos = pos + 1 + end + i = i + 1 + until (proc:display_name() == "Fader") + -- Add Limiter + local proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/dpl#stereo", ARDOUR.PluginType.LV2, ""); + assert (not proc:isnil()) + mb:add_processor_by_index(proc, pos, nil, true) + -- Add Stereo Phase-Correlation Meter + proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/meters#COR", ARDOUR.PluginType.LV2, ""); + assert (not proc:isnil()) + mb:add_processor_by_index(proc, -1, nil, true) + -- Add 1/3 Octave Spectrum Display Stereo + proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/meters#spectr30stereo", ARDOUR.PluginType.LV2, ""); + assert (not proc:isnil()) + mb:add_processor_by_index(proc, -1, nil, true) + -- Add EBU R128 Meter + proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/meters#EBUr128", ARDOUR.PluginType.LV2, ""); + assert (not proc:isnil()) + mb:add_processor_by_index(proc, -1, nil, true) + -- Add VU Meter + proc = ARDOUR.LuaAPI.new_plugin(Session, "http://gareus.org/oss/lv2/meters#VUstereo", ARDOUR.PluginType.LV2, ""); + assert (not proc:isnil()) + mb:add_processor_by_index(proc, -1, nil, true) + proc = nil; +end end diff --git a/share/scripts/_connect_Hydrogen_MIDI.lua b/share/scripts/_connect_Hydrogen_MIDI.lua new file mode 100644 index 0000000000..0dfc4bc11f --- /dev/null +++ b/share/scripts/_connect_Hydrogen_MIDI.lua @@ -0,0 +1,20 @@ +ardour { + ["type"] = "EditorAction", + name = "Connect MIDI Track to Hydrogen", + license = "MIT", + author = "Vincent Tassy", + description = [[Connects the current track to Hydrogen]] +} + +function factory () return function () + local sel = Editor:get_selection () + -- for each selected track/bus + for r in sel.tracks:routelist ():iter () do + if not r:to_track ():isnil () and not r:to_track ():to_midi_track ():isnil () then + local inputmidiport = r:input():midi(0) + print(inputmidiport:name()) + inputmidiport:disconnect_all() + inputmidiport:connect("Hydrogen-midi:TX") + end + end +end end diff --git a/share/scripts/_connect_MIDI_keyboard_control.lua b/share/scripts/_connect_MIDI_keyboard_control.lua new file mode 100644 index 0000000000..4dc9404da1 --- /dev/null +++ b/share/scripts/_connect_MIDI_keyboard_control.lua @@ -0,0 +1,26 @@ +ardour { + ["type"] = "EditorAction", + name = "Connect Keyboard Transport to Ardour", + license = "MIT", + author = "Vincent Tassy", + description = [[Connects Alesis Q49 MKII MIDI Transport to Ardour]] +} + +function factory () return function () + _, t = Session:engine ():get_backend_ports ("", ARDOUR.DataType.midi (),ARDOUR.PortFlags.IsOutput | ARDOUR.PortFlags.IsPhysical, C.StringVector ()) + local found = 0 + local i = 1 + repeat + local p = t[4]:table()[i] + if (p) then + print(p, " -> ", Session:engine (): get_pretty_name_by_name(p)) + if Session:engine (): get_pretty_name_by_name(p) == "Q49 MKII" then + found = found + 1 + if found == 2 then + Session:engine (): connect (p, "ardour:MIDI Control In") + end + end + i = i + 1 + end + until (found == 2 or p == nil) +end end \ No newline at end of file diff --git a/share/scripts/_create_from_template.lua b/share/scripts/_create_from_template.lua new file mode 100644 index 0000000000..bf8eb96e0f --- /dev/null +++ b/share/scripts/_create_from_template.lua @@ -0,0 +1,11 @@ +ardour { + ["type"] = "EditorAction", + name = "Create Track/Bus From Template", + license = "MIT", + author = "Vincent Tassy", + description = [[Creates a Track/Bus based on template]] +} + +function factory () return function () + Session:new_route_from_template (1, ARDOUR.PresentationInfo.max_order, "/home/user/.config/ardour6/route_templates/Drums:Kick.template", "Kick", ARDOUR.PlaylistDisposition.NewPlaylist); +end end diff --git a/share/scripts/_reset_DragonFly_reverbs.lua b/share/scripts/_reset_DragonFly_reverbs.lua new file mode 100644 index 0000000000..60377caad5 --- /dev/null +++ b/share/scripts/_reset_DragonFly_reverbs.lua @@ -0,0 +1,39 @@ +ardour { + ["type"] = "EditorAction", + name = "Reset DragonFly Reverbs", + license = "MIT", + author = "Vincent Tassy", + description = [[Switches OFF then ON the DragonFly plugins to stop them creating xruns]] +} + +function factory () return function () + + for r in Session:get_routes ():iter () do -- iterate over all tracks in the session + local i = 0; + repeat -- iterate over all plugins/processors + local proc = r:nth_processor (i) + if not proc:isnil () then + if (string.match (proc:name(), "Dragonfly")) then + print(r:name(), " -> Deactivating ", proc:name()) + proc:deactivate() + end + end + i = i + 1 + until proc:isnil () + end +ARDOUR.LuaAPI.usleep(1000000) + for r in Session:get_routes ():iter () do -- iterate over all tracks in the session + local i = 0; + repeat -- iterate over all plugins/processors + local proc = r:nth_processor (i) + if not proc:isnil () then + if (string.match (proc:name(), "Dragonfly")) then + print(r:name(), " -> Activating ", proc:name()) + proc:activate() + ARDOUR.LuaAPI.usleep(500000) + end + end + i = i + 1 + until proc:isnil () + end +end end \ No newline at end of file diff --git a/share/scripts/add_MIDI_monitor.lua b/share/scripts/add_MIDI_monitor.lua new file mode 100644 index 0000000000..c984e5f29a --- /dev/null +++ b/share/scripts/add_MIDI_monitor.lua @@ -0,0 +1,20 @@ +ardour { + ["type"] = "EditorAction", + name = "Add ACE MIDI Monitor", + license = "MIT", + author = "Vincent Tassy", + description = [[Adds an ACE MIDI Monitor on the current track]] +} + +function factory () return function () + local sel = Editor:get_selection () + -- for each selected track/bus + for r in sel.tracks:routelist ():iter () do + if not r:to_track ():isnil () and not r:to_track ():to_midi_track ():isnil () then + local proc = ARDOUR.LuaAPI.new_plugin(Session, "ACE MIDI Monitor", ARDOUR.PluginType.Lua, ""); + assert (not proc:isnil()) + r:add_processor_by_index(proc, 0, nil, true) + proc = nil; + end + end +end end diff --git a/share/scripts/add_audio_track.lua b/share/scripts/add_audio_track.lua new file mode 100644 index 0000000000..e9af6b2bb5 --- /dev/null +++ b/share/scripts/add_audio_track.lua @@ -0,0 +1,66 @@ +ardour { + ["type"] = "EditorAction", + name = "Add Audio Track", + license = "MIT", + author = "Vincent Tassy", + description = [[Adds an Audio Track after selection and make it selected]] +} + +function factory () return function () + local sel = Editor:get_selection () + if not Editor:get_selection ():empty () and not Editor:get_selection ().tracks:routelist ():empty () then + tr = Session:new_audio_track (1, 2, nil, 1, "Audio", Editor:get_selection ().tracks:routelist ():front():presentation_info_ptr ():order () + 1, ARDOUR.TrackMode.Normal, true) + else + tr = Session:new_audio_track (1, 2, nil, 1, "Audio", -1, ARDOUR.TrackMode.Normal, true) + end + tr:front ():peak_meter ():set_meter_type (ARDOUR.MeterType.MeterKrms) + + Editor:access_action("Mixer", "select-none") + repeat + Editor:access_action("Editor", "select-next-route") + until tr:front():is_selected() + + routeScrollIntoView(tr:front()) +end end + +-- Scrolls the mixer's route pane such that this route is visible. Typically this will make it the left-most visible +-- route but only if the available scrolling range allows it. +-- r: the route in question. +-- unhide: if the route is hidden then this function does nothing unless this parameter is true (or nil) in which case it unhides the route. +function routeScrollIntoView(r, unhide) + + if r:is_hidden() then + if unhide ~= nil and unhide ~= true then return end + Editor:show_track_in_display(routeToTav(r), true) + end + + for i = 1, Session:get_stripables():size() do + Editor:access_action("Mixer", "scroll-left") + end + + local pos = routePosition(r) + local numVisibleBeforeThis = 0 + + for r2 in Session:get_routes():iter() do + if routePosition(r2) < pos and not r2:is_hidden() then + numVisibleBeforeThis = numVisibleBeforeThis + 1 + end + end + + for i = 1, numVisibleBeforeThis do + Editor:access_action("Mixer", "scroll-right") + end + +end + +-- Returns the TimeAxisView for this route. +-- r: the route in question. +function routeToTav(r) + return Editor:rtav_from_route(r):to_timeaxisview() +end + +-- Returns strip position (presentation order), first strip = 0. +-- r: the route in question. +function routePosition(r) + return r:presentation_info_ptr():order() +end \ No newline at end of file