I have a flaky USB-MIDI interface that occasionally needs to be reset. I’m trying to write a LUA script to do this. I’ve got something that resets the audio interface (just stops and starts it), but I’m stuck trying to figure out to connect a physical MIDI device to a track. More specifically, I’m stuck trying to get a list of physical input MIDI devices. I’ve got this, but it prints just about everything except what I’m looking for (the physical MIDI device):
ardour {
["type"] = "EditorAction",
name = "Reset MIDI",
category = "Utility",
author = "Brent Baccala",
description = "Reset my MIDI interface"
}
function factory (unused_params)
return function ()
local engine = Session:engine();
engine:stop();
engine:start();
_, t = engine:get_ports (ARDOUR.DataType.midi (), ARDOUR.PortList ());
for p in t[2]:iter() do
local midiport = p:to_midiport ()
print(midiport:name())
end
end
end
It does seem that I need to specify ARDOUR.PortFlags.IsOutput to get an input port, but I’ll try to investigate that some more. My code is about nine months old, so I don’t have any recent patches.
We inherited those constants from JACK and should have replaced them with less ambiguous ones.
It depends on the view-point. From Ardour’s point of view, and output port is a source. Data is provided to Ardour by an output from somewhere (usually hardware).
Likewise an input is a sink, that Ardour sends data to for some other app or hardware to read.
–
This is reversed if you look on the whole system from the outside…