Mach1 Spatial SDK
Loading...
Searching...
No Matches
M1DSPFilters.h
1
// Mach1 Spatial SDK
2
// Copyright © 2017 Mach1. All rights reserved.
3
4
#pragma once
5
6
#include <math.h>
7
#include <vector>
8
9
namespace
M1DSP {
10
namespace
Filters {
11
class
CFilterSimpleLP
{
12
public
:
13
void
Setup(
int
cutoff_frequency,
double
resonance);
14
void
SetSampleRate(
double
fs);
// TODO: move to global SetSampleRate(double) function
15
double
Run(
double
in);
16
17
private
:
18
int
sample_rate;
19
int
cutoff_frequency;
20
double
resonance;
21
double
in1;
22
double
in2;
23
double
out1;
24
double
out2;
25
};
26
27
class
CFilterButterworth24db
{
28
public
:
29
CFilterButterworth24db
(
void
);
30
~CFilterButterworth24db
(
void
);
31
void
SetSampleRate(
double
fs);
// TODO: move to global SetSampleRate(double) function
32
void
Setup(
double
cutoff,
double
q);
33
double
Run(
double
input);
34
35
private
:
36
double
t0, t1, t2, t3;
37
double
coef0, coef1, coef2, coef3;
38
double
history1, history2, history3, history4;
39
double
gain;
40
double
min_cutoff, max_cutoff;
41
};
42
43
class
CFilterLowPass
{
44
private
:
45
double
y, a, s;
46
bool
initialized;
47
48
void
setAlpha(
double
alpha);
49
50
public
:
51
CFilterLowPass
(
double
alpha,
double
initval = 0.0);
52
double
Run(
double
input);
53
double
filterWithAlpha(
double
value,
double
alpha);
54
bool
hasLastRawValue(
void
);
55
double
lastRawValue(
void
);
56
};
57
58
class
CFilterOneEuro
{
59
public
:
60
CFilterOneEuro
(
void
);
61
~CFilterOneEuro
(
void
);
62
void
Setup(
double
mincutoff = 1.0,
double
beta_ = 0.0,
double
dcutoff = 1.0);
63
void
SetSampleRate(
double
fs);
// TODO: move to global SetSampleRate(double) function
64
double
Run(
double
input);
65
66
private
:
67
double
freq;
68
double
mincutoff;
69
double
beta_;
70
double
dcutoff;
71
CFilterLowPass
*x;
72
CFilterLowPass
*dx;
73
74
double
alpha(
double
cutoff);
75
void
setMinCutoff(
double
mc);
76
void
setBeta(
double
b);
77
void
setDerivateCutoff(
double
dc);
78
};
79
}
// namespace Filters
80
}
// namespace M1DSP
M1DSP::Filters::CFilterButterworth24db
Definition
M1DSPFilters.h:27
M1DSP::Filters::CFilterLowPass
Definition
M1DSPFilters.h:43
M1DSP::Filters::CFilterOneEuro
Definition
M1DSPFilters.h:58
M1DSP::Filters::CFilterSimpleLP
Definition
M1DSPFilters.h:11
libmach1spatial
deps
M1DSP
M1DSPFilters.h
Generated by
1.9.8