summaryrefslogtreecommitdiff
path: root/scripts/midimon.lua
diff options
context:
space:
mode:
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2016-07-12 00:13:01 +0200
committerRobin Gareus <robin@gareus.org>2016-07-12 01:47:02 +0200
commit30240b33e903a6a0ee098cc5c787f74e9f69f6c3 (patch)
tree31fa228dd7a279de9f5f386248c0490dc02ceea9 /scripts/midimon.lua
parente8cd2949bdec2e81187d74232193eb920c918459 (diff)
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.
Diffstat (limited to 'scripts/midimon.lua')
-rw-r--r--scripts/midimon.lua39
1 files changed, 24 insertions, 15 deletions
diff --git a/scripts/midimon.lua b/scripts/midimon.lua
index bda71be74a..226b4b0d17 100644
--- a/scripts/midimon.lua
+++ b/scripts/midimon.lua
@@ -13,7 +13,7 @@ local evlen = 3
local hpadding, vpadding = 4, 2
function dsp_ioconfig ()
- return { { audio_in = 0, audio_out = 0}, }
+ return { { audio_in = -1, audio_out = -1}, }
end
function dsp_has_midi_input () return true end
@@ -53,23 +53,32 @@ function dsp_init (rate)
end
end
-function dsp_run (_, _, n_samples)
- assert (type(midiin) == "table")
- assert (type(midiout) == "table")
-
+function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
local pos = self:shmem():atomic_get_int(0)
local buffer = self:shmem():to_int(1):array()
- -- passthrough midi data, and fill the event buffer
- for i, d in pairs(midiin) do
- local ev = d["data"]
- midiout[i] = { time = d["time"], data = ev }
- pos = pos % ringsize + 1
- for j = 1, math.min(#ev,evlen) do
- buffer[(pos-1)*evlen + j] = ev[j]
- end
- for j = #ev+1, evlen do
- buffer[(pos-1)*evlen + j] = 0
+ -- passthrough all data
+ ARDOUR.DSP.process_map (bufs, in_map, out_map, n_samples, offset, ARDOUR.DataType ("audio"))
+ ARDOUR.DSP.process_map (bufs, in_map, out_map, n_samples, offset, ARDOUR.DataType ("midi"))
+
+ -- then fill the event buffer
+ local ib = in_map:get (ARDOUR.DataType ("midi"), 0) -- index of 1st midi input
+
+ if ib ~= ARDOUR.ChanMapping.Invalid then
+ local events = bufs:get_midi (ib):table () -- copy event list into a lua table
+
+ -- 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