name = "Midi Passthru",
category = "Example",
license = "MIT",
- author = "Ardour Team",
+ author = "Ardour Lua Task Force",
description = [[An Example Audio/MIDI Passthrough Plugin using Buffer Pointers]]
}
if ib ~= ARDOUR.ChanMapping.Invalid then
-- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:MidiBuffer
local mb = bufs:get_midi (ib) -- get the mapped buffer
- events = mb:table () -- copy event list into a lua table
+ local events = mb:table () -- copy event list into a lua table
-- iterate over all MIDI events
for _, e in pairs (events) do
-- e is-a http://manual.ardour.org/lua-scripting/class_reference/#Evoral:MidiEvent
- -- do something with the event
- --print (e:channel ())
+ -- do something with the event e.g.
+ print (e:channel (), e:time (), e:size (), e:buffer ():array ()[1], e:buffer ():get_table (e:size ())[1])
end
end
-- The following code is needed with "dsp_runmap" to work for arbitrary pin connections
-- this passes though all audio/midi data unprocessed.
- local audio_ins = in_map:count (): n_audio () -- number of audio input buffers
- local audio_outs = out_map:count (): n_audio () -- number of audio output buffers
+ 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"))
+
+ -- equivalent lua code.
+ -- NOTE: the lua implementation below is intended for io-config [-1,-1].
+ -- It only works for actually mapped channels due to in_map:count() out_map:count()
+ -- being identical to the i/o pin count in this case.
+ --
+ -- Plugins that have multiple possible configurations will need to implement
+ -- dsp_configure() and remember the actual channel count.
+ --
+ -- ARDOUR.DSP.process_map() does iterate over the mapping itself and works generally.
+ -- Still the lua code below does lend itself as elaborate example.
+ --
+ --[[
+
+ local audio_ins = in_map:count (): n_audio () -- number of mapped audio input buffers
+ local audio_outs = out_map:count (): n_audio () -- number of mapped audio output buffers
assert (audio_outs, audio_ins) -- ioconfig [-1, -1]: must match
-- copy audio data if any
bufs:get_midi (ob):silence (n_samples, offset)
end
end
+ --]]
end