Peaking Filter

Overview

Peaking second-order IIR (Infinite Impulse Response) filter. This filter is embodied by the peaking class.

Include

#include <q/fx/biquad.hpp>

Declaration

struct bw (1)
{
   double val; // in octaves
};

struct peaking : biquad
{
         peaking(double db_gain, frequency f, float sps, bw _bw);
         peaking(double db_gain, frequency f, float sps, double q = 0.707);

   void  config(double db_gain, frequency f, float sps, bw _bw);
   void  config(double db_gain, frequency f, float sps, double q = 0.707);
};
1 Utility type to distinguish bandwidth from q, which is just a double.

Expressions

In addition to valid expressions for biquad, peaking allows these expressions.

Notation

bf

Object of type peaking.

f

Object of type frequency.

sps

Floating point value representing samples per second.

b

Floating point value for bandwidth (in octaves).

q

Floating point value for Q or quality factor.

g

Floating point value for gain (in decibels).

a [, b, c, d]

Required a, optional b, c, d.

Constructors

Expression Semantics

peaking(g, f, sps [, q])

Construct a peaking filter from g, f, sps and optional q (defaults to 0.707).

peaking(g, f, sps, bw{b})

Construct a peaking filter from g, f, sps and b (bandwidth).

C++ brace initialization may also be used.

Mutators

Expression Semantics Return Type

bf.config(g, f, sps [, q])

Configure a peaking filter from g, f, sps and optional q (defaults to 0.707).

void

bf.config(g, f, sps, bw{b})

Configure a peaking filter from g, f, sps and b (bandwidth).

void

Example

Boost the input samples in, at sps samples per second, by 6 dB around 2 kHz:

namespace q = cycfi::q;
using namespace q::literals;

auto bf = q::peaking{6.0, 2_kHz, sps, q::bw{1.0}};       (1)

for (auto& s : in)
   s = bf(s);                                            (2)
1 Construct a peaking filter with a 6 dB boost centered at 2 kHz, one octave wide.
2 Filter the sample in place.