void TerminalCmd_aiir(char *arg) { BYTE Items; float b0= 1; float b2 = 0; float b1 = 0; float a1 = 0; float a2 = 0; float Norm = 1; InhibitAudio = TRUE; Items=sscanf(arg,"%f %f %f %f %f %f",&b0,&b1,&b2,&a1,&a2,&Norm); arm_float_to_q31(&b0,&AlphaIIRTaps[0],1); arm_float_to_q31(&b1,&AlphaIIRTaps[1],1); arm_float_to_q31(&b2,&AlphaIIRTaps[2],1); arm_float_to_q31(&a1,&AlphaIIRTaps[3],1); arm_float_to_q31(&a2,&AlphaIIRTaps[4],1); arm_float_to_q31(&Norm,&AlphaIIR_Norm,1); arm_biquad_cas_df1_32x64_init_q31(&MyAlphaIIR,1,&AlphaIIRTaps[0],&AlphaIIRState[0],1); printf_Q(&TERMINAL_OUT_QUEUE,"\r\nSetting Alpha IIR Stage to: \r\n"); printf_Q(&TERMINAL_OUT_QUEUE,"b0: %f \r\n",b0); printf_Q(&TERMINAL_OUT_QUEUE,"b1: %f \r\n",b1); printf_Q(&TERMINAL_OUT_QUEUE,"b2: %f \r\n",b2); printf_Q(&TERMINAL_OUT_QUEUE,"a1: %f \r\n",a1); printf_Q(&TERMINAL_OUT_QUEUE,"a2: %f \r\n",a2); printf_Q(&TERMINAL_OUT_QUEUE,"Norm: %f \r\n",Norm); InhibitAudio = FALSE; }
int32_t main(void) { float32_t *inputF32, *outputF32; arm_biquad_cas_df1_32x64_ins_q31 S1; arm_biquad_cas_df1_32x64_ins_q31 S2; arm_biquad_casd_df1_inst_q31 S3; arm_biquad_casd_df1_inst_q31 S4; arm_biquad_casd_df1_inst_q31 S5; int i; int32_t status; inputF32 = &testInput_f32[0]; outputF32 = &testOutput[0]; /* Initialize the state and coefficient buffers for all Biquad sections */ arm_biquad_cas_df1_32x64_init_q31(&S1, NUMSTAGES, (q31_t *) &coeffTable[190*0 + 10*(gainDB[0] + 9)], &biquadStateBand1Q31[0], 2); arm_biquad_cas_df1_32x64_init_q31(&S2, NUMSTAGES, (q31_t *) &coeffTable[190*1 + 10*(gainDB[1] + 9)], &biquadStateBand2Q31[0], 2); arm_biquad_cascade_df1_init_q31(&S3, NUMSTAGES, (q31_t *) &coeffTable[190*2 + 10*(gainDB[2] + 9)], &biquadStateBand3Q31[0], 2); arm_biquad_cascade_df1_init_q31(&S4, NUMSTAGES, (q31_t *) &coeffTable[190*3 + 10*(gainDB[3] + 9)], &biquadStateBand4Q31[0], 2); arm_biquad_cascade_df1_init_q31(&S5, NUMSTAGES, (q31_t *) &coeffTable[190*4 + 10*(gainDB[4] + 9)], &biquadStateBand5Q31[0], 2); /* Call the process functions and needs to change filter coefficients for varying the gain of each band */ for(i=0; i < NUMBLOCKS; i++) { /* ---------------------------------------------------------------------- ** Convert block of input data from float to Q31 ** ------------------------------------------------------------------- */ arm_float_to_q31(inputF32 + (i*BLOCKSIZE), inputQ31, BLOCKSIZE); /* ---------------------------------------------------------------------- ** Scale down by 1/8. This provides additional headroom so that the ** graphic EQ can apply gain. ** ------------------------------------------------------------------- */ arm_scale_q31(inputQ31, 0x7FFFFFFF, -3, inputQ31, BLOCKSIZE); /* ---------------------------------------------------------------------- ** Call the Q31 Biquad Cascade DF1 32x64 process function for band1, band2 ** ------------------------------------------------------------------- */ arm_biquad_cas_df1_32x64_q31(&S1, inputQ31, outputQ31, BLOCKSIZE); arm_biquad_cas_df1_32x64_q31(&S2, outputQ31, outputQ31, BLOCKSIZE); /* ---------------------------------------------------------------------- ** Call the Q31 Biquad Cascade DF1 process function for band3, band4, band5 ** ------------------------------------------------------------------- */ arm_biquad_cascade_df1_q31(&S3, outputQ31, outputQ31, BLOCKSIZE); arm_biquad_cascade_df1_q31(&S4, outputQ31, outputQ31, BLOCKSIZE); arm_biquad_cascade_df1_q31(&S5, outputQ31, outputQ31, BLOCKSIZE); /* ---------------------------------------------------------------------- ** Convert Q31 result back to float ** ------------------------------------------------------------------- */ arm_q31_to_float(outputQ31, outputF32 + (i * BLOCKSIZE), BLOCKSIZE); /* ---------------------------------------------------------------------- ** Scale back up ** ------------------------------------------------------------------- */ arm_scale_f32(outputF32 + (i * BLOCKSIZE), 8.0f, outputF32 + (i * BLOCKSIZE), BLOCKSIZE); }; snr = arm_snr_f32(testRefOutput_f32, testOutput, TESTLENGTH); if (snr < SNR_THRESHOLD_F32) { status = ARM_MATH_TEST_FAILURE; } else { status = ARM_MATH_SUCCESS; } /* ---------------------------------------------------------------------- ** Loop here if the signal does not match the reference output. ** ------------------------------------------------------------------- */ if( status != ARM_MATH_SUCCESS) { while(1); } while(1); /* main function does not return */ }