summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-04-11 11:41:22 +0200
committerRobin Gareus <robin@gareus.org>2020-04-11 11:41:22 +0200
commitf18a7e3fc32d43fbf14000e5513e4eace3d76604 (patch)
tree9702aa3b6843728c195533b3998c1aea997c05a1 /share
parent9e3efced721fa41b39f8f032e2f26a20673a4eb1 (diff)
Prefer using C++ DSP for noise generation in scripts
This significantly reduces the DSP load of the noise generator (avg. process time is reduced by a factor of 8 or more).
Diffstat (limited to 'share')
-rw-r--r--share/scripts/_noisegen.lua (renamed from share/scripts/noisegen.lua)0
-rw-r--r--share/scripts/a-noise.lua55
2 files changed, 55 insertions, 0 deletions
diff --git a/share/scripts/noisegen.lua b/share/scripts/_noisegen.lua
index bf7b006160..bf7b006160 100644
--- a/share/scripts/noisegen.lua
+++ b/share/scripts/_noisegen.lua
diff --git a/share/scripts/a-noise.lua b/share/scripts/a-noise.lua
new file mode 100644
index 0000000000..dccded19c6
--- /dev/null
+++ b/share/scripts/a-noise.lua
@@ -0,0 +1,55 @@
+ardour {
+ ["type"] = "dsp",
+ name = "a-Noise",
+ category = "Utility",
+ license = "MIT",
+ author = "Ardour Team",
+ description = [[Noise Generator]]
+}
+
+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 = "Noise Level", min = -80, max = 0, default = -18, unit="dBFS"},
+ { ["type"] = "input", name = "Noise Type", min = 0, max = 2, default = 0, enum = true, scalepoints =
+ {
+ ["White Noise"] = ARDOUR.DSP.NoiseType.UniformWhiteNoise,
+ ["Gaussian White Noise"] = ARDOUR.DSP.NoiseType.GaussianWhiteNoise,
+ ["Pink Noise"] = ARDOUR.DSP.NoiseType.PinkNoise,
+ }
+ },
+ }
+end
+
+local cmem = nil
+local gen = nil
+local noise = 0
+
+function dsp_init (rate)
+ cmem = ARDOUR.DSP.DspShm (8192)
+ gen = ARDOUR.DSP.Generator ()
+end
+
+function dsp_run (ins, outs, n_samples)
+ local ctrl = CtrlPorts:array()
+ local lvl = ARDOUR.DSP.dB_to_coefficient (ctrl[1])
+ if (noise ~= ctrl[2]) then
+ noise = ctrl[2]
+ gen:set_type (noise)
+ end
+ for c = 1,#ins do
+ if ins[c] ~= outs[c] then
+ ARDOUR.DSP.copy_vector (outs[c], ins[c], n_samples)
+ end
+ gen:run (cmem:to_float(0), n_samples)
+ ARDOUR.DSP.mix_buffers_with_gain (outs[c], cmem:to_float(0), n_samples, lvl)
+ end
+end