Update to fluidsynth-2.1
[ardour.git] / scripts / _midigenerator2.lua
1 ardour {
2         ["type"]    = "dsp",
3         name        = "MIDI Generator II",
4         category    = "Example",
5         license     = "MIT",
6         author      = "Ardour Lua Task Force",
7         description = [[An Example Midi Generator for prototyping.]]
8 }
9
10 function dsp_ioconfig ()
11         return { { midi_in = 1, midi_out = 1, audio_in = -1, audio_out = -1}, }
12 end
13
14 function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
15         local ob = out_map:get (ARDOUR.DataType ("midi"), 0)
16         if ob ~= ARDOUR.ChanMapping.Invalid then
17                 local mb = bufs:get_midi (ob)
18
19                 -- see _midigenerator.lua for
20                 -- how to use a timed sequence
21
22                 local ba = C.ByteVector () -- construct a byte vector
23                 ba:add ({0x90, 64, 127}) -- add some data to the vector
24                 -- send a message at cycle-start
25                 mb:push_back (offset, ba:size (), ba:to_array());
26
27                 ba:clear ()
28                 ba:add ({0x80, 64, 127})
29                 mb:push_back (n_samples - 1 - offset, ba:size (), ba:to_array());
30         end
31
32         -- passthrough audio, apply pin/channel mapping
33         ARDOUR.DSP.process_map (bufs, in_map, out_map, n_samples, offset, ARDOUR.DataType ("audio"))
34 end