Use Midi Control Program Change to Jump To Marker via Lua

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. :frowning: )

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:

  1. Is this all right, so far?
  2. Is there a better way to get the midi control port, instead of looping through all ports?
  3. How to read the MIDI Information from “e” for further usage?
  4. How to debug a Session script? Printing inside would be horrible as it’s run all the time, or?
  5. (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!

It obviously seems like you are looking for a non-OSX/iOS solution right now so I am limiting suggestions to Linux based solutions for the moment, but if you want to go farther down this rabbit hole let me know.

While I am not even sure Ableton is the right tool for this, there is Bitwig as an alternative that runs on non-osx platforms including Linux.

However I wonder if something like Linux Show Player would be a better option for you. I am not certain on the status of playing back MIDI files in it (Though it can send MIDI commands etc.) That would allow you to easily jump through a set list.

In terms of the LUA API, I think most commands in the UI can be accessed through Lua IIRC, so what I may suggest then would be looking into Jump-To-Next-Marker and Jump-To-Previous-Marker instead of necessarily trying to get everything named based off exact PC requirements for a simpler solution? Heck that doesn’t even need to be MIDI based if you don’t want it to be, and instead could be simple keyboard emulators like an XKeys for instance to fire the commands.

Hope this helps and doesn’t derail from the other questions you have (Which I am less helpful with right now as I haven’t messed with Lua yet honestly)

    Seablade

Thanks for your reply

Ableton: With Ableton Live it’s possible to define Scenes with different Measures and Tempos. Starting a Scene will start all related Clips (same for bitwig). And you can define Midi Controls for selecting starting and stopping a Scene. I worked with this setup already with another band and it works like a charm. But i by myself don’t own a Mac (and don’t want to) and don’t want to pay 349,-€ for a full DAW, i only use for live sessions. :confused:

Bitwig: I tried that already but, unlike Ableton Live, Bitwig is not capable of using different Tempos per Scene AND Bitwig also has no Option to jump to a Scene in Mix View (or Marker in Arrangment View). Or at least i did not found anything about this.

Linux Show Player: Correct me, if i’m wrong, but Linux Show Player ist not able to play Multiple Tracks synchron at the same time to different Outputs. Is it?

Next/Prev ist not an option … think of a setlist with 50+ Songs … On stage, i have no time to “search” for a specific song via prev/next on the computer. Furthermore the “Jump to a special named Marker” is already solved via LUA.

Sorry, ithought that’s clear: I’m not able to work with the computer directly on Stage. I don’t want it to be in sight of the audiance and i don’t want to leave the stage for selecting and starting a Song. So mouse or keys are not an option. Therfore MIDI or OSC is the only relevant way to go, i think. Because i can sent both via either OSC Apps (Smartphone attached to my Mic) or Midi Pedal Boards or Midi Signal sent from the App “Bandhelper” on Song Selection. Latter would be great.

I think my Lua Solution is close to the perfect goal, if i understood Lua Session Scripts right. I’m only missing the MIDI-Thing or the Debug-Thing to test/find it out by myself. :confused:

If it isn’t that would be a major failing on it’s part considering it’s intended use. That is pretty basic functionality for that purpose honestly.

Do you not pre-build your setlist?

But beyond that you are also limiting yourself there as it doesn’t need to be a button press either, many MIDI control surfaces use increment and decrement commands on pots and jog wheels for instance.

For the record, one does not preclude the other a USB keyboard (Or rather devices that sends keyboard commands) can be remotely located very easily. But even so you will want/need some sort of screen on stage. I imagine this is why you are looking at program changes then to control and utilizing the feedback on your keyboard, hope it doesn’t ever fail then, as fixes will be much worse.

On the topic of keyboards by the way, not sure if this ever made it’s way back into Ardour or not:

A simple wired number pad could be located remotely using a USB to Cat5 Balun, just have the screen somewhere you could see it.

A suggestion: I have been involved with literally hundreds of different shows with similar situations, it doesn’t matter what level, every type of show in similar situations ALWAYS makes sure they can see the screen in case of emergency/failure. This includes those that utilize Live, QLab, or half a dozen other solutions of various quality levels ranging from one man band/small band performance to broadway. It doesn’t mean you need to interact in a ‘traditional’ way regularly, but it does mean that when something does go wrong (Not if) you will be better prepared to address it quickly, ideally before your audience even knows.

Wait are you running Android or iOS? That could change the answer considerably conceivably. I am guessing Bandhelper can’t play back individual tracks sync’d for this purpose either(IIUC it can play back stereo backing tracks but that is it?)

   Seablade

Thanks for your thoughts! This is a bit off-topic, because my main Questions are about Midi in LUA Scripts. … But i like to answer / explain a bit more detailed.

Nope, LiSP is ment to be used on theater shows or similar and allows only to run some “Cues” (aka Clips) on mouse-click or triggered by time/or another cue. It’s not capable of multiple (parallel) Tracks nor multiple Outputs (it’s not even showing up in Jack Connections and there are no audio settings.)

Nope, usually we only pre-build the first one or two sets and everything else depends of the behaviour of the audience on these first Songs. (And i’m lazy. I don’t want to create a new Project for every single show when we reorder the setlist. :wink: ) Therefore i need to jump to any song at any time.

Indeed. But only in case of failure. In the normal Live Scenario i can’t use the Screen of Adour or any other DAW (i’m aware of) because the Labels of Markers/Scenes or whatever are a way to small to be read from more than one meter distance.

Of cause, in case of failure i have to acces the Computer directly, but this should not be the normal way to go. When using prev/next Buttons, i need to see what’s selected. This is impossible on a Laptop placed on the ground or at the Stage-Rack on the side. … but this is Possible on a Foot-Pedal showing the Midi Programm Number in large LEDs.

The DAW is running on my Ubuntu-PC and i have a Android Tablet attached to my Mic Stand, running Bandhelper (mostly as Setlist) or my Monitor-Mixer. So sending some Signal from my Android Tablet, to control the Playback (select/start/stop Song) on the Computer is a desired option. (As i already said: Bandhelper is also capable of sending a Midi Program Change on Song Selection … )

Indeed, Bandhelper is able to play a single Audiofile per Song. But that’s not enough because I do need at least a separate Click-Track to route to the InEar Monitors. And I’d prefer to send each Track/Instrument from the Backing Tracks to single Channels on the PA-Mixer so the Sound-Guy can control them individually.

Understood, I only answer here because you brought it up in your OP and I can’t help you much with the Lua side of things right now. If you want I will be more than happy to split this into it’s own thread to continue discussion.

While I don’t have good knowledge on Linux Show Player, what you have described as it not doing is EXACTLY what I would expect any good theatrical sound playback software to do. For instance I use QLab for this quite often in designs I create (Both in terms of music and playing different tracks/instruments to different outputs in perfect sync, and in terms of SFX where I layer dozens of sounds using multiple outputs). If it does not do this, then it is a major limitation of the software sadly and doesn’t do anything about what I would expect it to so I apologize about bringing it up then.

Ok making a bit more sense now then, good to know.

That is where I would really be looking at Lua to provide feedback if needed honestly, creating a way to provide that visual feedback. but that is getting REALLY OT:)

Ok yea Android tablet is a bit harder to do it on, there were some options on iOS I tihnk, but not familiar with any on Android off hand, it’s audio system just isn’t at the same point sadly.

Doesn’t answer the multiple output side of things, but don’t forget that you can always mix your tracks to mono, and create a file with mono audio on one side and click on the other, and have the audio mixer route that to the PA and band as appropriate. This is the old way of doing things for many years that is still applicable today (Not to mention that many systems even if set up with more than one speaker are actually only really mono reproduction systems and shouldn’t be used as ‘stereo’, but that is WAY off topic;)

Seablade