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 #pragma once
2 #define ENABLE_NE10_FIR_FLOAT_NEON // Define needed for Ne10 library
3 #include <libraries/ne10/NE10.h> // neon library
4 #include <vector>
5 
7 {
8 public:
9  ConvolverChannel(const std::vector<float>& ir, unsigned int blockSize) {setup(ir, blockSize);};
10  int setup(const std::vector<float>& ir, unsigned int blockSize);
11  void process(ne10_float32_t* filterOut, const ne10_float32_t* filterIn);
12  void cleanup();
13 private:
14  ne10_fir_instance_f32_t firFilter;
15  unsigned int blockSize;
16  ne10_float32_t* firFilterCoeff = nullptr;
17  ne10_float32_t* firFilterState = nullptr;
18 };
19 
20 #include <string>
25 class Convolver
26 {
27 public:
28  Convolver() {};
29  ~Convolver() { cleanup(); };
40  int setup(const std::string& filename, unsigned int blockSize, unsigned int maxLength = 0);
49  int setup(const std::vector<std::vector<float>>& irs, unsigned int blockSize);
58  void process(float* out, const float* in, unsigned int frames, unsigned int channel = 0);
70  void processInterleaved(float* out, const float* in, unsigned int frames, unsigned int outChannels, unsigned int inChannels);
71  void cleanup();
75  unsigned int getChannels() { return convolverChannels.size(); }
76 private:
77  void doProcessInterleaved(float* out, const float* in, unsigned int frames, unsigned int outChannels, unsigned int inChannels, unsigned int channel);
78  std::vector<ConvolverChannel> convolverChannels;
79  ne10_float32_t* filterIn = nullptr;
80  ne10_float32_t* filterOut = nullptr;
81 };
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:25
Definition: Convolver.h:6
unsigned int getChannels()
Definition: Convolver.h:75
void process(float *out, const float *in, unsigned int frames, unsigned int channel=0)
Definition: Convolver.cpp:69