Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

42 lines
1.1KB

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