1ardour { 2 ["type"] = "dsp", 3 name = "Spike Synth", 4 category = "Instrument", 5 license = "MIT", 6 author = "Ardour Team", 7 description = [[A debug and test-instrumentation synth. This plugin is useful with Ardour's "Dummy" backend "Engine-Pulse" mode to verify capture alignment. This plugin generate the exact same audio-signal from MIDI data that the backend also generates: Note-on: +1, Note-off: -1.]] 8} 9 10function dsp_ioconfig () 11 return { { midi_in = 1, audio_in = 0, audio_out = 1} } 12end 13 14function dsp_run (ins, outs, n_samples) 15 local a = {} 16 for s = 1, n_samples do a[s] = 0 end 17 18 for c = 1,#outs do 19 ARDOUR.DSP.memset (outs[c], 0, n_samples) 20 end 21 22 assert (type(midiin) == "table") 23 for _,b in pairs (midiin) do 24 local t = b["time"] -- t = [ 1 .. n_samples ] 25 local d = b["data"] -- get midi-event 26 if (#d == 3 and (d[1] & 240) == 144) then -- note on 27 for c = 1,#outs do 28 outs[c]:array()[t] = 1.0 29 end 30 end 31 if (#d == 3 and (d[1] & 240) == 128) then -- note off 32 for c = 1,#outs do 33 outs[c]:array()[t] = -1.0 34 end 35 end 36 end 37end 38