summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-02-26 15:26:15 +0100
committerRobin Gareus <robin@gareus.org>2020-02-26 17:51:25 +0100
commit65425b9fe20590d0a37f91e5c8f88014bc3003d4 (patch)
tree47d89d9a9f96f5a4e82944b540a8bd06e91aec0c /share
parentd27cdb3855eb679dcf66fa37312dcab5aae100dd (diff)
Add a mute/gate plugin
Diffstat (limited to 'share')
-rw-r--r--share/scripts/a_mute.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/share/scripts/a_mute.lua b/share/scripts/a_mute.lua
new file mode 100644
index 0000000000..e52c7dde36
--- /dev/null
+++ b/share/scripts/a_mute.lua
@@ -0,0 +1,59 @@
+ardour {
+ ["type"] = "dsp",
+ name = "a-Mute",
+ category = "Amplifier",
+ license = "MIT",
+ author = "Ardour Team",
+ description = [[Auotomatable Mute/Gate]]
+}
+
+function dsp_ioconfig ()
+ -- -1, -1 = any number of channels as long as input and output count matches
+ return { { audio_in = -1, audio_out = -1} }
+end
+
+function dsp_params ()
+ return { { ["type"] = "input", name = "Mute", min = 0, max = 1, default = 0, toggled = true } }
+end
+
+local sr = 48000
+local cur_gain = 0.0
+
+function dsp_init (rate)
+ sr = rate
+end
+
+function dsp_configure (ins, outs)
+ n_out = outs
+ n_audio = outs:n_audio ()
+ n_midi = outs:n_midi ()
+ assert (n_midi == 0)
+end
+
+-- the DSP callback function
+function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
+ local ctrl = CtrlPorts:array() -- get control port array
+ local target_gain = ctrl[1] > 0 and 0.0 or 1.0; -- when muted, target_gain = 0.0; otherwise use 1.0
+ -- apply I/O map
+ ARDOUR.DSP.process_map (bufs, n_out, in_map, out_map, n_samples, offset)
+
+ local g = cur_gain
+ for c = 1, n_audio do
+ local ob = out_map:get (ARDOUR.DataType ("audio"), c - 1); -- get id of mapped output buffer for given cannel
+ if (ob ~= ARDOUR.ChanMapping.Invalid) then
+ cur_gain = ARDOUR.Amp.apply_gain (bufs:get_audio(ob), sr, n_samples, g, target_gain, offset)
+ end
+ end
+
+ -- This plugin doesn't allow MIDI I/O, but it could:
+ --[[
+ if (target_gain == 0) then
+ for c = 1, n_midi do
+ local ob = out_map:get (ARDOUR.DataType ("midi"), c - 1);
+ if (ob ~= ARDOUR.ChanMapping.Invalid) then
+ bufs:get_midi(ob):silence (n_samples, offset)
+ end
+ end
+ end
+ --]]
+end