Hi folks,
Just sharing a quick trick I did in my system to address something that I found a little bit irritating.
when recording keyboard/e-drum parts I use a MIDI master keyboard and it’s equipped (like most these days) with transport control buttons. I find these extremely handy as it let’s me focus on my takes without fiddling with the computer’s keyboard or mouse.
Problem: while Ardour will remember my declaration of the keyboard as control surface IF it’s turned-on before lanching Ardour, I often find myself turning it on on-demand and need to go back to the preference dialog (or MIDI Route) to reconnect it. (As I have another control surface, the order in which they’re turned on has a tendency of messing up the config too).
Not a big deal you might think, and you’re right
But Ardour is giving me a way to work around that, so why not
I started by declaring a LUA EditorAction that inspects the available physical MIDI ports, locates the one associated with my keyboard’s Transport Control and connects it to the Ardour MIDI Control In port.
ardour {
["type"] = "EditorAction",
name = "Connect Keyboard Transport to Ardour",
license = "GPL",
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
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
My Alesis Q49 MKII exposes 2 MIDI ports - the first one is the “Music” one and the second one is the Transport Control but unfortunately they have the same name that’s why you’ll see in the script some specific to pick the second port named “Q49 MKII”
So that’s already a shortcut and you can bind this script to an EditorAction and have a keyboard shortcut or a button in the UI to execute it. It’s EditorAction 1 on my setup.
But what if it could be executed automatically when the keyboard is turned on ?
I got that working by adding a udev rule to my system:
SUBSYSTEM=="usb", ATTRS{idVendor}=="13b2", ATTRS{idProduct}=="00b2", RUN+="/usr/bin/sudo -u myuser /home/myuser/Apps/connectKBDtoArdour.sh"
Note: udev scripts don’t have access to the network and (spoiler alert) I’m going to use OSC to launch the action, that’s why the sudo is needed.
And here’s the script that just waits a few seconds for alsa to have finished configuring the device, makes sure ardour is actually running and sends the OSC command:
#!/bin/sh
sleep 3
if [ `ps ax | grep [a]rdour | wc -l` -eq 1 ]; then
oscsend osc.udp://localhost:3819 /access_action/LuaAction/script-1
fi
Now back to making music