6 author = "Ardour Lua Task Force",
7 description = [[An Example Filter Plugin]]
10 function dsp_ioconfig ()
13 -- allow any number of I/O as long as port-count matches
14 { audio_in = -1, audio_out = -1},
18 function dsp_params ()
21 { ["type"] = "input", name = "Base Freq", min = 10, max = 1000, default = 100, unit="Hz", logarithmic = true },
22 { ["type"] = "input", name = "Quality", min = 1.0, max = 100.0, default = 8.0, logarithmic = true },
23 { ["type"] = "input", name = "Stages", min = 1.0, max = 100, default = 8.0, integer = true },
27 local filters = {} -- the biquad filter instances
29 local chn = 0 -- channel count
30 local max_stages = 100
34 function dsp_init (rate)
38 function dsp_configure (ins, outs)
39 assert (ins:n_audio () == outs:n_audio ())
43 for i = 1, max_stages do
44 filters[c][i] = ARDOUR.DSP.Biquad (sample_rate)
49 function dsp_run (ins, outs, n_samples)
51 assert (n_samples < 8192)
53 -- this is quick/dirty: no declick, no de-zipper, no latency reporting,...
54 -- and no documentation :)
56 local ctrl = CtrlPorts:array() -- get control parameters
57 if freq ~= ctrl[1] or qual ~= ctrl[2] then
61 for i = 1, max_stages do
62 filters[c][i]:compute (ARDOUR.DSP.BiquadType.Notch, freq * i, qual, 0)
67 local limit = math.floor (sample_rate / ( 2 * freq ))
68 local stages = math.floor (ctrl['3'])
69 if stages < 1 then stages = 1 end
70 if stages > max_stages then stages = max_stages end
71 if stages > limit then stages = limit end
73 -- process all channels
75 if not ins[c]:sameinstance (outs[c]) then
76 ARDOUR.DSP.copy_vector (outs[c], outs[c], n_samples)
80 filters[c][i]:run (outs[c], n_samples)