I’m working on writing my first lua script for ardour.
It was close, but then I made a syntax error. Now It seems to have disappeared from the plugin manager.
How do I get it back?
Thanks!
I’m working on writing my first lua script for ardour.
It was close, but then I made a syntax error. Now It seems to have disappeared from the plugin manager.
How do I get it back?
Thanks!
OK, the script is showing up now…
Here is what I “think” I have learned so far:
If a lua plugin has an obvious syntax error, it seems to get skipped from being made available in the plugin selector.
This is just as well because a script with a syntax error can crash Ardour. Not a complaint, just an observation.
It helps to paste the source code into the scripting window and tell it to run. It probably won’t do anything, but if there is a syntax error it will probably be flagged.
OK, here is my first script. It works exactly as I had hoped.
I’m learning to play drums and I use Ardour to play jam tracks. However, my electronic drum kit is far enough away from the computer that it’s inconvenient to press play on the computer then hurry to the kit and get situated before the track starts. This lets me just strike a drum when I want the track to start.
It was inspired by the “Voice/Level Activate” script that rolls the transport when an audio input reaches a certain level. This script does the same thing except the trigger is a MIDI note message.
I’m going to make a pull request to include it with the next release, but since this is my first one, and I don’t know lua, I’d appreciate it if someone that knows lua could take a quick look to see if there is something that I should change before I make the pull request.
Thank you.
ardour {
["type"] = "dsp",
name = "MIDI Roll Transport",
category = "Utility",
author = "Jon Bennett",
license = "MIT",
description = [[Roll the transport when a MIDI note is received.]]
}
function dsp_ioconfig ()
return { { midi_in = 1, midi_out = 1, audio_in = 0, audio_out = 0}, }
end
function dsp_run (_, _, _)
assert (type(midiin) == "table")
assert (type(midiout) == "table")
local cnt = 1
local rollTransport = false
for _,b in pairs (midiin) do
local t = b["time"] -- t = [ 1 .. n_samples ]
local d = b["data"] -- get midi-event
midiout[cnt] = {}
midiout[cnt]["time"] = t;
midiout[cnt]["data"] = d;
cnt = cnt + 1
local event_type
if #d == 0 then event_type = -1 else event_type = d[1] >> 4 end
if (#d == 3) and (event_type == 9 or event_type == 8) then -- note on, note off
rollTransport = true
end
end
if Session:transport_rolling() then
return
end
if rollTransport == true then
Session:request_roll (ARDOUR.TransportRequestSource.TRS_UI)
end
end