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
9namespace M1DSP {
10namespace Filters {
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
28 public:
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
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
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;
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
Definition M1DSPFilters.h:27
Definition M1DSPFilters.h:43
Definition M1DSPFilters.h:58
Definition M1DSPFilters.h:11