Hi
Background:
I’m trying to use Ardour as Live Backing-Track Player. (As there seems not to be any not-apple-ableton-live solution out there. )
What I Need is a Multi-Track Player sending a Click-Track and different Audio-Tracks to my AudioDevice (Soundcraft UI24) and my be Midi-Tracks to a Midi-Device. Ardour is perfect in doing that. But in a Live/Stage Context i need to Jump to songs and start/stop them very quickly and mouse-free or even better hands-free.
So my idea is to create a Project with all Songs after another, Insert Markers at each start and Jump to these Markers via Midi ProgramChange Comand sent via Midi Controler (Foot-Controler, Keyboard, …).
After long search i stumbled over Lua Scripts and it seems to be the right solution. But i’m stuck now and need help.
What i have Part 1 “Jump To Marker By Lua”:
(run via scripting console)
-- ardour {...}
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
function factory (params)
return function ()
Session:request_stop();
for loc in Session:locations():list():iter() do
if loc:is_mark() then
if string.starts(loc:name(), "03 |") then -- aka "Song Number Three"
-- jump to marker starting with "03 |"
-- "03" needs to be replaced with the Program Number
Session:request_locate(loc:start());
print(loc:name(), loc:start()); -- debug \o/
end
end
end
end
end
so far so good
To catch the Midi Signal i think the example _midi_rec_start.lua is the right choice. Is it?
So i modified it for my needs
ardour {
["type"] = "Session",
name = "Program Change To Marker",
category = "MIDI Controls",
license = "MIT",
author = "FalkHe",
description = [[Map Incoming MIDI Program Changes to Markers]]
}
function factory ()
return function (n_samples)
-- iterate over all MIDI ports
_, t = Session:engine():get_ports(ARDOUR.DataType.midi (), ARDOUR.PortList())
for p in t[2]:iter () do
-- skip output ports
if not p:receives_input () then goto next end
local midiport = p:to_midiport ()
-- and skip async event ports
if midiport:isnil () then goto next end
-- only use the port "MIDI control in"
if p:name() ~= "MIDI control in" then goto next end
-- can i rely on "p:name() === "MIDI control in" to watch only the configured Midi Control?
local mb = midiport:get_midi_buffer(n_samples) -- get the midi-data buffers
local events = mb:table() -- copy event list into lua table
for _,e in pairs (events) do -- iterate over all events in the midi-buffer
-- HELP NEEDED
end
::next::
end
end
end
Now i’m stuck and have a bunch of questions:
- Is this all right, so far?
- Is there a better way to get the midi control port, instead of looping through all ports?
- How to read the MIDI Information from “e” for further usage?
- How to debug a Session script? Printing inside would be horrible as it’s run all the time, or?
- (Is there any better solution or even another Software for the initial purpose?)
I’d love to have this up and running asap.
Thanks in Advance!