-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCascadeFilters.h
38 lines (32 loc) · 1.02 KB
/
CascadeFilters.h
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
#ifndef FILTERS_H
#define FILTERS_H
#include <stdint.h>
#include <stdbool.h>
#define FILTER_ORDER_MAX 6
typedef enum {
FILTER_TYPE_HIGHPASS,
FILTER_TYPE_LOWPASS,
FILTER_TYPE_BANDPASS,
FILTER_TYPE_BANDSTOP
} FilterType;
typedef struct {
FilterType type;
int numberOfFilters;
double highPassInputs[FILTER_ORDER_MAX]; // Inputs for high-pass filter
double highPassOutputs[FILTER_ORDER_MAX]; // Outputs for high-pass filter
double lowPassInputs[FILTER_ORDER_MAX]; // Inputs for low-pass filter
double lowPassOutputs[FILTER_ORDER_MAX]; // Outputs for low-pass filter
double highPassCoefficient;
double lowPassCoefficient;
} FilterCascade;
// Filter functions
void filterCascadeInitialise(
FilterCascade* cascade,
FilterType type,
int numberOfFilters,
double centerFrequency,
double bandwidth,
double sampleFrequency);
double filterCascadeUpdate(FilterCascade* cascade, double input);
void filterCascadeReset(FilterCascade* cascade);
#endif // FILTERS_H