From: Robin Gareus Date: Sat, 27 Aug 2016 17:47:53 +0000 (+0200) Subject: update notch-bank to variable i/o, increase max stages to 100 X-Git-Tag: 5.2~5 X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=commitdiff_plain;h=798cd4831bfb9b783fd88a2ae65a6fac6f78d983 update notch-bank to variable i/o, increase max stages to 100 --- diff --git a/scripts/_notch_bank.lua b/scripts/_notch_bank.lua index daaa4b1cd1..e90b028b92 100644 --- a/scripts/_notch_bank.lua +++ b/scripts/_notch_bank.lua @@ -10,7 +10,8 @@ ardour { function dsp_ioconfig () return { - { audio_in = 1, audio_out = 1}, + -- allow any number of I/O as long as port-count matches + { audio_in = -1, audio_out = -1}, } end @@ -19,45 +20,64 @@ function dsp_params () { { ["type"] = "input", name = "Base Freq", min = 10, max = 1000, default = 100, unit="Hz", logarithmic = true }, { ["type"] = "input", name = "Quality", min = 1.0, max = 16.0, default = 8.0 }, - { ["type"] = "input", name = "Stages", min = 1.0, max = 20, default = 6.0, integer = true }, + { ["type"] = "input", name = "Stages", min = 1.0, max = 100, default = 8.0, integer = true }, } end local filters = {} -- the biquad filter instances +local sample_rate = 0 +local chn = 0 -- channel count +local max_stages = 100 local freq = 0 -local bw = 0 +local qual = 0 function dsp_init (rate) - for i = 1,20 do - filters[i] = ARDOUR.DSP.Biquad (rate) + sample_rate = rate +end + +function dsp_configure (ins, outs) + assert (ins:n_audio () == outs:n_audio ()) + chn = ins:n_audio () + for c = 1, chn do + filters[c] = {} + for i = 1, max_stages do + filters[c][i] = ARDOUR.DSP.Biquad (sample_rate) + end end end function dsp_run (ins, outs, n_samples) - assert (#outs == 1) + assert (#ins == chn) assert (n_samples < 8192) -- this is quick/dirty: no declick, no de-zipper, no latency reporting,... -- and no documentation :) local ctrl = CtrlPorts:array() -- get control parameters - if freq ~= ctrl[1] or bw ~= ctrl[2] then + if freq ~= ctrl[1] or qual ~= ctrl[2] then freq = ctrl[1] - bw = ctrl[2] - for i = 1,20 do - filters[i]:compute (ARDOUR.DSP.BiquadType.Notch, freq * i, bw, 0) + qual = ctrl[2] + for c = 1, chn do + for i = 1, max_stages do + filters[c][i]:compute (ARDOUR.DSP.BiquadType.Notch, freq * i, qual, 0) + end end end - if not ins[1]:sameinstance (outs[1]) then - ARDOUR.DSP.copy_vector (outs[1], outs[1], n_samples) - end - + local limit = math.floor (sample_rate / ( 2 * freq )) local stages = math.floor (ctrl['3']) - if stages < 1 then stages = 1; end - if stages > 20 then stages = 20; end + if stages < 1 then stages = 1 end + if stages > max_stages then stages = max_stages end + if stages > limit then stages = limit end + + -- process all channels + for c = 1, chn do + if not ins[c]:sameinstance (outs[c]) then + ARDOUR.DSP.copy_vector (outs[c], outs[c], n_samples) + end - for i = 1, stages do - filters[i]:run (outs[1], n_samples) + for i = 1, stages do + filters[c][i]:run (outs[c], n_samples) + end end end