summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-02-29 00:25:51 +0100
committerRobin Gareus <robin@gareus.org>2020-02-29 00:25:51 +0100
commit97125011394df265cbf5fe9790431d4fe8c278c3 (patch)
tree7ac9584c2eed74893e92cd90b128b992e3c4664c /share
parentdd2c6e7cf19a34e6dcf0565b5b9b33172e2ad25b (diff)
Lua Amplifier plugin with gain-coeff ratio controls
Diffstat (limited to 'share')
-rw-r--r--share/scripts/_amp_coefficient_ratio.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/share/scripts/_amp_coefficient_ratio.lua b/share/scripts/_amp_coefficient_ratio.lua
new file mode 100644
index 0000000000..04d0d26061
--- /dev/null
+++ b/share/scripts/_amp_coefficient_ratio.lua
@@ -0,0 +1,48 @@
+ardour {
+ ["type"] = "dsp",
+ name = "a-Gain Ratio",
+ category = "Amplifier",
+ license = "MIT",
+ author = "Ardour Team",
+ description = [[Multichannel amplifier with gain coefficient ratio (not dezippered). Beware this plugin allows for significant gain ratios, it's intended to academic purposes.]]
+}
+
+function dsp_ioconfig ()
+ return
+ {
+ -- -1, -1 = any number of channels as long as input and output count matches
+ { audio_in = -1, audio_out = -1},
+ }
+end
+
+function dsp_params ()
+ return
+ {
+ { ["type"] = "input", name = "Gain Coefficient numerator", min = 0, max = 1048576, default = 1, unit="", logarithmic = true},
+ { ["type"] = "input", name = "Gain coefficient denominator", min = 1, max = 1048576, default = 1, unit="", logarithmic = 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 ()
+end
+
+function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
+ local ctrl = CtrlPorts:array()
+ local gain = ctrl[1] / ctrl[2]
+ ARDOUR.DSP.process_map (bufs, n_out, in_map, out_map, n_samples, offset)
+ 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
+ bufs:get_audio (ob):apply_gain (gain, n_samples);
+ end
+ end
+end