2017-01-01 18:52:25 -05:00
|
|
|
ardour {
|
|
|
|
["type"] = "session",
|
|
|
|
name = "MIDI Record Enable",
|
|
|
|
category = "Example", -- "Utility"
|
|
|
|
license = "MIT",
|
2020-09-30 16:06:35 -04:00
|
|
|
author = "Ardour Team",
|
2017-01-01 18:52:25 -05:00
|
|
|
description = [[An example script to start recording on note-on.]]
|
|
|
|
}
|
|
|
|
|
|
|
|
function factory ()
|
|
|
|
return function (n_samples)
|
|
|
|
if Session:actively_recording() then return end -- when recording already, do nothing
|
|
|
|
-- 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
|
|
|
|
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
|
2018-03-17 16:13:06 -04:00
|
|
|
if (e:buffer():array()[1] & 0xf0) == 0x90 then -- note on
|
2017-01-01 18:52:25 -05:00
|
|
|
Session:maybe_enable_record (true) -- global record-enable from rt-context
|
|
|
|
-- maybe-enable may fail if there are no tracks or step-entry is active
|
Fix various typos
Found via `codespell -q 3 -S *.po,./share/patchfiles,./libs -L ba,buss,busses,doubleclick,hsi,ontop,ro,seh,siz,sord,sur,te,trough,ue`
Follow-up to 364f2f078
2022-04-07 09:09:04 -04:00
|
|
|
-- roll transport if record-enable succeeded:
|
2017-01-01 18:52:25 -05:00
|
|
|
if ARDOUR.Session.RecordState.Enabled == Session:record_status() then
|
2021-04-17 15:29:00 -04:00
|
|
|
Session:request_roll (ARDOUR.TransportRequestSource.TRS_UI) -- ...and go.
|
2017-01-01 18:52:25 -05:00
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
::next::
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|