|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
-
-
- #ifndef filter_fir_h_
- #define filter_fir_h_
-
- #include "AudioStream.h"
- #include "arm_math.h"
-
-
-
- #define FIR_PASSTHRU ((const short *) 1)
-
- #define FIR_MAX_COEFFS 200
-
- class AudioFilterFIR : public AudioStream
- {
- public:
- AudioFilterFIR(void): AudioStream(1,inputQueueArray), coeff_p(NULL) {
- }
- void begin(const short *cp, int n_coeffs) {
- coeff_p = cp;
-
- if (coeff_p && (coeff_p != FIR_PASSTHRU) && n_coeffs <= FIR_MAX_COEFFS) {
- if (arm_fir_init_q15(&fir_inst, n_coeffs, (q15_t *)coeff_p,
- &StateQ15[0], AUDIO_BLOCK_SAMPLES) != ARM_MATH_SUCCESS) {
-
- coeff_p = NULL;
- }
- }
- }
- void end(void) {
- coeff_p = NULL;
- }
- virtual void update(void);
- private:
- audio_block_t *inputQueueArray[1];
-
-
- const short *coeff_p;
-
-
- arm_fir_instance_q15 fir_inst;
- q15_t StateQ15[AUDIO_BLOCK_SAMPLES + FIR_MAX_COEFFS];
- };
-
- #endif
|