13
0
livetrax/scripts/midi_rewite.lua
Robin Gareus 4866106bcc re-classify bundled lua scripts
* search by author:
  - "Ardour Team" for "ready to use" plugins
  - "Ardour Lua Task Force" = example plugins

* search by Category
  - use "Example" for DSP plugins (except instruments)
2016-07-12 16:43:10 +02:00

35 lines
965 B
Lua

ardour {
["type"] = "session",
name = "Rewrite Midi",
license = "MIT",
author = "Ardour Lua Task Force",
description = [[An example session script preprocesses midi buffers.]]
}
function factory ()
-- this function is called in every process cycle, before processing
return function (n_samples)
_, t = Session:engine ():get_ports (ARDOUR.DataType.midi (), ARDOUR.PortList ())
for p in t[2]:iter () do
if not p:receives_input () then goto next end
if not p:name () == "MIDI/midi_in 1" then goto next end
midiport = p:to_midiport ()
assert (not midiport:isnil ())
mb = midiport:get_midi_buffer (n_samples);
events = mb:table() -- copy event list into lua table
mb:silence (n_samples, 0); -- clear existing buffer
for _,e in pairs (events) do
-- e is-a http://manual.ardour.org/lua-scripting/class_reference/#Evoral:MidiEvent
e:set_channel (2)
mb:push_event (e)
end
::next::
end
end
end