From 448bc635e528f068d88a34de03622fba0e3ea180 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 18 Mar 2017 19:10:19 +0100 Subject: [PATCH] Add example script to access midi-region events --- scripts/_dump_midiregion.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 scripts/_dump_midiregion.lua diff --git a/scripts/_dump_midiregion.lua b/scripts/_dump_midiregion.lua new file mode 100644 index 0000000000..34ee124b14 --- /dev/null +++ b/scripts/_dump_midiregion.lua @@ -0,0 +1,21 @@ +ardour { ["type"] = "Snippet", name = "Dump MIDI Region" } + +function factory () return function () + local sel = Editor:get_selection () + for r in sel.regions:regionlist ():iter () do + local mr = r:to_midiregion () + if mr:isnil () then goto next end + + print (r:name (), "Pos:", r:position (), "Start:", r:start ()) + local bfc = ARDOUR.BeatsFramesConverter (Session:tempo_map (), r:position ()) + local nl = ARDOUR.LuaAPI.note_list (mr:model ()) + for n in nl:iter () do + print (" Note @", bfc:to (n:time ()), + ARDOUR.ParameterDescriptor.midi_note_name (n:note ()), + "Vel:", n:velocity ()) + end + print ("----") + ::next:: + end +end end +