13
0

Add API to copy Biquad parameters

This is handy for stereo or higher-order plugin configurations,
the coefficients have to be calculated only once.
This commit is contained in:
Robin Gareus 2022-04-02 19:10:08 +02:00
parent b411eeb74e
commit a946046532
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 14 additions and 1 deletions

View File

@ -248,6 +248,9 @@ namespace ARDOUR { namespace DSP {
/** setup filter, set coefficients directly */
void configure (double a1, double a2, double b0, double b1, double b2);
/* copy coefficients from other instance, retain state */
void configure (Biquad const&);
/** filter transfer function (filter response for spectrum visualization)
* @param freq frequency
* @return gain at given frequency in dB (clamped to -120..+120)

View File

@ -196,6 +196,16 @@ Biquad::configure (double a1, double a2, double b0, double b1, double b2)
_b2 = b2;
}
void
Biquad::configure (Biquad const& other)
{
_a1 = other._a1;
_a2 = other._a2;
_b0 = other._b0;
_b1 = other._b1;
_b2 = other._b2;
}
void
Biquad::compute (Type type, double freq, double Q, double gain)
{

View File

@ -2790,7 +2790,7 @@ LuaBindings::common (lua_State* L)
.addConstructor <void (*) (double)> ()
.addFunction ("run", &DSP::Biquad::run)
.addFunction ("compute", &DSP::Biquad::compute)
.addFunction ("configure", &DSP::Biquad::configure)
.addFunction ("configure", (void (DSP::Biquad::*) (DSP::Biquad const&))&DSP::Biquad::configure)
.addFunction ("reset", &DSP::Biquad::reset)
.addFunction ("dB_at_freq", &DSP::Biquad::dB_at_freq)
.endClass ()