Release notch-bank filter
This commit is contained in:
parent
6edc919656
commit
0a9674ec6b
@ -1,15 +1,15 @@
|
||||
ardour {
|
||||
["type"] = "dsp",
|
||||
name = "Notch Bank",
|
||||
category = "Example",
|
||||
name = "a-Notch Bank",
|
||||
category = "Filter",
|
||||
license = "MIT",
|
||||
author = "Ardour Lua Task Force",
|
||||
description = [[An Example Filter Plugin]]
|
||||
description = [[Notch Filter Bank; useful to remove noise with a harmonic spectum (e.g, mains hum, GSM signals, charge-pump noise, etc).
|
||||
Note: this plugin is not suitable to be automated, it is intended for static noise only.]]
|
||||
}
|
||||
|
||||
-------------------------------------------------------------------
|
||||
-- this is a quick/dirty example filter: no de-click, no de-zipper,
|
||||
-- no latency reporting,...
|
||||
------------------------------------------------------------------
|
||||
-- this is a quick/dirty example filter: no de-click, no de-zipper
|
||||
-------------------------------------------------------------------
|
||||
|
||||
-- configuration
|
||||
@ -28,23 +28,22 @@ end
|
||||
function dsp_params ()
|
||||
return
|
||||
{
|
||||
{ ["type"] = "input", name = "Base Freq", min = 10, max = 1000, default = 100, unit="Hz", logarithmic = true },
|
||||
{ ["type"] = "input", name = "Base Freq", min = 10, max = 2000, default = 100, unit="Hz", logarithmic = true },
|
||||
{ ["type"] = "input", name = "Quality", min = 1.0, max = 100.0, default = 8.0, logarithmic = true },
|
||||
{ ["type"] = "input", name = "Stages", min = 1.0, max = max_stages, default = 8.0, integer = true },
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
-- plugin instance state
|
||||
local filters = {} -- the biquad filter instances
|
||||
local chn = 0 -- configured channel count
|
||||
local sample_rate = 0 -- configured sample-rate
|
||||
local limit = 0 -- max number of stages (given freq & sample-rate)
|
||||
|
||||
-- cached control ports (keep track of changed)
|
||||
local freq = 0
|
||||
local qual = 0
|
||||
|
||||
|
||||
-- dsp_init is called once when instantiating the plugin
|
||||
function dsp_init (rate)
|
||||
-- remember the sample-rate
|
||||
@ -56,6 +55,10 @@ end
|
||||
function dsp_configure (ins, outs)
|
||||
assert (ins:n_audio () == outs:n_audio ())
|
||||
|
||||
-- explicit cleanup
|
||||
filters = {}
|
||||
collectgarbage ()
|
||||
|
||||
-- remember audio-channels
|
||||
chn = ins:n_audio ()
|
||||
|
||||
@ -68,7 +71,6 @@ function dsp_configure (ins, outs)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- the actual process function, called every cycle
|
||||
-- ins, outs are audio-data arrays
|
||||
-- http://manual.ardour.org/lua-scripting/class_reference/#C:FloatArray
|
||||
@ -79,31 +81,33 @@ function dsp_run (ins, outs, n_samples)
|
||||
-- ...and matches the configured number of channels
|
||||
assert (#ins == chn)
|
||||
|
||||
local ctrl = CtrlPorts:array() -- get control parameters as array
|
||||
-- ctrl[1] .. corresponds to the parameters given in in dsp_params()
|
||||
local ctrl = CtrlPorts:array () -- get control parameters as array
|
||||
-- ctrl[] .. correspond to the parameters given in in dsp_params()
|
||||
|
||||
-- test if the plugin-parameters have changed
|
||||
if freq ~= ctrl[1] or qual ~= ctrl[2] then
|
||||
-- remember current settings
|
||||
freq = ctrl[1]
|
||||
qual = ctrl[2]
|
||||
-- calc max number of states to configure/process
|
||||
limit = math.floor (sample_rate / (2 * freq)) -- at most up to SR / 2
|
||||
if limit > max_stages then limit = max_stages end
|
||||
|
||||
-- re-compute the filter coefficients for all filters
|
||||
for c = 1, chn do -- for each channel
|
||||
for i = 1, max_stages do -- and for each filter stage
|
||||
-- the parameters are type, frequency, quality(bandwidth), gain
|
||||
for i = 1, limit do -- and for each filter stage
|
||||
-- see http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:DSP:Biquad
|
||||
-- for a list of available types, see
|
||||
-- and for a list of available types, see
|
||||
-- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR.DSP.Biquad.Type
|
||||
-- the parameters are type, frequency, quality(bandwidth), gain
|
||||
filters[c][i]:compute (ARDOUR.DSP.BiquadType.Notch, freq * i, qual * i, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- limit the number of process stages
|
||||
local limit = math.floor (sample_rate / ( 2 * freq )) -- at most up to SR / 2
|
||||
local stages = math.floor (ctrl['3']) -- current user-set parameter
|
||||
if stages < 1 then stages = 1 end -- at least one stage...
|
||||
if stages > max_stages then stages = max_stages end
|
||||
if stages > limit then stages = limit end
|
||||
|
||||
-- process all channels
|
Loading…
Reference in New Issue
Block a user