mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 07:14:56 +01:00
prototype lua midi generators & filters and port event-rewrite
This commit is contained in:
parent
60200bf923
commit
39e818a03a
6 changed files with 218 additions and 18 deletions
36
scripts/midi_rewite.lua
Normal file
36
scripts/midi_rewite.lua
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
ardour {
|
||||
["type"] = "session",
|
||||
name = "Rewrite Midi",
|
||||
license = "MIT",
|
||||
author = "Robin Gareus",
|
||||
email = "robin@gareus.org",
|
||||
site = "http://gareus.org",
|
||||
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 an http://ardourman/lua-scripting/class_reference/#Evoral:MidiEvent
|
||||
e:set_channel (2)
|
||||
mb:push_event (e)
|
||||
end
|
||||
|
||||
::next::
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue