summaryrefslogtreecommitdiff
path: root/share/scripts/_spike_synth.lua
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-02-23 20:48:02 +0100
committerRobin Gareus <robin@gareus.org>2020-02-23 20:48:02 +0100
commit180843f9bd28b191c7404245ba0a121107992511 (patch)
treec60312dc09f76c2f55ba2383245c427e15c38dea /share/scripts/_spike_synth.lua
parentbf649cd68ad46c34a656700aa6cb89416d648c64 (diff)
Also move Lua scripts to share subfolder
Diffstat (limited to 'share/scripts/_spike_synth.lua')
-rw-r--r--share/scripts/_spike_synth.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/share/scripts/_spike_synth.lua b/share/scripts/_spike_synth.lua
new file mode 100644
index 0000000000..167e0e27d2
--- /dev/null
+++ b/share/scripts/_spike_synth.lua
@@ -0,0 +1,37 @@
+ardour {
+ ["type"] = "dsp",
+ name = "Spike Synth",
+ category = "Instrument",
+ license = "MIT",
+ author = "Ardour Lua Task Force",
+ 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.]]
+}
+
+function dsp_ioconfig ()
+ return { { midi_in = 1, audio_in = 0, audio_out = 1} }
+end
+
+function dsp_run (ins, outs, n_samples)
+ local a = {}
+ for s = 1, n_samples do a[s] = 0 end
+
+ for c = 1,#outs do
+ ARDOUR.DSP.memset (outs[c], 0, n_samples)
+ end
+
+ assert (type(midiin) == "table")
+ for _,b in pairs (midiin) do
+ local t = b["time"] -- t = [ 1 .. n_samples ]
+ local d = b["data"] -- get midi-event
+ if (#d == 3 and (d[1] & 240) == 144) then -- note on
+ for c = 1,#outs do
+ outs[c]:array()[t] = 1.0
+ end
+ end
+ if (#d == 3 and (d[1] & 240) == 128) then -- note off
+ for c = 1,#outs do
+ outs[c]:array()[t] = -1.0
+ end
+ end
+ end
+end