minilogue xd SDK  v1.1-0
Public Member Functions | Public Attributes | List of all members
dsp::ExtBiQuad Struct Reference

Extended transposed form 2 Bi-Quad construct. More...

#include <biquad.hpp>

Public Member Functions

 ExtBiQuad (void)
 Default constructor.
 
void flush (void)
 Flush internal delays.
 
float process_so (const float xn)
 Second order processing of one sample. More...
 
float process_fo (const float xn)
 First order processing of one sample. More...
 
float process (const float xn)
 Default processing function (second order) More...
 
void setFOAPLP (const float k)
 Calculate coefficients for "invertable" all pass based low pass filter. More...
 
void setFOAPHP (const float k)
 Calculate coefficients for "invertable" all pass based high pass filter. More...
 
void toggleFOLPHP (void)
 Toggle "invertable" all pass based low/high pass filter to opposite mode.
 
void updateFOLPHP (const float k)
 Update "invertable" all pass based low/high pass filter coefficients. More...
 
void setFOLS (const float k, const float gain)
 Calculate coefficients for first order all pass based low shelf filter. More...
 
void setFOHS (const float k, const float gain)
 Calculate coefficients for first order all pass based high shelf filter. More...
 
void setSOAPBR2 (const float delta, const float gamma)
 Calculate coefficients for second order all pass based band reject filter. More...
 
void setSOAPBP2 (const float delta, const float gamma)
 Calculate coefficients for second order all pass based band pass filter. More...
 
void setSOAPPN2 (const float delta, const float gamma, const float gain)
 Calculate coefficients for second order all pass based peak/notch filter. More...
 

Public Attributes

BiQuad::Coeffs mCoeffs
 Coefficients for the Bi-Quad construct.
 
float mD0
 
float mD1
 
float mW0
 
float mW1
 
float mZ1
 
float mZ2
 

Detailed Description

Extended transposed form 2 Bi-Quad construct.

Definition at line 415 of file biquad.hpp.

Member Function Documentation

◆ process()

float dsp::ExtBiQuad::process ( const float  xn)
inline

Default processing function (second order)

Parameters
xnInput sample
Returns
Output sample

Definition at line 487 of file biquad.hpp.

487  {
488  return process_so(xn);
489  }

◆ process_fo()

float dsp::ExtBiQuad::process_fo ( const float  xn)
inline

First order processing of one sample.

Parameters
xnInput sample
Returns
Output sample

Definition at line 472 of file biquad.hpp.

472  {
473  float acc = mCoeffs.ff0 * xn + mZ1;
474  mZ1 = mCoeffs.ff1 * xn;
475  mZ1 -= mCoeffs.fb1 * acc;
476  return mW1 * (mW0 * acc + mD0 * xn) + mD1 * xn;
477  }

◆ process_so()

float dsp::ExtBiQuad::process_so ( const float  xn)
inline

Second order processing of one sample.

Parameters
xnInput sample
Returns
Output sample

Definition at line 455 of file biquad.hpp.

455  {
456  float acc = mCoeffs.ff0 * xn + mZ1;
457  mZ1 = mCoeffs.ff1 * xn + mZ2;
458  mZ2 = mCoeffs.ff2 * xn;
459  mZ1 -= mCoeffs.fb1 * acc;
460  mZ2 -= mCoeffs.fb2 * acc;
461  return mW1 * (mW0 * acc + mD0 * xn) + mD1 * xn;
462  }

◆ setFOAPHP()

void dsp::ExtBiQuad::setFOAPHP ( const float  k)
inline

Calculate coefficients for "invertable" all pass based high pass filter.

Parameters
kTangent of PI x cutoff frequency in radians: tan(pi*wc)

Definition at line 513 of file biquad.hpp.

513  {
514  // k = tan(pi*wc)
515  mCoeffs.setFOAP(k);
516  mD0 = 0.5f;
517  mW0 = -0.5f;
518  mD1 = 0.f;
519  mW1 = 1.f;
520  }

◆ setFOAPLP()

void dsp::ExtBiQuad::setFOAPLP ( const float  k)
inline

Calculate coefficients for "invertable" all pass based low pass filter.

Parameters
kTangent of PI x cutoff frequency in radians: tan(pi*wc)

Definition at line 499 of file biquad.hpp.

499  {
500  // k = tan(pi*wc)
501  mCoeffs.setFOAP(k);
502  mD0 = mW0 = 0.5f;
503  mD1 = 0.f;
504  mW1 = 1.f;
505  }

◆ setFOHS()

void dsp::ExtBiQuad::setFOHS ( const float  k,
const float  gain 
)
inline

Calculate coefficients for first order all pass based high shelf filter.

Parameters
kTangent of PI x cutoff frequency in radians: tan(pi*wc)
gain10^(gain_db/20)

Definition at line 572 of file biquad.hpp.

