Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Convolver.h
1 #define ENABLE_NE10_FIR_FLOAT_NEON // Define needed for Ne10 library
2 #include <libraries/ne10/NE10.h> // neon library
3 #include <vector>
4 
6 {
7 public:
8  ConvolverChannel(const std::vector<float>& ir, unsigned int blockSize) {setup(ir, blockSize);};
9  int setup(const std::vector<float>& ir, unsigned int blockSize);
10  void process(ne10_float32_t* filterOut, const ne10_float32_t* filterIn);
11  void cleanup();
12 private:
13  ne10_fir_instance_f32_t firFilter;
14  unsigned int blockSize;
15  ne10_float32_t* firFilterCoeff = nullptr;
16  ne10_float32_t* firFilterState = nullptr;
17 };
18 
19 #include <string>
24 class Convolver
25 {
26 public:
27  Convolver() {};
28  ~Convolver() { cleanup(); };
39  int setup(const std::string& filename, unsigned int blockSize, unsigned int maxLength = 0);
48  int setup(const std::vector<std::vector<float>>& irs, unsigned int blockSize);
57  void process(float* out, const float* in, unsigned int frames, unsigned int channel = 0);
69  void processInterleaved(float* out, const float* in, unsigned int frames, unsigned int outChannels, unsigned int inChannels);
70  void cleanup();
74  unsigned int getChannels() { return convolverChannels.size(); }
75 private:
76  void doProcessInterleaved(float* out, const float* in, unsigned int frames, unsigned int outChannels, unsigned int inChannels, unsigned int channel);
77  std::vector<ConvolverChannel> convolverChannels;
78  ne10_float32_t* filterIn = nullptr;
79  ne10_float32_t* filterOut = nullptr;
80 };
int setup(const std::string &filename, unsigned int blockSize, unsigned int maxLength=0)
Definition: Convolver.cpp:37
void processInterleaved(float *out, const float *in, unsigned int frames, unsigned int outChannels, unsigned int inChannels)
Definition: Convolver.cpp:74
Definition: Convolver.h:24
Definition: Convolver.h:5
unsigned int getChannels()
Definition: Convolver.h:74
void process(float *out, const float *in, unsigned int frames, unsigned int channel=0)
Definition: Convolver.cpp:69