-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbbd_filter.h
More file actions
50 lines (44 loc) · 1.2 KB
/
bbd_filter.h
File metadata and controls
50 lines (44 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <memory>
#include <complex>
typedef std::complex<double> cdouble;
enum class BBD_Filter_Kind {
Input,
Output,
};
/*
Analog specifications of BBD filters, input and output.
M=order R=numerator P=denominator
Analog transfer: H(s)=sum(m:1→M) (R[m]/(s-P[m]))
*/
struct BBD_Filter_Spec {
BBD_Filter_Kind kind;
unsigned M;
const cdouble *R;/*[M]*/
const cdouble *P;/*[M]*/
//
cdouble transfer(double frequency) const noexcept;
};
/*
Discretized matrix of filters coefficients.
M=order, N=interpolation steps, H=feedback factor
*/
struct BBD_Filter_Coef {
unsigned M;
unsigned N;
std::unique_ptr<cdouble[]> G;/*[M*N]*/
std::unique_ptr<cdouble[]> P;/*[M]*/
double H;
//
void interpolate_G(double d, cdouble *g/*[M]*/) const noexcept;
};
namespace BBD {
BBD_Filter_Coef compute_filter(float fs, unsigned steps, const BBD_Filter_Spec &spec);
const BBD_Filter_Coef &compute_filter_cached(float fs, unsigned steps, const BBD_Filter_Spec &spec);
void clear_filter_cache();
} // namespace BBD
/*
The model of BBD input and output filters from Juno 60.
*/
extern const BBD_Filter_Spec bbd_fin_j60;
extern const BBD_Filter_Spec bbd_fout_j60;