572  {
573  // k = tan(pi*wc)
574  // gain = raw amplitude (pre converted from dB)
575  const float h = gain - 1.f;
576  const float gk = (gain >= 1.f) ? k : gain*k;
577  mCoeffs.ff0 = mCoeffs.fb1 = (gk - 1.f) / (gk + 1);
578  mCoeffs.ff1 = 1.f;
579  mCoeffs.fb2 = mCoeffs.ff2 = 0.f;
580 
581  mW0 = -1.f;
582  mD0 = 1.f;
583 
584  mW1 = 0.5f * h;
585  mD1 = 1.f;
586  }

◆ setFOLS()

void dsp::ExtBiQuad::setFOLS ( const float  k,
const float  gain 
)
inline

Calculate coefficients for first order all pass based low shelf filter.

Parameters
kTangent of PI x cutoff frequency in radians: tan(pi*wc)
gain10^(gain_db/20)

Definition at line 549 of file biquad.hpp.

549  {
550  // k = tan(pi*wc)
551  // gain = raw amplitude (pre converted from dB)
552  const float h = gain - 1.f;
553  const float g = (gain >= 1.f) ? 1.f : gain;
554  mCoeffs.ff0 = mCoeffs.fb1 = (k - g) / (k + g);
555  mCoeffs.ff1 = 1.f;
556  mCoeffs.fb2 = mCoeffs.ff2 = 0.f;
557 
558  mW0 = 1.f;
559  mD0 = 1.f;
560 
561  mW1 = 0.5f * h;
562  mD1 = 1.f;
563  }

◆ setSOAPBP2()

void dsp::ExtBiQuad::setSOAPBP2 ( const float  delta,
const float  gamma 
)
inline

Calculate coefficients for second order all pass based band pass filter.

Parameters
deltacos(2pi*wc)
gammatan(pi * wb)
Note
q is inverse of relative bandwidth (wc / wb)

Definition at line 621 of file biquad.hpp.

621  {
622  // Alternative implementation based on second order tunable all pass
623  // delta = cos(2pi*wc)
624  mCoeffs.setSOAP2(delta, gamma);
625 
626  mW0 = -1.f;
627  mD0 = 1.f;
628 
629  mW1 = 0.5f;
630  mD1 = 0.f;
631  }

◆ setSOAPBR2()

void dsp::ExtBiQuad::setSOAPBR2 ( const float  delta,
const float  gamma 
)
inline

Calculate coefficients for second order all pass based band reject filter.

Parameters
deltacos(2pi*wc)
gammatan(pi * wb)
Note
q is inverse of relative bandwidth (wc / wb)

Definition at line 600 of file biquad.hpp.

600  {
601  // Alternative implementation based on second order tunable all pass
602  // delta = cos(2pi*wc)
603  mCoeffs.setSOAP2(delta, gamma);
604 
605  mW0 = 1.f;
606  mD0 = 1.f;
607 
608  mW1 = 0.5f;
609  mD1 = 0.f;
610  }

◆ setSOAPPN2()

void dsp::ExtBiQuad::setSOAPPN2 ( const float  delta,
const float  gamma,
const float  gain 
)
inline

Calculate coefficients for second order all pass based peak/notch filter.

Parameters
deltacos(2pi*wc)
gammatan(pi * wb)
gain10^(gain_db/20)
Note
q is inverse of relative bandwidth (wc / wb)

Definition at line 644 of file biquad.hpp.

644  {
645  // Alternative implementation based on second order tunable all pass
646  // delta = cos(2pi*wc)
647 
648  const float h = gain - 1.f;
649  const float g = (gain >= 1.f) ? 1.f : gain;
650 
651  const float c = (gamma - g) / (gamma + g);
652  const float d = -delta;
653 
654  mCoeffs.ff0 = mCoeffs.fb2 = -c;
655  mCoeffs.ff1 = mCoeffs.fb1 = d * (1.f - c);
656  mCoeffs.ff2 = 1.f;
657 
658  mW0 = -1.f;
659  mD0 = 1.f;
660 
661  mW1 = 0.5f * h;
662  mD1 = 1.f;
663  }

◆ updateFOLPHP()

void dsp::ExtBiQuad::updateFOLPHP ( const float  k)
inline

Update "invertable" all pass based low/high pass filter coefficients.

Agnostic from current mode.

Parameters
kTangent of PI x cutoff frequency in radians: tan(pi*wc)

Definition at line 536 of file biquad.hpp.

536  {
537  mCoeffs.setFOAP(k);
538  }

The documentation for this struct was generated from the following file:
dsp::ExtBiQuad::process_so
float process_so(const float xn)
Second order processing of one sample.
Definition: biquad.hpp:455
dsp::ExtBiQuad::mCoeffs
BiQuad::Coeffs mCoeffs
Coefficients for the Bi-Quad construct.
Definition: biquad.hpp:670
dsp::BiQuad::Coeffs::setSOAP2
void setSOAP2(const float delta, const float gamma)
Calculate coefficients for second order all pass filter.
Definition: biquad.hpp:306
dsp::BiQuad::Coeffs::setFOAP
void setFOAP(const float k)
Calculate coefficients for first order all pass filter.
Definition: biquad.hpp:168