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