BIQUADQ15.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #include "BIQUADQ15.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. /*
  5. Accuracy issues on biquad df1 q15
  6. It will have to be reworked
  7. */
  8. #define SNR_THRESHOLD 30
  9. #define ABS_ERROR_Q15 ((q15_t)500)
  10. void BIQUADQ15::test_biquad_cascade_df1()
  11. {
  12. q15_t *statep = state.ptr();
  13. const q15_t *coefsp = coefs.ptr();
  14. const q15_t *inputp = inputs.ptr();
  15. q15_t *outp = output.ptr();
  16. int blockSize;
  17. /*
  18. Python script is generating different tests with
  19. different blockSize and numTaps.
  20. We loop on those configs.
  21. */
  22. blockSize = inputs.nbSamples() >> 1;
  23. /*
  24. The filter is initialized with the coefs, blockSize and numTaps.
  25. */
  26. arm_biquad_cascade_df1_init_q15(&this->S,3,coefsp,statep,2);
  27. /*
  28. Python script is filtering a 2*blockSize number of samples.
  29. We do the same filtering in two pass to check (indirectly that
  30. the state management of the fir is working.)
  31. */
  32. arm_biquad_cascade_df1_q15(&this->S,inputp,outp,blockSize);
  33. outp += blockSize;
  34. inputp += blockSize;
  35. arm_biquad_cascade_df1_q15(&this->S,inputp,outp,blockSize);
  36. outp += blockSize;
  37. ASSERT_EMPTY_TAIL(output);
  38. ASSERT_SNR(output,ref,(q15_t)SNR_THRESHOLD);
  39. ASSERT_NEAR_EQ(output,ref,ABS_ERROR_Q15);
  40. }
  41. void BIQUADQ15::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  42. {
  43. (void)params;
  44. switch(id)
  45. {
  46. case BIQUADQ15::TEST_BIQUAD_CASCADE_DF1_1:
  47. break;
  48. }
  49. inputs.reload(BIQUADQ15::BIQUADINPUTS_Q15_ID,mgr);
  50. coefs.reload(BIQUADQ15::BIQUADCOEFS_Q15_ID,mgr);
  51. ref.reload(BIQUADQ15::BIQUADREFS_Q15_ID,mgr);
  52. output.create(ref.nbSamples(),BIQUADQ15::OUT_Q15_ID,mgr);
  53. /* max 4 * nbTaps as generated by Python script */
  54. /* Same OUTID is reused. So linked to same output file. If it is dumped
  55. it may overwrite the output
  56. */
  57. state.create(32,BIQUADQ15::OUT_Q15_ID,mgr);
  58. }
  59. void BIQUADQ15::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  60. {
  61. (void)id;
  62. output.dump(mgr);
  63. }