mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 00:34:59 +01:00
update notch-bank to variable i/o, increase max stages to 100
This commit is contained in:
parent
c6ef3a75d3
commit
798cd4831b
1 changed files with 38 additions and 18 deletions
|
|
@ -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
|
||||
|
||||
for i = 1, stages do
|
||||
filters[i]:run (outs[1], n_samples)
|
||||
-- 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[c][i]:run (outs[c], n_samples)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue