No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

43 líneas
1.1KB

  1. #ifndef filter_fir_h_
  2. #define filter_fir_h_
  3. #include "AudioStream.h"
  4. #include "arm_math.h"
  5. // Maximum number of coefficients in a FIR filter
  6. // The audio breaks up with 128 coefficients so a
  7. // maximum of 150 is more than sufficient
  8. #define MAX_COEFFS 150
  9. // Indicates that the code should just pass through the audio
  10. // without any filtering (as opposed to doing nothing at all)
  11. #define FIR_PASSTHRU ((short *) 1)
  12. class AudioFilterFIR :
  13. public AudioStream
  14. {
  15. public:
  16. AudioFilterFIR(void):
  17. AudioStream(2,inputQueueArray), coeff_p(NULL)
  18. {
  19. }
  20. void begin(short *coeff_p,int f_pin);
  21. virtual void update(void);
  22. void stop(void);
  23. private:
  24. audio_block_t *inputQueueArray[2];
  25. // arm state arrays and FIR instances for left and right channels
  26. // the state arrays are defined to handle a maximum of MAX_COEFFS
  27. // coefficients in a filter
  28. q15_t l_StateQ15[AUDIO_BLOCK_SAMPLES + MAX_COEFFS];
  29. q15_t r_StateQ15[AUDIO_BLOCK_SAMPLES + MAX_COEFFS];
  30. arm_fir_instance_q15 l_fir_inst;
  31. arm_fir_instance_q15 r_fir_inst;
  32. // pointer to current coefficients or NULL or FIR_PASSTHRU
  33. short *coeff_p;
  34. };
  35. #endif