1 /****************************************************************************** 2 * @file filtering_functions.h 3 * @brief Public header file for CMSIS DSP Library 4 * @version V1.10.0 5 * @date 08 July 2021 6 * Target Processor: Cortex-M and Cortex-A cores 7 ******************************************************************************/ 8 /* 9 * Copyright (c) 2010-2020 Arm Limited or its affiliates. All rights reserved. 10 * 11 * SPDX-License-Identifier: Apache-2.0 12 * 13 * Licensed under the Apache License, Version 2.0 (the License); you may 14 * not use this file except in compliance with the License. 15 * You may obtain a copy of the License at 16 * 17 * www.apache.org/licenses/LICENSE-2.0 18 * 19 * Unless required by applicable law or agreed to in writing, software 20 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 21 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 22 * See the License for the specific language governing permissions and 23 * limitations under the License. 24 */ 25 26 27 #ifndef _FILTERING_FUNCTIONS_H_ 28 #define _FILTERING_FUNCTIONS_H_ 29 30 #include "arm_math_types.h" 31 #include "arm_math_memory.h" 32 33 #include "dsp/none.h" 34 #include "dsp/utils.h" 35 36 #include "dsp/support_functions.h" 37 #include "dsp/fast_math_functions.h" 38 39 #ifdef __cplusplus 40 extern "C" 41 { 42 #endif 43 44 45 46 #define DELTA_Q31 ((q31_t)(0x100)) 47 #define DELTA_Q15 ((q15_t)0x5) 48 49 /** 50 * @defgroup groupFilters Filtering Functions 51 */ 52 53 /** 54 * @brief Instance structure for the Q7 FIR filter. 55 */ 56 typedef struct 57 { 58 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 59 q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 60 const q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 61 } arm_fir_instance_q7; 62 63 /** 64 * @brief Instance structure for the Q15 FIR filter. 65 */ 66 typedef struct 67 { 68 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 69 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 70 const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 71 } arm_fir_instance_q15; 72 73 /** 74 * @brief Instance structure for the Q31 FIR filter. 75 */ 76 typedef struct 77 { 78 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 79 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 80 const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 81 } arm_fir_instance_q31; 82 83 /** 84 * @brief Instance structure for the floating-point FIR filter. 85 */ 86 typedef struct 87 { 88 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 89 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 90 const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 91 } arm_fir_instance_f32; 92 93 /** 94 * @brief Instance structure for the floating-point FIR filter. 95 */ 96 typedef struct 97 { 98 uint16_t numTaps; /**< number of filter coefficients in the filter. */ 99 float64_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 100 const float64_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 101 } arm_fir_instance_f64; 102 103 /** 104 * @brief Processing function for the Q7 FIR filter. 105 * @param[in] S points to an instance of the Q7 FIR filter structure. 106 * @param[in] pSrc points to the block of input data. 107 * @param[out] pDst points to the block of output data. 108 * @param[in] blockSize number of samples to process. 109 */ 110 void arm_fir_q7( 111 const arm_fir_instance_q7 * S, 112 const q7_t * pSrc, 113 q7_t * pDst, 114 uint32_t blockSize); 115 116 /** 117 * @brief Initialization function for the Q7 FIR filter. 118 * @param[in,out] S points to an instance of the Q7 FIR structure. 119 * @param[in] numTaps Number of filter coefficients in the filter. 120 * @param[in] pCoeffs points to the filter coefficients. 121 * @param[in] pState points to the state buffer. 122 * @param[in] blockSize number of samples that are processed. 123 * 124 * For the MVE version, the coefficient length must be a multiple of 16. 125 * You can pad with zeros if you have less coefficients. 126 */ 127 void arm_fir_init_q7( 128 arm_fir_instance_q7 * S, 129 uint16_t numTaps, 130 const q7_t * pCoeffs, 131 q7_t * pState, 132 uint32_t blockSize); 133 134 /** 135 * @brief Processing function for the Q15 FIR filter. 136 * @param[in] S points to an instance of the Q15 FIR structure. 137 * @param[in] pSrc points to the block of input data. 138 * @param[out] pDst points to the block of output data. 139 * @param[in] blockSize number of samples to process. 140 */ 141 void arm_fir_q15( 142 const arm_fir_instance_q15 * S, 143 const q15_t * pSrc, 144 q15_t * pDst, 145 uint32_t blockSize); 146 147 /** 148 * @brief Processing function for the fast Q15 FIR filter (fast version). 149 * @param[in] S points to an instance of the Q15 FIR filter structure. 150 * @param[in] pSrc points to the block of input data. 151 * @param[out] pDst points to the block of output data. 152 * @param[in] blockSize number of samples to process. 153 */ 154 void arm_fir_fast_q15( 155 const arm_fir_instance_q15 * S, 156 const q15_t * pSrc, 157 q15_t * pDst, 158 uint32_t blockSize); 159 160 /** 161 * @brief Initialization function for the Q15 FIR filter. 162 * @param[in,out] S points to an instance of the Q15 FIR filter structure. 163 * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4. 164 * @param[in] pCoeffs points to the filter coefficients. 165 * @param[in] pState points to the state buffer. 166 * @param[in] blockSize number of samples that are processed at a time. 167 * @return The function returns either 168 * <code>ARM_MATH_SUCCESS</code> if initialization was successful or 169 * <code>ARM_MATH_ARGUMENT_ERROR</code> if <code>numTaps</code> is not a supported value. 170 * 171 * For the MVE version, the coefficient length must be a multiple of 8. 172 * You can pad with zeros if you have less coefficients. 173 * 174 */ 175 arm_status arm_fir_init_q15( 176 arm_fir_instance_q15 * S, 177 uint16_t numTaps, 178 const q15_t * pCoeffs, 179 q15_t * pState, 180 uint32_t blockSize); 181 182 /** 183 * @brief Processing function for the Q31 FIR filter. 184 * @param[in] S points to an instance of the Q31 FIR filter structure. 185 * @param[in] pSrc points to the block of input data. 186 * @param[out] pDst points to the block of output data. 187 * @param[in] blockSize number of samples to process. 188 */ 189 void arm_fir_q31( 190 const arm_fir_instance_q31 * S, 191 const q31_t * pSrc, 192 q31_t * pDst, 193 uint32_t blockSize); 194 195 /** 196 * @brief Processing function for the fast Q31 FIR filter (fast version). 197 * @param[in] S points to an instance of the Q31 FIR filter structure. 198 * @param[in] pSrc points to the block of input data. 199 * @param[out] pDst points to the block of output data. 200 * @param[in] blockSize number of samples to process. 201 */ 202 void arm_fir_fast_q31( 203 const arm_fir_instance_q31 * S, 204 const q31_t * pSrc, 205 q31_t * pDst, 206 uint32_t blockSize); 207 208 /** 209 * @brief Initialization function for the Q31 FIR filter. 210 * @param[in,out] S points to an instance of the Q31 FIR structure. 211 * @param[in] numTaps Number of filter coefficients in the filter. 212 * @param[in] pCoeffs points to the filter coefficients. 213 * @param[in] pState points to the state buffer. 214 * @param[in] blockSize number of samples that are processed at a time. 215 * 216 * For the MVE version, the coefficient length must be a multiple of 4. 217 * You can pad with zeros if you have less coefficients. 218 */ 219 void arm_fir_init_q31( 220 arm_fir_instance_q31 * S, 221 uint16_t numTaps, 222 const q31_t * pCoeffs, 223 q31_t * pState, 224 uint32_t blockSize); 225 226 /** 227 * @brief Processing function for the floating-point FIR filter. 228 * @param[in] S points to an instance of the floating-point FIR structure. 229 * @param[in] pSrc points to the block of input data. 230 * @param[out] pDst points to the block of output data. 231 * @param[in] blockSize number of samples to process. 232 */ 233 void arm_fir_f32( 234 const arm_fir_instance_f32 * S, 235 const float32_t * pSrc, 236 float32_t * pDst, 237 uint32_t blockSize); 238 239 /** 240 * @brief Processing function for the floating-point FIR filter. 241 * @param[in] S points to an instance of the floating-point FIR structure. 242 * @param[in] pSrc points to the block of input data. 243 * @param[out] pDst points to the block of output data. 244 * @param[in] blockSize number of samples to process. 245 */ 246 void arm_fir_f64( 247 const arm_fir_instance_f64 * S, 248 const float64_t * pSrc, 249 float64_t * pDst, 250 uint32_t blockSize); 251 252 /** 253 * @brief Initialization function for the floating-point FIR filter. 254 * @param[in,out] S points to an instance of the floating-point FIR filter structure. 255 * @param[in] numTaps Number of filter coefficients in the filter. 256 * @param[in] pCoeffs points to the filter coefficients. 257 * @param[in] pState points to the state buffer. 258 * @param[in] blockSize number of samples that are processed at a time. 259 */ 260 void arm_fir_init_f32( 261 arm_fir_instance_f32 * S, 262 uint16_t numTaps, 263 const float32_t * pCoeffs, 264 float32_t * pState, 265 uint32_t blockSize); 266 267 /** 268 * @brief Initialization function for the floating-point FIR filter. 269 * @param[in,out] S points to an instance of the floating-point FIR filter structure. 270 * @param[in] numTaps Number of filter coefficients in the filter. 271 * @param[in] pCoeffs points to the filter coefficients. 272 * @param[in] pState points to the state buffer. 273 * @param[in] blockSize number of samples that are processed at a time. 274 */ 275 void arm_fir_init_f64( 276 arm_fir_instance_f64 * S, 277 uint16_t numTaps, 278 const float64_t * pCoeffs, 279 float64_t * pState, 280 uint32_t blockSize); 281 282 /** 283 * @brief Instance structure for the Q15 Biquad cascade filter. 284 */ 285 typedef struct 286 { 287 int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 288 q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ 289 const q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ 290 int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ 291 } arm_biquad_casd_df1_inst_q15; 292 293 /** 294 * @brief Instance structure for the Q31 Biquad cascade filter. 295 */ 296 typedef struct 297 { 298 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 299 q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ 300 const q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ 301 uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ 302 } arm_biquad_casd_df1_inst_q31; 303 304 /** 305 * @brief Instance structure for the floating-point Biquad cascade filter. 306 */ 307 typedef struct 308 { 309 uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 310 float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ 311 const float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ 312 } arm_biquad_casd_df1_inst_f32; 313 314 #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) 315 /** 316 * @brief Instance structure for the modified Biquad coefs required by vectorized code. 317 */ 318 typedef struct 319 { 320 float32_t coeffs[8][4]; /**< Points to the array of modified coefficients. The array is of length 32. There is one per stage */ 321 } arm_biquad_mod_coef_f32; 322 #endif 323 324 /** 325 * @brief Processing function for the Q15 Biquad cascade filter. 326 * @param[in] S points to an instance of the Q15 Biquad cascade structure. 327 * @param[in] pSrc points to the block of input data. 328 * @param[out] pDst points to the block of output data. 329 * @param[in] blockSize number of samples to process. 330 */ 331 void arm_biquad_cascade_df1_q15( 332 const arm_biquad_casd_df1_inst_q15 * S, 333 const q15_t * pSrc, 334 q15_t * pDst, 335 uint32_t blockSize); 336 337 /** 338 * @brief Initialization function for the Q15 Biquad cascade filter. 339 * @param[in,out] S points to an instance of the Q15 Biquad cascade structure. 340 * @param[in] numStages number of 2nd order stages in the filter. 341 * @param[in] pCoeffs points to the filter coefficients. 342 * @param[in] pState points to the state buffer. 343 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format 344 */ 345 void arm_biquad_cascade_df1_init_q15( 346 arm_biquad_casd_df1_inst_q15 * S, 347 uint8_t numStages, 348 const q15_t * pCoeffs, 349 q15_t * pState, 350 int8_t postShift); 351 352 /** 353 * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4. 354 * @param[in] S points to an instance of the Q15 Biquad cascade structure. 355 * @param[in] pSrc points to the block of input data. 356 * @param[out] pDst points to the block of output data. 357 * @param[in] blockSize number of samples to process. 358 */ 359 void arm_biquad_cascade_df1_fast_q15( 360 const arm_biquad_casd_df1_inst_q15 * S, 361 const q15_t * pSrc, 362 q15_t * pDst, 363 uint32_t blockSize); 364 365 /** 366 * @brief Processing function for the Q31 Biquad cascade filter 367 * @param[in] S points to an instance of the Q31 Biquad cascade structure. 368 * @param[in] pSrc points to the block of input data. 369 * @param[out] pDst points to the block of output data. 370 * @param[in] blockSize number of samples to process. 371 */ 372 void arm_biquad_cascade_df1_q31( 373 const arm_biquad_casd_df1_inst_q31 * S, 374 const q31_t * pSrc, 375 q31_t * pDst, 376 uint32_t blockSize); 377 378 /** 379 * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4. 380 * @param[in] S points to an instance of the Q31 Biquad cascade structure. 381 * @param[in] pSrc points to the block of input data. 382 * @param[out] pDst points to the block of output data. 383 * @param[in] blockSize number of samples to process. 384 */ 385 void arm_biquad_cascade_df1_fast_q31( 386 const arm_biquad_casd_df1_inst_q31 * S, 387 const q31_t * pSrc, 388 q31_t * pDst, 389 uint32_t blockSize); 390 391 /** 392 * @brief Initialization function for the Q31 Biquad cascade filter. 393 * @param[in,out] S points to an instance of the Q31 Biquad cascade structure. 394 * @param[in] numStages number of 2nd order stages in the filter. 395 * @param[in] pCoeffs points to the filter coefficients. 396 * @param[in] pState points to the state buffer. 397 * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format 398 */ 399 void arm_biquad_cascade_df1_init_q31( 400 arm_biquad_casd_df1_inst_q31 * S, 401 uint8_t numStages, 402 const q31_t * pCoeffs, 403 q31_t * pState, 404 int8_t postShift); 405 406 /** 407 * @brief Processing function for the floating-point Biquad cascade filter. 408 * @param[in] S points to an instance of the floating-point Biquad cascade structure. 409 * @param[in] pSrc points to the block of input data. 410 * @param[out] pDst points to the block of output data. 411 * @param[in] blockSize number of samples to process. 412 */ 413 void arm_biquad_cascade_df1_f32( 414 const arm_biquad_casd_df1_inst_f32 * S, 415 const float32_t * pSrc, 416 float32_t * pDst, 417 uint32_t blockSize); 418 419 /** 420 * @brief Initialization function for the floating-point Biquad cascade filter. 421 * @param[in,out] S points to an instance of the floating-point Biquad cascade structure. 422 * @param[in] numStages number of 2nd order stages in the filter. 423 * @param[in] pCoeffs points to the filter coefficients. 424 * @param[in] pCoeffsMod points to the modified filter coefficients (only MVE version). 425 * @param[in] pState points to the state buffer. 426 */ 427 #if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) 428 void arm_biquad_cascade_df1_mve_init_f32( 429 arm_biquad_casd_df1_inst_f32 * S, 430 uint8_t numStages, 431 const float32_t * pCoeffs, 432 arm_biquad_mod_coef_f32 * pCoeffsMod, 433 float32_t * pState); 434 #endif 435 436 void arm_biquad_cascade_df1_init_f32( 437 arm_biquad_casd_df1_inst_f32 * S, 438 uint8_t numStages, 439 const float32_t * pCoeffs, 440 float32_t * pState); 441 442 443 /** 444 * @brief Convolution of floating-point sequences. 445 * @param[in] pSrcA points to the first input sequence. 446 * @param[in] srcALen length of the first input sequence. 447 * @param[in] pSrcB points to the second input sequence. 448 * @param[in] srcBLen length of the second input sequence. 449 * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. 450 */ 451 void arm_conv_f32( 452 const float32_t * pSrcA, 453 uint32_t srcALen, 454 const float32_t * pSrcB, 455 uint32_t srcBLen, 456 float32_t * pDst); 457 458 459 /** 460 * @brief Convolution of Q15 sequences. 461 * @param[in] pSrcA points to the first input sequence. 462 * @param[in] srcALen length of the first input sequence. 463 * @param[in] pSrcB points to the second input sequence. 464 * @param[in] srcBLen length of the second input sequence. 465 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. 466 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 467 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). 468 */ 469 void arm_conv_opt_q15( 470 const q15_t * pSrcA, 471 uint32_t srcALen, 472 const q15_t * pSrcB, 473 uint32_t srcBLen, 474 q15_t * pDst, 475 q15_t * pScratch1, 476 q15_t * pScratch2); 477 478 479 /** 480 * @brief Convolution of Q15 sequences. 481 * @param[in] pSrcA points to the first input sequence. 482 * @param[in] srcALen length of the first input sequence. 483 * @param[in] pSrcB points to the second input sequence. 484 * @param[in] srcBLen length of the second input sequence. 485 * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. 486 */ 487 void arm_conv_q15( 488 const q15_t * pSrcA, 489 uint32_t srcALen, 490 const q15_t * pSrcB, 491 uint32_t srcBLen, 492 q15_t * pDst); 493 494 495 /** 496 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 497 * @param[in] pSrcA points to the first input sequence. 498 * @param[in] srcALen length of the first input sequence. 499 * @param[in] pSrcB points to the second input sequence. 500 * @param[in] srcBLen length of the second input sequence. 501 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. 502 */ 503 void arm_conv_fast_q15( 504 const q15_t * pSrcA, 505 uint32_t srcALen, 506 const q15_t * pSrcB, 507 uint32_t srcBLen, 508 q15_t * pDst); 509 510 511 /** 512 * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 513 * @param[in] pSrcA points to the first input sequence. 514 * @param[in] srcALen length of the first input sequence. 515 * @param[in] pSrcB points to the second input sequence. 516 * @param[in] srcBLen length of the second input sequence. 517 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. 518 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 519 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). 520 */ 521 void arm_conv_fast_opt_q15( 522 const q15_t * pSrcA, 523 uint32_t srcALen, 524 const q15_t * pSrcB, 525 uint32_t srcBLen, 526 q15_t * pDst, 527 q15_t * pScratch1, 528 q15_t * pScratch2); 529 530 531 /** 532 * @brief Convolution of Q31 sequences. 533 * @param[in] pSrcA points to the first input sequence. 534 * @param[in] srcALen length of the first input sequence. 535 * @param[in] pSrcB points to the second input sequence. 536 * @param[in] srcBLen length of the second input sequence. 537 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. 538 */ 539 void arm_conv_q31( 540 const q31_t * pSrcA, 541 uint32_t srcALen, 542 const q31_t * pSrcB, 543 uint32_t srcBLen, 544 q31_t * pDst); 545 546 547 /** 548 * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4 549 * @param[in] pSrcA points to the first input sequence. 550 * @param[in] srcALen length of the first input sequence. 551 * @param[in] pSrcB points to the second input sequence. 552 * @param[in] srcBLen length of the second input sequence. 553 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. 554 */ 555 void arm_conv_fast_q31( 556 const q31_t * pSrcA, 557 uint32_t srcALen, 558 const q31_t * pSrcB, 559 uint32_t srcBLen, 560 q31_t * pDst); 561 562 563 /** 564 * @brief Convolution of Q7 sequences. 565 * @param[in] pSrcA points to the first input sequence. 566 * @param[in] srcALen length of the first input sequence. 567 * @param[in] pSrcB points to the second input sequence. 568 * @param[in] srcBLen length of the second input sequence. 569 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. 570 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 571 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). 572 */ 573 void arm_conv_opt_q7( 574 const q7_t * pSrcA, 575 uint32_t srcALen, 576 const q7_t * pSrcB, 577 uint32_t srcBLen, 578 q7_t * pDst, 579 q15_t * pScratch1, 580 q15_t * pScratch2); 581 582 583 /** 584 * @brief Convolution of Q7 sequences. 585 * @param[in] pSrcA points to the first input sequence. 586 * @param[in] srcALen length of the first input sequence. 587 * @param[in] pSrcB points to the second input sequence. 588 * @param[in] srcBLen length of the second input sequence. 589 * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. 590 */ 591 void arm_conv_q7( 592 const q7_t * pSrcA, 593 uint32_t srcALen, 594 const q7_t * pSrcB, 595 uint32_t srcBLen, 596 q7_t * pDst); 597 598 599 /** 600 * @brief Partial convolution of floating-point sequences. 601 * @param[in] pSrcA points to the first input sequence. 602 * @param[in] srcALen length of the first input sequence. 603 * @param[in] pSrcB points to the second input sequence. 604 * @param[in] srcBLen length of the second input sequence. 605 * @param[out] pDst points to the block of output data 606 * @param[in] firstIndex is the first output sample to start with. 607 * @param[in] numPoints is the number of output points to be computed. 608 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 609 */ 610 arm_status arm_conv_partial_f32( 611 const float32_t * pSrcA, 612 uint32_t srcALen, 613 const float32_t * pSrcB, 614 uint32_t srcBLen, 615 float32_t * pDst, 616 uint32_t firstIndex, 617 uint32_t numPoints); 618 619 620 /** 621 * @brief Partial convolution of Q15 sequences. 622 * @param[in] pSrcA points to the first input sequence. 623 * @param[in] srcALen length of the first input sequence. 624 * @param[in] pSrcB points to the second input sequence. 625 * @param[in] srcBLen length of the second input sequence. 626 * @param[out] pDst points to the block of output data 627 * @param[in] firstIndex is the first output sample to start with. 628 * @param[in] numPoints is the number of output points to be computed. 629 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 630 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). 631 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 632 */ 633 arm_status arm_conv_partial_opt_q15( 634 const q15_t * pSrcA, 635 uint32_t srcALen, 636 const q15_t * pSrcB, 637 uint32_t srcBLen, 638 q15_t * pDst, 639 uint32_t firstIndex, 640 uint32_t numPoints, 641 q15_t * pScratch1, 642 q15_t * pScratch2); 643 644 645 /** 646 * @brief Partial convolution of Q15 sequences. 647 * @param[in] pSrcA points to the first input sequence. 648 * @param[in] srcALen length of the first input sequence. 649 * @param[in] pSrcB points to the second input sequence. 650 * @param[in] srcBLen length of the second input sequence. 651 * @param[out] pDst points to the block of output data 652 * @param[in] firstIndex is the first output sample to start with. 653 * @param[in] numPoints is the number of output points to be computed. 654 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 655 */ 656 arm_status arm_conv_partial_q15( 657 const q15_t * pSrcA, 658 uint32_t srcALen, 659 const q15_t * pSrcB, 660 uint32_t srcBLen, 661 q15_t * pDst, 662 uint32_t firstIndex, 663 uint32_t numPoints); 664 665 666 /** 667 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 668 * @param[in] pSrcA points to the first input sequence. 669 * @param[in] srcALen length of the first input sequence. 670 * @param[in] pSrcB points to the second input sequence. 671 * @param[in] srcBLen length of the second input sequence. 672 * @param[out] pDst points to the block of output data 673 * @param[in] firstIndex is the first output sample to start with. 674 * @param[in] numPoints is the number of output points to be computed. 675 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 676 */ 677 arm_status arm_conv_partial_fast_q15( 678 const q15_t * pSrcA, 679 uint32_t srcALen, 680 const q15_t * pSrcB, 681 uint32_t srcBLen, 682 q15_t * pDst, 683 uint32_t firstIndex, 684 uint32_t numPoints); 685 686 687 /** 688 * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 689 * @param[in] pSrcA points to the first input sequence. 690 * @param[in] srcALen length of the first input sequence. 691 * @param[in] pSrcB points to the second input sequence. 692 * @param[in] srcBLen length of the second input sequence. 693 * @param[out] pDst points to the block of output data 694 * @param[in] firstIndex is the first output sample to start with. 695 * @param[in] numPoints is the number of output points to be computed. 696 * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 697 * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). 698 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 699 */ 700 arm_status arm_conv_partial_fast_opt_q15( 701 const q15_t * pSrcA, 702 uint32_t srcALen, 703 const q15_t * pSrcB, 704 uint32_t srcBLen, 705 q15_t * pDst, 706 uint32_t firstIndex, 707 uint32_t numPoints, 708 q15_t * pScratch1, 709 q15_t * pScratch2); 710 711 712 /** 713 * @brief Partial convolution of Q31 sequences. 714 * @param[in] pSrcA points to the first input sequence. 715 * @param[in] srcALen length of the first input sequence. 716 * @param[in] pSrcB points to the second input sequence. 717 * @param[in] srcBLen length of the second input sequence. 718 * @param[out] pDst points to the block of output data 719 * @param[in] firstIndex is the first output sample to start with. 720 * @param[in] numPoints is the number of output points to be computed. 721 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 722 */ 723 arm_status arm_conv_partial_q31( 724 const q31_t * pSrcA, 725 uint32_t srcALen, 726 const q31_t * pSrcB, 727 uint32_t srcBLen, 728 q31_t * pDst, 729 uint32_t firstIndex, 730 uint32_t numPoints); 731 732 733 /** 734 * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4 735 * @param[in] pSrcA points to the first input sequence. 736 * @param[in] srcALen length of the first input sequence. 737 * @param[in] pSrcB points to the second input sequence. 738 * @param[in] srcBLen length of the second input sequence. 739 * @param[out] pDst points to the block of output data 740 * @param[in] firstIndex is the first output sample to start with. 741 * @param[in] numPoints is the number of output points to be computed. 742 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 743 */ 744 arm_status arm_conv_partial_fast_q31( 745 const q31_t * pSrcA, 746 uint32_t srcALen, 747 const q31_t * pSrcB, 748 uint32_t srcBLen, 749 q31_t * pDst, 750 uint32_t firstIndex, 751 uint32_t numPoints); 752 753 754 /** 755 * @brief Partial convolution of Q7 sequences 756 * @param[in] pSrcA points to the first input sequence. 757 * @param[in] srcALen length of the first input sequence. 758 * @param[in] pSrcB points to the second input sequence. 759 * @param[in] srcBLen length of the second input sequence. 760 * @param[out] pDst points to the block of output data 761 * @param[in] firstIndex is the first output sample to start with. 762 * @param[in] numPoints is the number of output points to be computed. 763 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 764 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). 765 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 766 */ 767 arm_status arm_conv_partial_opt_q7( 768 const q7_t * pSrcA, 769 uint32_t srcALen, 770 const q7_t * pSrcB, 771 uint32_t srcBLen, 772 q7_t * pDst, 773 uint32_t firstIndex, 774 uint32_t numPoints, 775 q15_t * pScratch1, 776 q15_t * pScratch2); 777 778 779 /** 780 * @brief Partial convolution of Q7 sequences. 781 * @param[in] pSrcA points to the first input sequence. 782 * @param[in] srcALen length of the first input sequence. 783 * @param[in] pSrcB points to the second input sequence. 784 * @param[in] srcBLen length of the second input sequence. 785 * @param[out] pDst points to the block of output data 786 * @param[in] firstIndex is the first output sample to start with. 787 * @param[in] numPoints is the number of output points to be computed. 788 * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. 789 */ 790 arm_status arm_conv_partial_q7( 791 const q7_t * pSrcA, 792 uint32_t srcALen, 793 const q7_t * pSrcB, 794 uint32_t srcBLen, 795 q7_t * pDst, 796 uint32_t firstIndex, 797 uint32_t numPoints); 798 799 800 /** 801 * @brief Instance structure for the Q15 FIR decimator. 802 */ 803 typedef struct 804 { 805 uint8_t M; /**< decimation factor. */ 806 uint16_t numTaps; /**< number of coefficients in the filter. */ 807 const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 808 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 809 } arm_fir_decimate_instance_q15; 810 811 /** 812 * @brief Instance structure for the Q31 FIR decimator. 813 */ 814 typedef struct 815 { 816 uint8_t M; /**< decimation factor. */ 817 uint16_t numTaps; /**< number of coefficients in the filter. */ 818 const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 819 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 820 } arm_fir_decimate_instance_q31; 821 822 /** 823 @brief Instance structure for floating-point FIR decimator. 824 */ 825 typedef struct 826 { 827 uint8_t M; /**< decimation factor. */ 828 uint16_t numTaps; /**< number of coefficients in the filter. */ 829 const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 830 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 831 } arm_fir_decimate_instance_f32; 832 833 834 /** 835 @brief Processing function for floating-point FIR decimator. 836 @param[in] S points to an instance of the floating-point FIR decimator structure 837 @param[in] pSrc points to the block of input data 838 @param[out] pDst points to the block of output data 839 @param[in] blockSize number of samples to process 840 */ 841 void arm_fir_decimate_f32( 842 const arm_fir_decimate_instance_f32 * S, 843 const float32_t * pSrc, 844 float32_t * pDst, 845 uint32_t blockSize); 846 847 848 /** 849 @brief Initialization function for the floating-point FIR decimator. 850 @param[in,out] S points to an instance of the floating-point FIR decimator structure 851 @param[in] numTaps number of coefficients in the filter 852 @param[in] M decimation factor 853 @param[in] pCoeffs points to the filter coefficients 854 @param[in] pState points to the state buffer 855 @param[in] blockSize number of input samples to process per call 856 @return execution status 857 - \ref ARM_MATH_SUCCESS : Operation successful 858 - \ref ARM_MATH_LENGTH_ERROR : <code>blockSize</code> is not a multiple of <code>M</code> 859 */ 860 arm_status arm_fir_decimate_init_f32( 861 arm_fir_decimate_instance_f32 * S, 862 uint16_t numTaps, 863 uint8_t M, 864 const float32_t * pCoeffs, 865 float32_t * pState, 866 uint32_t blockSize); 867 868 869 /** 870 * @brief Processing function for the Q15 FIR decimator. 871 * @param[in] S points to an instance of the Q15 FIR decimator structure. 872 * @param[in] pSrc points to the block of input data. 873 * @param[out] pDst points to the block of output data 874 * @param[in] blockSize number of input samples to process per call. 875 */ 876 void arm_fir_decimate_q15( 877 const arm_fir_decimate_instance_q15 * S, 878 const q15_t * pSrc, 879 q15_t * pDst, 880 uint32_t blockSize); 881 882 883 /** 884 * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. 885 * @param[in] S points to an instance of the Q15 FIR decimator structure. 886 * @param[in] pSrc points to the block of input data. 887 * @param[out] pDst points to the block of output data 888 * @param[in] blockSize number of input samples to process per call. 889 */ 890 void arm_fir_decimate_fast_q15( 891 const arm_fir_decimate_instance_q15 * S, 892 const q15_t * pSrc, 893 q15_t * pDst, 894 uint32_t blockSize); 895 896 897 /** 898 * @brief Initialization function for the Q15 FIR decimator. 899 * @param[in,out] S points to an instance of the Q15 FIR decimator structure. 900 * @param[in] numTaps number of coefficients in the filter. 901 * @param[in] M decimation factor. 902 * @param[in] pCoeffs points to the filter coefficients. 903 * @param[in] pState points to the state buffer. 904 * @param[in] blockSize number of input samples to process per call. 905 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 906 * <code>blockSize</code> is not a multiple of <code>M</code>. 907 */ 908 arm_status arm_fir_decimate_init_q15( 909 arm_fir_decimate_instance_q15 * S, 910 uint16_t numTaps, 911 uint8_t M, 912 const q15_t * pCoeffs, 913 q15_t * pState, 914 uint32_t blockSize); 915 916 917 /** 918 * @brief Processing function for the Q31 FIR decimator. 919 * @param[in] S points to an instance of the Q31 FIR decimator structure. 920 * @param[in] pSrc points to the block of input data. 921 * @param[out] pDst points to the block of output data 922 * @param[in] blockSize number of input samples to process per call. 923 */ 924 void arm_fir_decimate_q31( 925 const arm_fir_decimate_instance_q31 * S, 926 const q31_t * pSrc, 927 q31_t * pDst, 928 uint32_t blockSize); 929 930 /** 931 * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. 932 * @param[in] S points to an instance of the Q31 FIR decimator structure. 933 * @param[in] pSrc points to the block of input data. 934 * @param[out] pDst points to the block of output data 935 * @param[in] blockSize number of input samples to process per call. 936 */ 937 void arm_fir_decimate_fast_q31( 938 const arm_fir_decimate_instance_q31 * S, 939 const q31_t * pSrc, 940 q31_t * pDst, 941 uint32_t blockSize); 942 943 944 /** 945 * @brief Initialization function for the Q31 FIR decimator. 946 * @param[in,out] S points to an instance of the Q31 FIR decimator structure. 947 * @param[in] numTaps number of coefficients in the filter. 948 * @param[in] M decimation factor. 949 * @param[in] pCoeffs points to the filter coefficients. 950 * @param[in] pState points to the state buffer. 951 * @param[in] blockSize number of input samples to process per call. 952 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 953 * <code>blockSize</code> is not a multiple of <code>M</code>. 954 */ 955 arm_status arm_fir_decimate_init_q31( 956 arm_fir_decimate_instance_q31 * S, 957 uint16_t numTaps, 958 uint8_t M, 959 const q31_t * pCoeffs, 960 q31_t * pState, 961 uint32_t blockSize); 962 963 964 /** 965 * @brief Instance structure for the Q15 FIR interpolator. 966 */ 967 typedef struct 968 { 969 uint8_t L; /**< upsample factor. */ 970 uint16_t phaseLength; /**< length of each polyphase filter component. */ 971 const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 972 q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ 973 } arm_fir_interpolate_instance_q15; 974 975 /** 976 * @brief Instance structure for the Q31 FIR interpolator. 977 */ 978 typedef struct 979 { 980 uint8_t L; /**< upsample factor. */ 981 uint16_t phaseLength; /**< length of each polyphase filter component. */ 982 const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 983 q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ 984 } arm_fir_interpolate_instance_q31; 985 986 /** 987 * @brief Instance structure for the floating-point FIR interpolator. 988 */ 989 typedef struct 990 { 991 uint8_t L; /**< upsample factor. */ 992 uint16_t phaseLength; /**< length of each polyphase filter component. */ 993 const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 994 float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */ 995 } arm_fir_interpolate_instance_f32; 996 997 998 /** 999 * @brief Processing function for the Q15 FIR interpolator. 1000 * @param[in] S points to an instance of the Q15 FIR interpolator structure. 1001 * @param[in] pSrc points to the block of input data. 1002 * @param[out] pDst points to the block of output data. 1003 * @param[in] blockSize number of input samples to process per call. 1004 */ 1005 void arm_fir_interpolate_q15( 1006 const arm_fir_interpolate_instance_q15 * S, 1007 const q15_t * pSrc, 1008 q15_t * pDst, 1009 uint32_t blockSize); 1010 1011 1012 /** 1013 * @brief Initialization function for the Q15 FIR interpolator. 1014 * @param[in,out] S points to an instance of the Q15 FIR interpolator structure. 1015 * @param[in] L upsample factor. 1016 * @param[in] numTaps number of filter coefficients in the filter. 1017 * @param[in] pCoeffs points to the filter coefficient buffer. 1018 * @param[in] pState points to the state buffer. 1019 * @param[in] blockSize number of input samples to process per call. 1020 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 1021 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 1022 */ 1023 arm_status arm_fir_interpolate_init_q15( 1024 arm_fir_interpolate_instance_q15 * S, 1025 uint8_t L, 1026 uint16_t numTaps, 1027 const q15_t * pCoeffs, 1028 q15_t * pState, 1029 uint32_t blockSize); 1030 1031 1032 /** 1033 * @brief Processing function for the Q31 FIR interpolator. 1034 * @param[in] S points to an instance of the Q15 FIR interpolator structure. 1035 * @param[in] pSrc points to the block of input data. 1036 * @param[out] pDst points to the block of output data. 1037 * @param[in] blockSize number of input samples to process per call. 1038 */ 1039 void arm_fir_interpolate_q31( 1040 const arm_fir_interpolate_instance_q31 * S, 1041 const q31_t * pSrc, 1042 q31_t * pDst, 1043 uint32_t blockSize); 1044 1045 1046 /** 1047 * @brief Initialization function for the Q31 FIR interpolator. 1048 * @param[in,out] S points to an instance of the Q31 FIR interpolator structure. 1049 * @param[in] L upsample factor. 1050 * @param[in] numTaps number of filter coefficients in the filter. 1051 * @param[in] pCoeffs points to the filter coefficient buffer. 1052 * @param[in] pState points to the state buffer. 1053 * @param[in] blockSize number of input samples to process per call. 1054 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 1055 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 1056 */ 1057 arm_status arm_fir_interpolate_init_q31( 1058 arm_fir_interpolate_instance_q31 * S, 1059 uint8_t L, 1060 uint16_t numTaps, 1061 const q31_t * pCoeffs, 1062 q31_t * pState, 1063 uint32_t blockSize); 1064 1065 1066 /** 1067 * @brief Processing function for the floating-point FIR interpolator. 1068 * @param[in] S points to an instance of the floating-point FIR interpolator structure. 1069 * @param[in] pSrc points to the block of input data. 1070 * @param[out] pDst points to the block of output data. 1071 * @param[in] blockSize number of input samples to process per call. 1072 */ 1073 void arm_fir_interpolate_f32( 1074 const arm_fir_interpolate_instance_f32 * S, 1075 const float32_t * pSrc, 1076 float32_t * pDst, 1077 uint32_t blockSize); 1078 1079 1080 /** 1081 * @brief Initialization function for the floating-point FIR interpolator. 1082 * @param[in,out] S points to an instance of the floating-point FIR interpolator structure. 1083 * @param[in] L upsample factor. 1084 * @param[in] numTaps number of filter coefficients in the filter. 1085 * @param[in] pCoeffs points to the filter coefficient buffer. 1086 * @param[in] pState points to the state buffer. 1087 * @param[in] blockSize number of input samples to process per call. 1088 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 1089 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 1090 */ 1091 arm_status arm_fir_interpolate_init_f32( 1092 arm_fir_interpolate_instance_f32 * S, 1093 uint8_t L, 1094 uint16_t numTaps, 1095 const float32_t * pCoeffs, 1096 float32_t * pState, 1097 uint32_t blockSize); 1098 1099 1100 /** 1101 * @brief Instance structure for the high precision Q31 Biquad cascade filter. 1102 */ 1103 typedef struct 1104 { 1105 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 1106 q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ 1107 const q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 1108 uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */ 1109 } arm_biquad_cas_df1_32x64_ins_q31; 1110 1111 1112 /** 1113 * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure. 1114 * @param[in] pSrc points to the block of input data. 1115 * @param[out] pDst points to the block of output data 1116 * @param[in] blockSize number of samples to process. 1117 */ 1118 void arm_biquad_cas_df1_32x64_q31( 1119 const arm_biquad_cas_df1_32x64_ins_q31 * S, 1120 const q31_t * pSrc, 1121 q31_t * pDst, 1122 uint32_t blockSize); 1123 1124 1125 /** 1126 * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure. 1127 * @param[in] numStages number of 2nd order stages in the filter. 1128 * @param[in] pCoeffs points to the filter coefficients. 1129 * @param[in] pState points to the state buffer. 1130 * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format 1131 */ 1132 void arm_biquad_cas_df1_32x64_init_q31( 1133 arm_biquad_cas_df1_32x64_ins_q31 * S, 1134 uint8_t numStages, 1135 const q31_t * pCoeffs, 1136 q63_t * pState, 1137 uint8_t postShift); 1138 1139 1140 /** 1141 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. 1142 */ 1143 typedef struct 1144 { 1145 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 1146 float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ 1147 const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 1148 } arm_biquad_cascade_df2T_instance_f32; 1149 1150 /** 1151 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. 1152 */ 1153 typedef struct 1154 { 1155 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 1156 float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ 1157 const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 1158 } arm_biquad_cascade_stereo_df2T_instance_f32; 1159 1160 /** 1161 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. 1162 */ 1163 typedef struct 1164 { 1165 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 1166 float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ 1167 const float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 1168 } arm_biquad_cascade_df2T_instance_f64; 1169 1170 1171 /** 1172 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 1173 * @param[in] S points to an instance of the filter data structure. 1174 * @param[in] pSrc points to the block of input data. 1175 * @param[out] pDst points to the block of output data 1176 * @param[in] blockSize number of samples to process. 1177 */ 1178 void arm_biquad_cascade_df2T_f32( 1179 const arm_biquad_cascade_df2T_instance_f32 * S, 1180 const float32_t * pSrc, 1181 float32_t * pDst, 1182 uint32_t blockSize); 1183 1184 1185 /** 1186 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels 1187 * @param[in] S points to an instance of the filter data structure. 1188 * @param[in] pSrc points to the block of input data. 1189 * @param[out] pDst points to the block of output data 1190 * @param[in] blockSize number of samples to process. 1191 */ 1192 void arm_biquad_cascade_stereo_df2T_f32( 1193 const arm_biquad_cascade_stereo_df2T_instance_f32 * S, 1194 const float32_t * pSrc, 1195 float32_t * pDst, 1196 uint32_t blockSize); 1197 1198 1199 /** 1200 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 1201 * @param[in] S points to an instance of the filter data structure. 1202 * @param[in] pSrc points to the block of input data. 1203 * @param[out] pDst points to the block of output data 1204 * @param[in] blockSize number of samples to process. 1205 */ 1206 void arm_biquad_cascade_df2T_f64( 1207 const arm_biquad_cascade_df2T_instance_f64 * S, 1208 const float64_t * pSrc, 1209 float64_t * pDst, 1210 uint32_t blockSize); 1211 1212 1213 #if defined(ARM_MATH_NEON) 1214 /** 1215 @brief Compute new coefficient arrays for use in vectorized filter (Neon only). 1216 @param[in] numStages number of 2nd order stages in the filter. 1217 @param[in] pCoeffs points to the original filter coefficients. 1218 @param[in] pComputedCoeffs points to the new computed coefficients for the vectorized version. 1219 @return none 1220 */ 1221 void arm_biquad_cascade_df2T_compute_coefs_f32( 1222 uint8_t numStages, 1223 const float32_t * pCoeffs, 1224 float32_t * pComputedCoeffs); 1225 #endif 1226 /** 1227 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. 1228 * @param[in,out] S points to an instance of the filter data structure. 1229 * @param[in] numStages number of 2nd order stages in the filter. 1230 * @param[in] pCoeffs points to the filter coefficients. 1231 * @param[in] pState points to the state buffer. 1232 */ 1233 void arm_biquad_cascade_df2T_init_f32( 1234 arm_biquad_cascade_df2T_instance_f32 * S, 1235 uint8_t numStages, 1236 const float32_t * pCoeffs, 1237 float32_t * pState); 1238 1239 1240 /** 1241 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. 1242 * @param[in,out] S points to an instance of the filter data structure. 1243 * @param[in] numStages number of 2nd order stages in the filter. 1244 * @param[in] pCoeffs points to the filter coefficients. 1245 * @param[in] pState points to the state buffer. 1246 */ 1247 void arm_biquad_cascade_stereo_df2T_init_f32( 1248 arm_biquad_cascade_stereo_df2T_instance_f32 * S, 1249 uint8_t numStages, 1250 const float32_t * pCoeffs, 1251 float32_t * pState); 1252 1253 1254 /** 1255 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. 1256 * @param[in,out] S points to an instance of the filter data structure. 1257 * @param[in] numStages number of 2nd order stages in the filter. 1258 * @param[in] pCoeffs points to the filter coefficients. 1259 * @param[in] pState points to the state buffer. 1260 */ 1261 void arm_biquad_cascade_df2T_init_f64( 1262 arm_biquad_cascade_df2T_instance_f64 * S, 1263 uint8_t numStages, 1264 const float64_t * pCoeffs, 1265 float64_t * pState); 1266 1267 1268 /** 1269 * @brief Instance structure for the Q15 FIR lattice filter. 1270 */ 1271 typedef struct 1272 { 1273 uint16_t numStages; /**< number of filter stages. */ 1274 q15_t *pState; /**< points to the state variable array. The array is of length numStages. */ 1275 const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 1276 } arm_fir_lattice_instance_q15; 1277 1278 /** 1279 * @brief Instance structure for the Q31 FIR lattice filter. 1280 */ 1281 typedef struct 1282 { 1283 uint16_t numStages; /**< number of filter stages. */ 1284 q31_t *pState; /**< points to the state variable array. The array is of length numStages. */ 1285 const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 1286 } arm_fir_lattice_instance_q31; 1287 1288 /** 1289 * @brief Instance structure for the floating-point FIR lattice filter. 1290 */ 1291 typedef struct 1292 { 1293 uint16_t numStages; /**< number of filter stages. */ 1294 float32_t *pState; /**< points to the state variable array. The array is of length numStages. */ 1295 const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 1296 } arm_fir_lattice_instance_f32; 1297 1298 1299 /** 1300 * @brief Initialization function for the Q15 FIR lattice filter. 1301 * @param[in] S points to an instance of the Q15 FIR lattice structure. 1302 * @param[in] numStages number of filter stages. 1303 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. 1304 * @param[in] pState points to the state buffer. The array is of length numStages. 1305 */ 1306 void arm_fir_lattice_init_q15( 1307 arm_fir_lattice_instance_q15 * S, 1308 uint16_t numStages, 1309 const q15_t * pCoeffs, 1310 q15_t * pState); 1311 1312 1313 /** 1314 * @brief Processing function for the Q15 FIR lattice filter. 1315 * @param[in] S points to an instance of the Q15 FIR lattice structure. 1316 * @param[in] pSrc points to the block of input data. 1317 * @param[out] pDst points to the block of output data. 1318 * @param[in] blockSize number of samples to process. 1319 */ 1320 void arm_fir_lattice_q15( 1321 const arm_fir_lattice_instance_q15 * S, 1322 const q15_t * pSrc, 1323 q15_t * pDst, 1324 uint32_t blockSize); 1325 1326 1327 /** 1328 * @brief Initialization function for the Q31 FIR lattice filter. 1329 * @param[in] S points to an instance of the Q31 FIR lattice structure. 1330 * @param[in] numStages number of filter stages. 1331 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. 1332 * @param[in] pState points to the state buffer. The array is of length numStages. 1333 */ 1334 void arm_fir_lattice_init_q31( 1335 arm_fir_lattice_instance_q31 * S, 1336 uint16_t numStages, 1337 const q31_t * pCoeffs, 1338 q31_t * pState); 1339 1340 1341 /** 1342 * @brief Processing function for the Q31 FIR lattice filter. 1343 * @param[in] S points to an instance of the Q31 FIR lattice structure. 1344 * @param[in] pSrc points to the block of input data. 1345 * @param[out] pDst points to the block of output data 1346 * @param[in] blockSize number of samples to process. 1347 */ 1348 void arm_fir_lattice_q31( 1349 const arm_fir_lattice_instance_q31 * S, 1350 const q31_t * pSrc, 1351 q31_t * pDst, 1352 uint32_t blockSize); 1353 1354 1355 /** 1356 * @brief Initialization function for the floating-point FIR lattice filter. 1357 * @param[in] S points to an instance of the floating-point FIR lattice structure. 1358 * @param[in] numStages number of filter stages. 1359 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. 1360 * @param[in] pState points to the state buffer. The array is of length numStages. 1361 */ 1362 void arm_fir_lattice_init_f32( 1363 arm_fir_lattice_instance_f32 * S, 1364 uint16_t numStages, 1365 const float32_t * pCoeffs, 1366 float32_t * pState); 1367 1368 1369 /** 1370 * @brief Processing function for the floating-point FIR lattice filter. 1371 * @param[in] S points to an instance of the floating-point FIR lattice structure. 1372 * @param[in] pSrc points to the block of input data. 1373 * @param[out] pDst points to the block of output data 1374 * @param[in] blockSize number of samples to process. 1375 */ 1376 void arm_fir_lattice_f32( 1377 const arm_fir_lattice_instance_f32 * S, 1378 const float32_t * pSrc, 1379 float32_t * pDst, 1380 uint32_t blockSize); 1381 1382 1383 /** 1384 * @brief Instance structure for the Q15 IIR lattice filter. 1385 */ 1386 typedef struct 1387 { 1388 uint16_t numStages; /**< number of stages in the filter. */ 1389 q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 1390 q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 1391 q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 1392 } arm_iir_lattice_instance_q15; 1393 1394 /** 1395 * @brief Instance structure for the Q31 IIR lattice filter. 1396 */ 1397 typedef struct 1398 { 1399 uint16_t numStages; /**< number of stages in the filter. */ 1400 q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 1401 q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 1402 q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 1403 } arm_iir_lattice_instance_q31; 1404 1405 /** 1406 * @brief Instance structure for the floating-point IIR lattice filter. 1407 */ 1408 typedef struct 1409 { 1410 uint16_t numStages; /**< number of stages in the filter. */ 1411 float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 1412 float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 1413 float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 1414 } arm_iir_lattice_instance_f32; 1415 1416 1417 /** 1418 * @brief Processing function for the floating-point IIR lattice filter. 1419 * @param[in] S points to an instance of the floating-point IIR lattice structure. 1420 * @param[in] pSrc points to the block of input data. 1421 * @param[out] pDst points to the block of output data. 1422 * @param[in] blockSize number of samples to process. 1423 */ 1424 void arm_iir_lattice_f32( 1425 const arm_iir_lattice_instance_f32 * S, 1426 const float32_t * pSrc, 1427 float32_t * pDst, 1428 uint32_t blockSize); 1429 1430 1431 /** 1432 * @brief Initialization function for the floating-point IIR lattice filter. 1433 * @param[in] S points to an instance of the floating-point IIR lattice structure. 1434 * @param[in] numStages number of stages in the filter. 1435 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 1436 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 1437 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1. 1438 * @param[in] blockSize number of samples to process. 1439 */ 1440 void arm_iir_lattice_init_f32( 1441 arm_iir_lattice_instance_f32 * S, 1442 uint16_t numStages, 1443 float32_t * pkCoeffs, 1444 float32_t * pvCoeffs, 1445 float32_t * pState, 1446 uint32_t blockSize); 1447 1448 1449 /** 1450 * @brief Processing function for the Q31 IIR lattice filter. 1451 * @param[in] S points to an instance of the Q31 IIR lattice structure. 1452 * @param[in] pSrc points to the block of input data. 1453 * @param[out] pDst points to the block of output data. 1454 * @param[in] blockSize number of samples to process. 1455 */ 1456 void arm_iir_lattice_q31( 1457 const arm_iir_lattice_instance_q31 * S, 1458 const q31_t * pSrc, 1459 q31_t * pDst, 1460 uint32_t blockSize); 1461 1462 1463 /** 1464 * @brief Initialization function for the Q31 IIR lattice filter. 1465 * @param[in] S points to an instance of the Q31 IIR lattice structure. 1466 * @param[in] numStages number of stages in the filter. 1467 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 1468 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 1469 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize. 1470 * @param[in] blockSize number of samples to process. 1471 */ 1472 void arm_iir_lattice_init_q31( 1473 arm_iir_lattice_instance_q31 * S, 1474 uint16_t numStages, 1475 q31_t * pkCoeffs, 1476 q31_t * pvCoeffs, 1477 q31_t * pState, 1478 uint32_t blockSize); 1479 1480 1481 /** 1482 * @brief Processing function for the Q15 IIR lattice filter. 1483 * @param[in] S points to an instance of the Q15 IIR lattice structure. 1484 * @param[in] pSrc points to the block of input data. 1485 * @param[out] pDst points to the block of output data. 1486 * @param[in] blockSize number of samples to process. 1487 */ 1488 void arm_iir_lattice_q15( 1489 const arm_iir_lattice_instance_q15 * S, 1490 const q15_t * pSrc, 1491 q15_t * pDst, 1492 uint32_t blockSize); 1493 1494 1495 /** 1496 * @brief Initialization function for the Q15 IIR lattice filter. 1497 * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure. 1498 * @param[in] numStages number of stages in the filter. 1499 * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages. 1500 * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1. 1501 * @param[in] pState points to state buffer. The array is of length numStages+blockSize. 1502 * @param[in] blockSize number of samples to process per call. 1503 */ 1504 void arm_iir_lattice_init_q15( 1505 arm_iir_lattice_instance_q15 * S, 1506 uint16_t numStages, 1507 q15_t * pkCoeffs, 1508 q15_t * pvCoeffs, 1509 q15_t * pState, 1510 uint32_t blockSize); 1511 1512 1513 /** 1514 * @brief Instance structure for the floating-point LMS filter. 1515 */ 1516 typedef struct 1517 { 1518 uint16_t numTaps; /**< number of coefficients in the filter. */ 1519 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1520 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1521 float32_t mu; /**< step size that controls filter coefficient updates. */ 1522 } arm_lms_instance_f32; 1523 1524 1525 /** 1526 * @brief Processing function for floating-point LMS filter. 1527 * @param[in] S points to an instance of the floating-point LMS filter structure. 1528 * @param[in] pSrc points to the block of input data. 1529 * @param[in] pRef points to the block of reference data. 1530 * @param[out] pOut points to the block of output data. 1531 * @param[out] pErr points to the block of error data. 1532 * @param[in] blockSize number of samples to process. 1533 */ 1534 void arm_lms_f32( 1535 const arm_lms_instance_f32 * S, 1536 const float32_t * pSrc, 1537 float32_t * pRef, 1538 float32_t * pOut, 1539 float32_t * pErr, 1540 uint32_t blockSize); 1541 1542 1543 /** 1544 * @brief Initialization function for floating-point LMS filter. 1545 * @param[in] S points to an instance of the floating-point LMS filter structure. 1546 * @param[in] numTaps number of filter coefficients. 1547 * @param[in] pCoeffs points to the coefficient buffer. 1548 * @param[in] pState points to state buffer. 1549 * @param[in] mu step size that controls filter coefficient updates. 1550 * @param[in] blockSize number of samples to process. 1551 */ 1552 void arm_lms_init_f32( 1553 arm_lms_instance_f32 * S, 1554 uint16_t numTaps, 1555 float32_t * pCoeffs, 1556 float32_t * pState, 1557 float32_t mu, 1558 uint32_t blockSize); 1559 1560 1561 /** 1562 * @brief Instance structure for the Q15 LMS filter. 1563 */ 1564 typedef struct 1565 { 1566 uint16_t numTaps; /**< number of coefficients in the filter. */ 1567 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1568 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1569 q15_t mu; /**< step size that controls filter coefficient updates. */ 1570 uint32_t postShift; /**< bit shift applied to coefficients. */ 1571 } arm_lms_instance_q15; 1572 1573 1574 /** 1575 * @brief Initialization function for the Q15 LMS filter. 1576 * @param[in] S points to an instance of the Q15 LMS filter structure. 1577 * @param[in] numTaps number of filter coefficients. 1578 * @param[in] pCoeffs points to the coefficient buffer. 1579 * @param[in] pState points to the state buffer. 1580 * @param[in] mu step size that controls filter coefficient updates. 1581 * @param[in] blockSize number of samples to process. 1582 * @param[in] postShift bit shift applied to coefficients. 1583 */ 1584 void arm_lms_init_q15( 1585 arm_lms_instance_q15 * S, 1586 uint16_t numTaps, 1587 q15_t * pCoeffs, 1588 q15_t * pState, 1589 q15_t mu, 1590 uint32_t blockSize, 1591 uint32_t postShift); 1592 1593 1594 /** 1595 * @brief Processing function for Q15 LMS filter. 1596 * @param[in] S points to an instance of the Q15 LMS filter structure. 1597 * @param[in] pSrc points to the block of input data. 1598 * @param[in] pRef points to the block of reference data. 1599 * @param[out] pOut points to the block of output data. 1600 * @param[out] pErr points to the block of error data. 1601 * @param[in] blockSize number of samples to process. 1602 */ 1603 void arm_lms_q15( 1604 const arm_lms_instance_q15 * S, 1605 const q15_t * pSrc, 1606 q15_t * pRef, 1607 q15_t * pOut, 1608 q15_t * pErr, 1609 uint32_t blockSize); 1610 1611 1612 /** 1613 * @brief Instance structure for the Q31 LMS filter. 1614 */ 1615 typedef struct 1616 { 1617 uint16_t numTaps; /**< number of coefficients in the filter. */ 1618 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1619 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1620 q31_t mu; /**< step size that controls filter coefficient updates. */ 1621 uint32_t postShift; /**< bit shift applied to coefficients. */ 1622 } arm_lms_instance_q31; 1623 1624 1625 /** 1626 * @brief Processing function for Q31 LMS filter. 1627 * @param[in] S points to an instance of the Q15 LMS filter structure. 1628 * @param[in] pSrc points to the block of input data. 1629 * @param[in] pRef points to the block of reference data. 1630 * @param[out] pOut points to the block of output data. 1631 * @param[out] pErr points to the block of error data. 1632 * @param[in] blockSize number of samples to process. 1633 */ 1634 void arm_lms_q31( 1635 const arm_lms_instance_q31 * S, 1636 const q31_t * pSrc, 1637 q31_t * pRef, 1638 q31_t * pOut, 1639 q31_t * pErr, 1640 uint32_t blockSize); 1641 1642 1643 /** 1644 * @brief Initialization function for Q31 LMS filter. 1645 * @param[in] S points to an instance of the Q31 LMS filter structure. 1646 * @param[in] numTaps number of filter coefficients. 1647 * @param[in] pCoeffs points to coefficient buffer. 1648 * @param[in] pState points to state buffer. 1649 * @param[in] mu step size that controls filter coefficient updates. 1650 * @param[in] blockSize number of samples to process. 1651 * @param[in] postShift bit shift applied to coefficients. 1652 */ 1653 void arm_lms_init_q31( 1654 arm_lms_instance_q31 * S, 1655 uint16_t numTaps, 1656 q31_t * pCoeffs, 1657 q31_t * pState, 1658 q31_t mu, 1659 uint32_t blockSize, 1660 uint32_t postShift); 1661 1662 1663 /** 1664 * @brief Instance structure for the floating-point normalized LMS filter. 1665 */ 1666 typedef struct 1667 { 1668 uint16_t numTaps; /**< number of coefficients in the filter. */ 1669 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1670 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1671 float32_t mu; /**< step size that control filter coefficient updates. */ 1672 float32_t energy; /**< saves previous frame energy. */ 1673 float32_t x0; /**< saves previous input sample. */ 1674 } arm_lms_norm_instance_f32; 1675 1676 1677 /** 1678 * @brief Processing function for floating-point normalized LMS filter. 1679 * @param[in] S points to an instance of the floating-point normalized LMS filter structure. 1680 * @param[in] pSrc points to the block of input data. 1681 * @param[in] pRef points to the block of reference data. 1682 * @param[out] pOut points to the block of output data. 1683 * @param[out] pErr points to the block of error data. 1684 * @param[in] blockSize number of samples to process. 1685 */ 1686 void arm_lms_norm_f32( 1687 arm_lms_norm_instance_f32 * S, 1688 const float32_t * pSrc, 1689 float32_t * pRef, 1690 float32_t * pOut, 1691 float32_t * pErr, 1692 uint32_t blockSize); 1693 1694 1695 /** 1696 * @brief Initialization function for floating-point normalized LMS filter. 1697 * @param[in] S points to an instance of the floating-point LMS filter structure. 1698 * @param[in] numTaps number of filter coefficients. 1699 * @param[in] pCoeffs points to coefficient buffer. 1700 * @param[in] pState points to state buffer. 1701 * @param[in] mu step size that controls filter coefficient updates. 1702 * @param[in] blockSize number of samples to process. 1703 */ 1704 void arm_lms_norm_init_f32( 1705 arm_lms_norm_instance_f32 * S, 1706 uint16_t numTaps, 1707 float32_t * pCoeffs, 1708 float32_t * pState, 1709 float32_t mu, 1710 uint32_t blockSize); 1711 1712 1713 /** 1714 * @brief Instance structure for the Q31 normalized LMS filter. 1715 */ 1716 typedef struct 1717 { 1718 uint16_t numTaps; /**< number of coefficients in the filter. */ 1719 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1720 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1721 q31_t mu; /**< step size that controls filter coefficient updates. */ 1722 uint8_t postShift; /**< bit shift applied to coefficients. */ 1723 const q31_t *recipTable; /**< points to the reciprocal initial value table. */ 1724 q31_t energy; /**< saves previous frame energy. */ 1725 q31_t x0; /**< saves previous input sample. */ 1726 } arm_lms_norm_instance_q31; 1727 1728 1729 /** 1730 * @brief Processing function for Q31 normalized LMS filter. 1731 * @param[in] S points to an instance of the Q31 normalized LMS filter structure. 1732 * @param[in] pSrc points to the block of input data. 1733 * @param[in] pRef points to the block of reference data. 1734 * @param[out] pOut points to the block of output data. 1735 * @param[out] pErr points to the block of error data. 1736 * @param[in] blockSize number of samples to process. 1737 */ 1738 void arm_lms_norm_q31( 1739 arm_lms_norm_instance_q31 * S, 1740 const q31_t * pSrc, 1741 q31_t * pRef, 1742 q31_t * pOut, 1743 q31_t * pErr, 1744 uint32_t blockSize); 1745 1746 1747 /** 1748 * @brief Initialization function for Q31 normalized LMS filter. 1749 * @param[in] S points to an instance of the Q31 normalized LMS filter structure. 1750 * @param[in] numTaps number of filter coefficients. 1751 * @param[in] pCoeffs points to coefficient buffer. 1752 * @param[in] pState points to state buffer. 1753 * @param[in] mu step size that controls filter coefficient updates. 1754 * @param[in] blockSize number of samples to process. 1755 * @param[in] postShift bit shift applied to coefficients. 1756 */ 1757 void arm_lms_norm_init_q31( 1758 arm_lms_norm_instance_q31 * S, 1759 uint16_t numTaps, 1760 q31_t * pCoeffs, 1761 q31_t * pState, 1762 q31_t mu, 1763 uint32_t blockSize, 1764 uint8_t postShift); 1765 1766 1767 /** 1768 * @brief Instance structure for the Q15 normalized LMS filter. 1769 */ 1770 typedef struct 1771 { 1772 uint16_t numTaps; /**< Number of coefficients in the filter. */ 1773 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1774 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1775 q15_t mu; /**< step size that controls filter coefficient updates. */ 1776 uint8_t postShift; /**< bit shift applied to coefficients. */ 1777 const q15_t *recipTable; /**< Points to the reciprocal initial value table. */ 1778 q15_t energy; /**< saves previous frame energy. */ 1779 q15_t x0; /**< saves previous input sample. */ 1780 } arm_lms_norm_instance_q15; 1781 1782 1783 /** 1784 * @brief Processing function for Q15 normalized LMS filter. 1785 * @param[in] S points to an instance of the Q15 normalized LMS filter structure. 1786 * @param[in] pSrc points to the block of input data. 1787 * @param[in] pRef points to the block of reference data. 1788 * @param[out] pOut points to the block of output data. 1789 * @param[out] pErr points to the block of error data. 1790 * @param[in] blockSize number of samples to process. 1791 */ 1792 void arm_lms_norm_q15( 1793 arm_lms_norm_instance_q15 * S, 1794 const q15_t * pSrc, 1795 q15_t * pRef, 1796 q15_t * pOut, 1797 q15_t * pErr, 1798 uint32_t blockSize); 1799 1800 1801 /** 1802 * @brief Initialization function for Q15 normalized LMS filter. 1803 * @param[in] S points to an instance of the Q15 normalized LMS filter structure. 1804 * @param[in] numTaps number of filter coefficients. 1805 * @param[in] pCoeffs points to coefficient buffer. 1806 * @param[in] pState points to state buffer. 1807 * @param[in] mu step size that controls filter coefficient updates. 1808 * @param[in] blockSize number of samples to process. 1809 * @param[in] postShift bit shift applied to coefficients. 1810 */ 1811 void arm_lms_norm_init_q15( 1812 arm_lms_norm_instance_q15 * S, 1813 uint16_t numTaps, 1814 q15_t * pCoeffs, 1815 q15_t * pState, 1816 q15_t mu, 1817 uint32_t blockSize, 1818 uint8_t postShift); 1819 1820 1821 /** 1822 * @brief Correlation of floating-point sequences. 1823 * @param[in] pSrcA points to the first input sequence. 1824 * @param[in] srcALen length of the first input sequence. 1825 * @param[in] pSrcB points to the second input sequence. 1826 * @param[in] srcBLen length of the second input sequence. 1827 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1828 */ 1829 void arm_correlate_f32( 1830 const float32_t * pSrcA, 1831 uint32_t srcALen, 1832 const float32_t * pSrcB, 1833 uint32_t srcBLen, 1834 float32_t * pDst); 1835 1836 1837 /** 1838 * @brief Correlation of floating-point sequences. 1839 * @param[in] pSrcA points to the first input sequence. 1840 * @param[in] srcALen length of the first input sequence. 1841 * @param[in] pSrcB points to the second input sequence. 1842 * @param[in] srcBLen length of the second input sequence. 1843 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1844 */ 1845 void arm_correlate_f64( 1846 const float64_t * pSrcA, 1847 uint32_t srcALen, 1848 const float64_t * pSrcB, 1849 uint32_t srcBLen, 1850 float64_t * pDst); 1851 1852 1853 /** 1854 @brief Correlation of Q15 sequences 1855 @param[in] pSrcA points to the first input sequence 1856 @param[in] srcALen length of the first input sequence 1857 @param[in] pSrcB points to the second input sequence 1858 @param[in] srcBLen length of the second input sequence 1859 @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1860 @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 1861 */ 1862 void arm_correlate_opt_q15( 1863 const q15_t * pSrcA, 1864 uint32_t srcALen, 1865 const q15_t * pSrcB, 1866 uint32_t srcBLen, 1867 q15_t * pDst, 1868 q15_t * pScratch); 1869 1870 1871 /** 1872 @brief Correlation of Q15 sequences. 1873 @param[in] pSrcA points to the first input sequence 1874 @param[in] srcALen length of the first input sequence 1875 @param[in] pSrcB points to the second input sequence 1876 @param[in] srcBLen length of the second input sequence 1877 @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1878 */ 1879 void arm_correlate_q15( 1880 const q15_t * pSrcA, 1881 uint32_t srcALen, 1882 const q15_t * pSrcB, 1883 uint32_t srcBLen, 1884 q15_t * pDst); 1885 1886 1887 /** 1888 @brief Correlation of Q15 sequences (fast version). 1889 @param[in] pSrcA points to the first input sequence 1890 @param[in] srcALen length of the first input sequence 1891 @param[in] pSrcB points to the second input sequence 1892 @param[in] srcBLen length of the second input sequence 1893 @param[out] pDst points to the location where the output result is written. Length 2 * max(srcALen, srcBLen) - 1. 1894 @return none 1895 */ 1896 void arm_correlate_fast_q15( 1897 const q15_t * pSrcA, 1898 uint32_t srcALen, 1899 const q15_t * pSrcB, 1900 uint32_t srcBLen, 1901 q15_t * pDst); 1902 1903 1904 /** 1905 @brief Correlation of Q15 sequences (fast version). 1906 @param[in] pSrcA points to the first input sequence. 1907 @param[in] srcALen length of the first input sequence. 1908 @param[in] pSrcB points to the second input sequence. 1909 @param[in] srcBLen length of the second input sequence. 1910 @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1911 @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 1912 */ 1913 void arm_correlate_fast_opt_q15( 1914 const q15_t * pSrcA, 1915 uint32_t srcALen, 1916 const q15_t * pSrcB, 1917 uint32_t srcBLen, 1918 q15_t * pDst, 1919 q15_t * pScratch); 1920 1921 1922 /** 1923 * @brief Correlation of Q31 sequences. 1924 * @param[in] pSrcA points to the first input sequence. 1925 * @param[in] srcALen length of the first input sequence. 1926 * @param[in] pSrcB points to the second input sequence. 1927 * @param[in] srcBLen length of the second input sequence. 1928 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1929 */ 1930 void arm_correlate_q31( 1931 const q31_t * pSrcA, 1932 uint32_t srcALen, 1933 const q31_t * pSrcB, 1934 uint32_t srcBLen, 1935 q31_t * pDst); 1936 1937 1938 /** 1939 @brief Correlation of Q31 sequences (fast version). 1940 @param[in] pSrcA points to the first input sequence 1941 @param[in] srcALen length of the first input sequence 1942 @param[in] pSrcB points to the second input sequence 1943 @param[in] srcBLen length of the second input sequence 1944 @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1945 */ 1946 void arm_correlate_fast_q31( 1947 const q31_t * pSrcA, 1948 uint32_t srcALen, 1949 const q31_t * pSrcB, 1950 uint32_t srcBLen, 1951 q31_t * pDst); 1952 1953 1954 /** 1955 * @brief Correlation of Q7 sequences. 1956 * @param[in] pSrcA points to the first input sequence. 1957 * @param[in] srcALen length of the first input sequence. 1958 * @param[in] pSrcB points to the second input sequence. 1959 * @param[in] srcBLen length of the second input sequence. 1960 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1961 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 1962 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). 1963 */ 1964 void arm_correlate_opt_q7( 1965 const q7_t * pSrcA, 1966 uint32_t srcALen, 1967 const q7_t * pSrcB, 1968 uint32_t srcBLen, 1969 q7_t * pDst, 1970 q15_t * pScratch1, 1971 q15_t * pScratch2); 1972 1973 1974 /** 1975 * @brief Correlation of Q7 sequences. 1976 * @param[in] pSrcA points to the first input sequence. 1977 * @param[in] srcALen length of the first input sequence. 1978 * @param[in] pSrcB points to the second input sequence. 1979 * @param[in] srcBLen length of the second input sequence. 1980 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1981 */ 1982 void arm_correlate_q7( 1983 const q7_t * pSrcA, 1984 uint32_t srcALen, 1985 const q7_t * pSrcB, 1986 uint32_t srcBLen, 1987 q7_t * pDst); 1988 1989 1990 /** 1991 * @brief Instance structure for the floating-point sparse FIR filter. 1992 */ 1993 typedef struct 1994 { 1995 uint16_t numTaps; /**< number of coefficients in the filter. */ 1996 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 1997 float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 1998 const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 1999 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 2000 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 2001 } arm_fir_sparse_instance_f32; 2002 2003 /** 2004 * @brief Instance structure for the Q31 sparse FIR filter. 2005 */ 2006 typedef struct 2007 { 2008 uint16_t numTaps; /**< number of coefficients in the filter. */ 2009 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 2010 q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 2011 const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 2012 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 2013 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 2014 } arm_fir_sparse_instance_q31; 2015 2016 /** 2017 * @brief Instance structure for the Q15 sparse FIR filter. 2018 */ 2019 typedef struct 2020 { 2021 uint16_t numTaps; /**< number of coefficients in the filter. */ 2022 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 2023 q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 2024 const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 2025 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 2026 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 2027 } arm_fir_sparse_instance_q15; 2028 2029 /** 2030 * @brief Instance structure for the Q7 sparse FIR filter. 2031 */ 2032 typedef struct 2033 { 2034 uint16_t numTaps; /**< number of coefficients in the filter. */ 2035 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 2036 q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 2037 const q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 2038 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 2039 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 2040 } arm_fir_sparse_instance_q7; 2041 2042 2043 /** 2044 * @brief Processing function for the floating-point sparse FIR filter. 2045 * @param[in] S points to an instance of the floating-point sparse FIR structure. 2046 * @param[in] pSrc points to the block of input data. 2047 * @param[out] pDst points to the block of output data 2048 * @param[in] pScratchIn points to a temporary buffer of size blockSize. 2049 * @param[in] blockSize number of input samples to process per call. 2050 */ 2051 void arm_fir_sparse_f32( 2052 arm_fir_sparse_instance_f32 * S, 2053 const float32_t * pSrc, 2054 float32_t * pDst, 2055 float32_t * pScratchIn, 2056 uint32_t blockSize); 2057 2058 2059 /** 2060 * @brief Initialization function for the floating-point sparse FIR filter. 2061 * @param[in,out] S points to an instance of the floating-point sparse FIR structure. 2062 * @param[in] numTaps number of nonzero coefficients in the filter. 2063 * @param[in] pCoeffs points to the array of filter coefficients. 2064 * @param[in] pState points to the state buffer. 2065 * @param[in] pTapDelay points to the array of offset times. 2066 * @param[in] maxDelay maximum offset time supported. 2067 * @param[in] blockSize number of samples that will be processed per block. 2068 */ 2069 void arm_fir_sparse_init_f32( 2070 arm_fir_sparse_instance_f32 * S, 2071 uint16_t numTaps, 2072 const float32_t * pCoeffs, 2073 float32_t * pState, 2074 int32_t * pTapDelay, 2075 uint16_t maxDelay, 2076 uint32_t blockSize); 2077 2078 2079 /** 2080 * @brief Processing function for the Q31 sparse FIR filter. 2081 * @param[in] S points to an instance of the Q31 sparse FIR structure. 2082 * @param[in] pSrc points to the block of input data. 2083 * @param[out] pDst points to the block of output data 2084 * @param[in] pScratchIn points to a temporary buffer of size blockSize. 2085 * @param[in] blockSize number of input samples to process per call. 2086 */ 2087 void arm_fir_sparse_q31( 2088 arm_fir_sparse_instance_q31 * S, 2089 const q31_t * pSrc, 2090 q31_t * pDst, 2091 q31_t * pScratchIn, 2092 uint32_t blockSize); 2093 2094 2095 /** 2096 * @brief Initialization function for the Q31 sparse FIR filter. 2097 * @param[in,out] S points to an instance of the Q31 sparse FIR structure. 2098 * @param[in] numTaps number of nonzero coefficients in the filter. 2099 * @param[in] pCoeffs points to the array of filter coefficients. 2100 * @param[in] pState points to the state buffer. 2101 * @param[in] pTapDelay points to the array of offset times. 2102 * @param[in] maxDelay maximum offset time supported. 2103 * @param[in] blockSize number of samples that will be processed per block. 2104 */ 2105 void arm_fir_sparse_init_q31( 2106 arm_fir_sparse_instance_q31 * S, 2107 uint16_t numTaps, 2108 const q31_t * pCoeffs, 2109 q31_t * pState, 2110 int32_t * pTapDelay, 2111 uint16_t maxDelay, 2112 uint32_t blockSize); 2113 2114 2115 /** 2116 * @brief Processing function for the Q15 sparse FIR filter. 2117 * @param[in] S points to an instance of the Q15 sparse FIR structure. 2118 * @param[in] pSrc points to the block of input data. 2119 * @param[out] pDst points to the block of output data 2120 * @param[in] pScratchIn points to a temporary buffer of size blockSize. 2121 * @param[in] pScratchOut points to a temporary buffer of size blockSize. 2122 * @param[in] blockSize number of input samples to process per call. 2123 */ 2124 void arm_fir_sparse_q15( 2125 arm_fir_sparse_instance_q15 * S, 2126 const q15_t * pSrc, 2127 q15_t * pDst, 2128 q15_t * pScratchIn, 2129 q31_t * pScratchOut, 2130 uint32_t blockSize); 2131 2132 2133 /** 2134 * @brief Initialization function for the Q15 sparse FIR filter. 2135 * @param[in,out] S points to an instance of the Q15 sparse FIR structure. 2136 * @param[in] numTaps number of nonzero coefficients in the filter. 2137 * @param[in] pCoeffs points to the array of filter coefficients. 2138 * @param[in] pState points to the state buffer. 2139 * @param[in] pTapDelay points to the array of offset times. 2140 * @param[in] maxDelay maximum offset time supported. 2141 * @param[in] blockSize number of samples that will be processed per block. 2142 */ 2143 void arm_fir_sparse_init_q15( 2144 arm_fir_sparse_instance_q15 * S, 2145 uint16_t numTaps, 2146 const q15_t * pCoeffs, 2147 q15_t * pState, 2148 int32_t * pTapDelay, 2149 uint16_t maxDelay, 2150 uint32_t blockSize); 2151 2152 2153 /** 2154 * @brief Processing function for the Q7 sparse FIR filter. 2155 * @param[in] S points to an instance of the Q7 sparse FIR structure. 2156 * @param[in] pSrc points to the block of input data. 2157 * @param[out] pDst points to the block of output data 2158 * @param[in] pScratchIn points to a temporary buffer of size blockSize. 2159 * @param[in] pScratchOut points to a temporary buffer of size blockSize. 2160 * @param[in] blockSize number of input samples to process per call. 2161 */ 2162 void arm_fir_sparse_q7( 2163 arm_fir_sparse_instance_q7 * S, 2164 const q7_t * pSrc, 2165 q7_t * pDst, 2166 q7_t * pScratchIn, 2167 q31_t * pScratchOut, 2168 uint32_t blockSize); 2169 2170 2171 /** 2172 * @brief Initialization function for the Q7 sparse FIR filter. 2173 * @param[in,out] S points to an instance of the Q7 sparse FIR structure. 2174 * @param[in] numTaps number of nonzero coefficients in the filter. 2175 * @param[in] pCoeffs points to the array of filter coefficients. 2176 * @param[in] pState points to the state buffer. 2177 * @param[in] pTapDelay points to the array of offset times. 2178 * @param[in] maxDelay maximum offset time supported. 2179 * @param[in] blockSize number of samples that will be processed per block. 2180 */ 2181 void arm_fir_sparse_init_q7( 2182 arm_fir_sparse_instance_q7 * S, 2183 uint16_t numTaps, 2184 const q7_t * pCoeffs, 2185 q7_t * pState, 2186 int32_t * pTapDelay, 2187 uint16_t maxDelay, 2188 uint32_t blockSize); 2189 2190 2191 2192 2193 2194 2195 /** 2196 * @brief floating-point Circular write function. 2197 */ arm_circularWrite_f32(int32_t * circBuffer,int32_t L,uint16_t * writeOffset,int32_t bufferInc,const int32_t * src,int32_t srcInc,uint32_t blockSize)2198 __STATIC_FORCEINLINE void arm_circularWrite_f32( 2199 int32_t * circBuffer, 2200 int32_t L, 2201 uint16_t * writeOffset, 2202 int32_t bufferInc, 2203 const int32_t * src, 2204 int32_t srcInc, 2205 uint32_t blockSize) 2206 { 2207 uint32_t i = 0U; 2208 int32_t wOffset; 2209 2210 /* Copy the value of Index pointer that points 2211 * to the current location where the input samples to be copied */ 2212 wOffset = *writeOffset; 2213 2214 /* Loop over the blockSize */ 2215 i = blockSize; 2216 2217 while (i > 0U) 2218 { 2219 /* copy the input sample to the circular buffer */ 2220 circBuffer[wOffset] = *src; 2221 2222 /* Update the input pointer */ 2223 src += srcInc; 2224 2225 /* Circularly update wOffset. Watch out for positive and negative value */ 2226 wOffset += bufferInc; 2227 if (wOffset >= L) 2228 wOffset -= L; 2229 2230 /* Decrement the loop counter */ 2231 i--; 2232 } 2233 2234 /* Update the index pointer */ 2235 *writeOffset = (uint16_t)wOffset; 2236 } 2237 2238 2239 2240 /** 2241 * @brief floating-point Circular Read function. 2242 */ arm_circularRead_f32(int32_t * circBuffer,int32_t L,int32_t * readOffset,int32_t bufferInc,int32_t * dst,int32_t * dst_base,int32_t dst_length,int32_t dstInc,uint32_t blockSize)2243 __STATIC_FORCEINLINE void arm_circularRead_f32( 2244 int32_t * circBuffer, 2245 int32_t L, 2246 int32_t * readOffset, 2247 int32_t bufferInc, 2248 int32_t * dst, 2249 int32_t * dst_base, 2250 int32_t dst_length, 2251 int32_t dstInc, 2252 uint32_t blockSize) 2253 { 2254 uint32_t i = 0U; 2255 int32_t rOffset; 2256 int32_t* dst_end; 2257 2258 /* Copy the value of Index pointer that points 2259 * to the current location from where the input samples to be read */ 2260 rOffset = *readOffset; 2261 dst_end = dst_base + dst_length; 2262 2263 /* Loop over the blockSize */ 2264 i = blockSize; 2265 2266 while (i > 0U) 2267 { 2268 /* copy the sample from the circular buffer to the destination buffer */ 2269 *dst = circBuffer[rOffset]; 2270 2271 /* Update the input pointer */ 2272 dst += dstInc; 2273 2274 if (dst == dst_end) 2275 { 2276 dst = dst_base; 2277 } 2278 2279 /* Circularly update rOffset. Watch out for positive and negative value */ 2280 rOffset += bufferInc; 2281 2282 if (rOffset >= L) 2283 { 2284 rOffset -= L; 2285 } 2286 2287 /* Decrement the loop counter */ 2288 i--; 2289 } 2290 2291 /* Update the index pointer */ 2292 *readOffset = rOffset; 2293 } 2294 2295 2296 /** 2297 * @brief Q15 Circular write function. 2298 */ arm_circularWrite_q15(q15_t * circBuffer,int32_t L,uint16_t * writeOffset,int32_t bufferInc,const q15_t * src,int32_t srcInc,uint32_t blockSize)2299 __STATIC_FORCEINLINE void arm_circularWrite_q15( 2300 q15_t * circBuffer, 2301 int32_t L, 2302 uint16_t * writeOffset, 2303 int32_t bufferInc, 2304 const q15_t * src, 2305 int32_t srcInc, 2306 uint32_t blockSize) 2307 { 2308 uint32_t i = 0U; 2309 int32_t wOffset; 2310 2311 /* Copy the value of Index pointer that points 2312 * to the current location where the input samples to be copied */ 2313 wOffset = *writeOffset; 2314 2315 /* Loop over the blockSize */ 2316 i = blockSize; 2317 2318 while (i > 0U) 2319 { 2320 /* copy the input sample to the circular buffer */ 2321 circBuffer[wOffset] = *src; 2322 2323 /* Update the input pointer */ 2324 src += srcInc; 2325 2326 /* Circularly update wOffset. Watch out for positive and negative value */ 2327 wOffset += bufferInc; 2328 if (wOffset >= L) 2329 wOffset -= L; 2330 2331 /* Decrement the loop counter */ 2332 i--; 2333 } 2334 2335 /* Update the index pointer */ 2336 *writeOffset = (uint16_t)wOffset; 2337 } 2338 2339 2340 /** 2341 * @brief Q15 Circular Read function. 2342 */ arm_circularRead_q15(q15_t * circBuffer,int32_t L,int32_t * readOffset,int32_t bufferInc,q15_t * dst,q15_t * dst_base,int32_t dst_length,int32_t dstInc,uint32_t blockSize)2343 __STATIC_FORCEINLINE void arm_circularRead_q15( 2344 q15_t * circBuffer, 2345 int32_t L, 2346 int32_t * readOffset, 2347 int32_t bufferInc, 2348 q15_t * dst, 2349 q15_t * dst_base, 2350 int32_t dst_length, 2351 int32_t dstInc, 2352 uint32_t blockSize) 2353 { 2354 uint32_t i = 0; 2355 int32_t rOffset; 2356 q15_t* dst_end; 2357 2358 /* Copy the value of Index pointer that points 2359 * to the current location from where the input samples to be read */ 2360 rOffset = *readOffset; 2361 2362 dst_end = dst_base + dst_length; 2363 2364 /* Loop over the blockSize */ 2365 i = blockSize; 2366 2367 while (i > 0U) 2368 { 2369 /* copy the sample from the circular buffer to the destination buffer */ 2370 *dst = circBuffer[rOffset]; 2371 2372 /* Update the input pointer */ 2373 dst += dstInc; 2374 2375 if (dst == dst_end) 2376 { 2377 dst = dst_base; 2378 } 2379 2380 /* Circularly update wOffset. Watch out for positive and negative value */ 2381 rOffset += bufferInc; 2382 2383 if (rOffset >= L) 2384 { 2385 rOffset -= L; 2386 } 2387 2388 /* Decrement the loop counter */ 2389 i--; 2390 } 2391 2392 /* Update the index pointer */ 2393 *readOffset = rOffset; 2394 } 2395 2396 2397 /** 2398 * @brief Q7 Circular write function. 2399 */ arm_circularWrite_q7(q7_t * circBuffer,int32_t L,uint16_t * writeOffset,int32_t bufferInc,const q7_t * src,int32_t srcInc,uint32_t blockSize)2400 __STATIC_FORCEINLINE void arm_circularWrite_q7( 2401 q7_t * circBuffer, 2402 int32_t L, 2403 uint16_t * writeOffset, 2404 int32_t bufferInc, 2405 const q7_t * src, 2406 int32_t srcInc, 2407 uint32_t blockSize) 2408 { 2409 uint32_t i = 0U; 2410 int32_t wOffset; 2411 2412 /* Copy the value of Index pointer that points 2413 * to the current location where the input samples to be copied */ 2414 wOffset = *writeOffset; 2415 2416 /* Loop over the blockSize */ 2417 i = blockSize; 2418 2419 while (i > 0U) 2420 { 2421 /* copy the input sample to the circular buffer */ 2422 circBuffer[wOffset] = *src; 2423 2424 /* Update the input pointer */ 2425 src += srcInc; 2426 2427 /* Circularly update wOffset. Watch out for positive and negative value */ 2428 wOffset += bufferInc; 2429 if (wOffset >= L) 2430 wOffset -= L; 2431 2432 /* Decrement the loop counter */ 2433 i--; 2434 } 2435 2436 /* Update the index pointer */ 2437 *writeOffset = (uint16_t)wOffset; 2438 } 2439 2440 2441 /** 2442 * @brief Q7 Circular Read function. 2443 */ arm_circularRead_q7(q7_t * circBuffer,int32_t L,int32_t * readOffset,int32_t bufferInc,q7_t * dst,q7_t * dst_base,int32_t dst_length,int32_t dstInc,uint32_t blockSize)2444 __STATIC_FORCEINLINE void arm_circularRead_q7( 2445 q7_t * circBuffer, 2446 int32_t L, 2447 int32_t * readOffset, 2448 int32_t bufferInc, 2449 q7_t * dst, 2450 q7_t * dst_base, 2451 int32_t dst_length, 2452 int32_t dstInc, 2453 uint32_t blockSize) 2454 { 2455 uint32_t i = 0; 2456 int32_t rOffset; 2457 q7_t* dst_end; 2458 2459 /* Copy the value of Index pointer that points 2460 * to the current location from where the input samples to be read */ 2461 rOffset = *readOffset; 2462 2463 dst_end = dst_base + dst_length; 2464 2465 /* Loop over the blockSize */ 2466 i = blockSize; 2467 2468 while (i > 0U) 2469 { 2470 /* copy the sample from the circular buffer to the destination buffer */ 2471 *dst = circBuffer[rOffset]; 2472 2473 /* Update the input pointer */ 2474 dst += dstInc; 2475 2476 if (dst == dst_end) 2477 { 2478 dst = dst_base; 2479 } 2480 2481 /* Circularly update rOffset. Watch out for positive and negative value */ 2482 rOffset += bufferInc; 2483 2484 if (rOffset >= L) 2485 { 2486 rOffset -= L; 2487 } 2488 2489 /* Decrement the loop counter */ 2490 i--; 2491 } 2492 2493 /* Update the index pointer */ 2494 *readOffset = rOffset; 2495 } 2496 2497 2498 /** 2499 @brief Levinson Durbin 2500 @param[in] phi autocovariance vector starting with lag 0 (length is nbCoefs + 1) 2501 @param[out] a autoregressive coefficients 2502 @param[out] err prediction error (variance) 2503 @param[in] nbCoefs number of autoregressive coefficients 2504 @return none 2505 */ 2506 void arm_levinson_durbin_f32(const float32_t *phi, 2507 float32_t *a, 2508 float32_t *err, 2509 int nbCoefs); 2510 2511 2512 /** 2513 @brief Levinson Durbin 2514 @param[in] phi autocovariance vector starting with lag 0 (length is nbCoefs + 1) 2515 @param[out] a autoregressive coefficients 2516 @param[out] err prediction error (variance) 2517 @param[in] nbCoefs number of autoregressive coefficients 2518 @return none 2519 */ 2520 void arm_levinson_durbin_q31(const q31_t *phi, 2521 q31_t *a, 2522 q31_t *err, 2523 int nbCoefs); 2524 2525 #ifdef __cplusplus 2526 } 2527 #endif 2528 2529 #endif /* ifndef _FILTERING_FUNCTIONS_H_ */ 2530