Listing 5
#include <math.h>
#define NULL 0
#ifndef M_LN2
#define M_LN2 0.69314718055994530942
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
/* whatever sample type you want */
typedef double smp_type;
/* this holds the data required to update samples thru a filter */
typedef struct {
smp_type a0, a1, a2, a3, a4;
smp_type x1, x2, y1, y2;
}
biquad;
extern smp_type BiQuad(smp_type sample, biquad * b);
extern biquad *BiQuad_new(int type, smp_type dbGain, /* gain of filter */
smp_type freq, /* center frequency */
smp_type srate, /* sampling rate */
smp_type BW_Q_SH, /* bandwidth in octaves, Q or Shelving parameter */
smp_type S); /* shelf rate */
/* filter types */
enum {
LPF, /* low pass filter */
HPF, /* High pass filter */
BPFA, /* band pass filter - constant 0 dB peak gain */
BPFB, /* constant skirt gain, peak gain = Q */
NOTCH, /* Notch Filter */
APF, /* all pass filter */
PEQ, /* Peaking band EQ filter */
LSH, /* Low shelf filter */
HSH /* High shelf filter */
};