Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
Main Page
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
libraries
Biquad
Biquad.h
1
// This code is based on the code credited below, but it has been modified further
2
//
3
// Biquad.h
4
//
5
// Created by Nigel Redmon on 11/24/12
6
// EarLevel Engineering: earlevel.com
7
// Copyright 2012 Nigel Redmon
8
//
9
// For a complete explanation of the Biquad code:
10
// http://www.earlevel.com/main/2012/11/25/biquad-c-source-code/
11
//
12
// License:
13
//
14
// This source code is provided as is, without warranty.
15
// You may copy and distribute verbatim copies of this document.
16
// You may modify and use this source code to create binary code
17
// for your own purposes, free or commercial.
18
//
19
20
#pragma once
21
25
class
Biquad
{
26
public
:
27
typedef
enum
28
{
29
lowpass,
30
highpass,
31
bandpass,
32
notch,
33
peak,
34
lowshelf,
35
highshelf
36
} Type;
37
struct
Settings
{
38
double
fs
;
39
Type
type
;
40
double
cutoff
;
41
double
q
;
42
double
peakGainDb
;
43
};
44
Biquad
();
45
Biquad
(
const
Settings
& settings);
46
~
Biquad
();
47
int
setup(
const
Settings
& settings);
48
52
float
process
(
float
in);
53
57
void
clean
();
58
59
void
setType(Type type);
60
void
setQ(
double
Q);
61
void
setFc(
double
Fc);
62
void
setPeakGain(
double
peakGainDB);
63
64
Type getType();
65
double
getQ();
66
double
getFc();
67
double
getPeakGain();
68
69
double
getStartingQ();
70
double
getStartingFc();
71
double
getStartingPeakGain();
72
73
protected
:
74
void
calcBiquad(
void
);
75
76
Type type;
77
double
a0, a1, a2, b1, b2;
78
double
Fc, Q, peakGain;
79
double
Fs;
80
double
startFc, startQ, startPeakGain;
81
double
z1, z2;
82
};
83
84
inline
float
Biquad::process
(
float
in) {
85
double
out = in * a0 + z1;
86
z1 = in * a1 + z2 - b1 * out;
87
z2 = in * a2 - b2 * out;
88
return
out;
89
}
Biquad::process
float process(float in)
Definition:
Biquad.h:84
Biquad::Settings::type
Type type
Filter type.
Definition:
Biquad.h:39
Biquad::Settings::peakGainDb
double peakGainDb
Maximum filter gain.
Definition:
Biquad.h:42
Biquad::Settings::fs
double fs
Sample rate in Hz.
Definition:
Biquad.h:38
Biquad::clean
void clean()
Definition:
Biquad.cpp:65
Biquad
Definition:
Biquad.h:25
Biquad::Settings
Definition:
Biquad.h:37
Biquad::Settings::cutoff
double cutoff
Cutoff in Hz.
Definition:
Biquad.h:40
Biquad::Settings::q
double q
Quality factor.
Definition:
Biquad.h:41
Generated on Tue Jan 19 2021 10:08:06 for Bela by
1.8.6