From 8702ff2189665b473918ed60f34b6be4010a06f7 Mon Sep 17 00:00:00 2001 From: R <@gmail.com> Date: Sun, 23 Feb 2020 00:07:51 +0000 Subject: [PATCH] Add support for Lua DSP scripts with multiple MIDI outputs --- libs/ardour/luaproc.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libs/ardour/luaproc.cc b/libs/ardour/luaproc.cc index bbde673299..ab20bdf251 100644 --- a/libs/ardour/luaproc.cc +++ b/libs/ardour/luaproc.cc @@ -725,12 +725,15 @@ LuaProc::connect_and_run (BufferSet& bufs, // copy back midi events if (_has_midi_output && lua_midi_sink_tbl.isTable ()) { - bool valid; - const uint32_t idx = out.get(DataType::MIDI, 0, &valid); - if (valid && bufs.count().n_midi() > idx) { - MidiBuffer& mbuf = bufs.get_midi(idx); - mbuf.silence(0, 0); - for (luabridge::Iterator i (lua_midi_sink_tbl); !i.isNil (); ++i) { + uint32_t count = 0; + uint32_t idx; + for (luabridge::Iterator i (lua_midi_sink_tbl); !i.isNil (); ++i) { + bool iter_is_valid; + idx = out.get(DataType::MIDI, count, &iter_is_valid); + count++; + if (iter_is_valid && bufs.count().n_midi() > idx) { + MidiBuffer& mbuf = bufs.get_midi(idx); + mbuf.silence(0, 0); if (!i.key ().isNumber ()) { continue; } if (!i.value ()["time"].isNumber ()) { continue; } if (!i.value ()["data"].isTable ()) { continue; }