Change track Active state using MIDI Controller

Hi All

I would like to toggle the Active state of a track using a MIDI controller.
Is a Lua script the way to go?

Any advice appreciated.

Lua is the only way to access this at present - there is no defined Action for Route::set_active.

However, I would have to ask why you want to do this. Route::set_active() is intended to be a very rare operation, used mostly for DSP load management.

I am using Ardour as a live instrument. I realize that it might not be the purpose it has been designed for :slight_smile:
However, it fits my ideas so far.
And also I enjoy the Ardour atmosphere.
Many thanks for it, btw.

In my project I have a lot of tracks, busses, midi instruments, plugins,…
Many of them need to be ON at once. Not all of them though.
I am squeezing the CPU, but it all seems to work and the latency is ok (which I am really surprised).

So now that the setup is finishing, I`d like to optimize the performance by switching Active state instead of Muting the tracks.

I had a quick look at the Lua scripting, but I need to take a deep breath before I dig into it.
Is there a IntelliSense way (with Ardour classes) to write them?
Or the way is to look for examples, documentation and snippets, and compile the solution?
I was considering a hook or a DSP script.
Again any advice much appreciated.

Intellisense is a property of the IDE you choose to use.

The current Ardour developers do not use any IDEs (we prefer traditional text editors combined with other tools and a more modular development environment).

You do not need to compile Lua scripts. You just write them. There are many examples, and yes, most likely the fastest way is to find an example that does something close to what you want.

I’m not really familiar with all of the current examples, but I am not sure there is one that uses incoming MIDI data to do something like this. It will not be a DSP script - you are using MIDI as a user interface and requesting changes in the state of the session.

tl;dr: I think it is not realistic to to do this.

Keep in mind that de/activating tracks is not usually click-free and may cause dropouts. It can also only be done while the transport is not rolling.

Furthermore I expect you’ll get CPU load spikes when en/disabling tracks, not to mention perhaps other side-effects.

It should also be done from a UI thread (GUI, control-surface …), and not realtime thread. This is not currently feasible using Lua. Threading issues are one reason why control surfaces are C++ only.

That being said you could write Editor Action scripts and then use generic-MIDI bindings to trigger Editor/script-action-1…9, but that gets complicated.

A quick/dirty hack would indeed be a Session or DSP script and just deactivate routes, ignoring any thread-safety concerns. A session script would prevent you from de-activating the track that hosts the DSP plugin.

You can probably copy/edit this from two example snippets:

As for triggering this, either make it an EditorAction or look into share/scripts/_midi_rewrite.lua and parse MIDI