XCORE SDK
XCORE Software Development Kit
SampleFilter.hpp
1 // Copyright 2022 XMOS LIMITED.
2 // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 
4 #pragma once
5 
6 #include <cstdint>
7 #include <string>
8 #include <cassert>
9 #include <iostream>
10 #include <type_traits>
11 #include <functional>
12 
13 #include <xcore/channel.h>
14 
15 // This has caused problems previously, so just catch the problems here.
16 #if defined(MIC_COUNT)
17 # error Application must not define the following as precompiler macros: MIC_COUNT.
18 #endif
19 
20 using namespace std;
21 
22 namespace mic_array {
23 
32  template<unsigned MIC_COUNT>
34  {
35  public:
39  void Filter(int32_t sample[MIC_COUNT]) {};
40  };
41 
47  template<unsigned MIC_COUNT>
49  {
50 
51  protected:
55  dcoe_chan_state_t state[MIC_COUNT];
56 
57  public:
58 
64  void Init();
65 
77  void Filter(int32_t sample[MIC_COUNT]);
78  };
79 }
80 
82 // Template function implementations below. //
84 
85 
86 template <unsigned MIC_COUNT>
88 {
89  dcoe_state_init(&state[0], MIC_COUNT);
90 }
91 
92 
93 template <unsigned MIC_COUNT>
95  int32_t sample[MIC_COUNT])
96 {
97  dcoe_filter(&sample[0], &state[0], &sample[0], MIC_COUNT);
98 }
Filter which applies DC Offset Elimination (DCOE).
Definition: SampleFilter.hpp:49
void Init()
Initialize the filter states.
Definition: SampleFilter.hpp:87
void Filter(int32_t sample[MIC_COUNT])
Apply DCOE filter on samples.
Definition: SampleFilter.hpp:94
Filter which does nothing.
Definition: SampleFilter.hpp:34
void Filter(int32_t sample[MIC_COUNT])
Do nothing.
Definition: SampleFilter.hpp:39
void dcoe_state_init(dcoe_chan_state_t state[], const unsigned chan_count)
Initialize DCOE states.
void dcoe_filter(int32_t new_output[], dcoe_chan_state_t state[], int32_t new_input[], const unsigned chan_count)
Apply DCOE filter.
DC Offset Elimination (DCOE) State.
Definition: dc_elimination.h:60