Make MIDI monitor a pass-through for audio and midi

MIDI monitor only accepted midi data and output that same data. That was
logical for a MIDI plugin, but a consequence is that automatic pin
configuration makes MIDI monitors opaque to audio data, which means
drag'n'dropping a MIDI monitor for debugging purposes can suddenly cut
audio, or even change the channel count if strict I/O is enabled.

Improve the MIDI monitor so that it passes through all incoming data
unchanged.
This commit is contained in:
Julien "_FrnchFrgg_" RIVAUD 2016-07-12 00:13:01 +02:00 committed by Robin Gareus
parent e8cd2949bd
commit 30240b33e9

View file

@ -13,7 +13,7 @@ local evlen = 3
local hpadding, vpadding = 4, 2 local hpadding, vpadding = 4, 2
function dsp_ioconfig () function dsp_ioconfig ()
return { { audio_in = 0, audio_out = 0}, } return { { audio_in = -1, audio_out = -1}, }
end end
function dsp_has_midi_input () return true end function dsp_has_midi_input () return true end
@ -53,23 +53,32 @@ function dsp_init (rate)
end end
end end
function dsp_run (_, _, n_samples) function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
assert (type(midiin) == "table")
assert (type(midiout) == "table")
local pos = self:shmem():atomic_get_int(0) local pos = self:shmem():atomic_get_int(0)
local buffer = self:shmem():to_int(1):array() local buffer = self:shmem():to_int(1):array()
-- passthrough midi data, and fill the event buffer -- passthrough all data
for i, d in pairs(midiin) do ARDOUR.DSP.process_map (bufs, in_map, out_map, n_samples, offset, ARDOUR.DataType ("audio"))
local ev = d["data"] ARDOUR.DSP.process_map (bufs, in_map, out_map, n_samples, offset, ARDOUR.DataType ("midi"))
midiout[i] = { time = d["time"], data = ev }
pos = pos % ringsize + 1 -- then fill the event buffer
for j = 1, math.min(#ev,evlen) do local ib = in_map:get (ARDOUR.DataType ("midi"), 0) -- index of 1st midi input
buffer[(pos-1)*evlen + j] = ev[j]
end if ib ~= ARDOUR.ChanMapping.Invalid then
for j = #ev+1, evlen do local events = bufs:get_midi (ib):table () -- copy event list into a lua table
buffer[(pos-1)*evlen + j] = 0
-- iterate over all MIDI events
for _, e in pairs (events) do
local ev = e:buffer():array()
pos = pos % ringsize + 1
-- copy the data
for j = 1, math.min(e:size(),evlen) do
buffer[(pos-1)*evlen + j] = ev[j]
end
-- zero unused slots
for j = e:size()+1, evlen do
buffer[(pos-1)*evlen + j] = 0
end
end end
end end