Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
Loading...
Searching...
No Matches
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
6class ConvolverChannel
7{
8public:
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();
13private:
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>
25class Convolver
26{
27public:
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(); }
76private:
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 process(float *out, const float *in, unsigned int frames, unsigned int channel=0)
Definition Convolver.cpp:69
unsigned int getChannels()
Definition Convolver.h:75
void processInterleaved(float *out, const float *in, unsigned int frames, unsigned int outChannels, unsigned int inChannels)
Definition Convolver.cpp:74