4 category = "Example", -- Utility
6 author = "Ardour Lua Task Force",
7 description = [[MIDI CC LFO Example -- Triangle full scale CC Parameter automation]]
10 function dsp_ioconfig ()
11 return { { midi_in = 1, midi_out = 1, audio_in = 0, audio_out = 0}, }
14 function dsp_params ()
17 { ["type"] = "input", name = "BPM", min = 40, max = 200, default = 60, unit="BPM"},
18 { ["type"] = "input", name = "CC", min = 0, max = 127, default = 1, integer = true },
26 function dsp_init (rate)
32 function dsp_run (_, _, n_samples)
33 assert (type(midiin) == "table")
34 assert (type(midiout) == "table")
36 local ctrl = CtrlPorts:array ()
40 local spb = samplerate * 60 / bpm -- samples per beat
41 local sps = spb / 254 -- samples per step (0..127..1 = 254 steps)
47 for ts = 1, n_samples do
50 -- forward incoming midi
52 while midiin[i]["time"] == ts do
53 midiout[m] = midiin[i]
56 if i > #midiin then break end
63 if step > 127 then val = 254 - step else val = step end
66 midiout[m]["time"] = ts
67 midiout[m]["data"] = { 0xb0, cc, val }
71 if step == 253 then step = 0 else step = step + 1 end