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 single precision 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 @brief Instance structure for double precision floating-point FIR decimator. 835 */ 836 typedef struct 837 { 838 uint8_t M; /**< decimation factor. */ 839 uint16_t numTaps; /**< number of coefficients in the filter. */ 840 const float64_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 841 float64_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 842 } arm_fir_decimate_instance_f64; 843 844 /** 845 @brief Processing function for floating-point FIR decimator. 846 @param[in] S points to an instance of the floating-point FIR decimator structure 847 @param[in] pSrc points to the block of input data 848 @param[out] pDst points to the block of output data 849 @param[in] blockSize number of samples to process 850 */ 851 void arm_fir_decimate_f64( 852 const arm_fir_decimate_instance_f64 * S, 853 const float64_t * pSrc, 854 float64_t * pDst, 855 uint32_t blockSize); 856 857 858 /** 859 @brief Initialization function for the floating-point FIR decimator. 860 @param[in,out] S points to an instance of the floating-point FIR decimator structure 861 @param[in] numTaps number of coefficients in the filter 862 @param[in] M decimation factor 863 @param[in] pCoeffs points to the filter coefficients 864 @param[in] pState points to the state buffer 865 @param[in] blockSize number of input samples to process per call 866 @return execution status 867 - \ref ARM_MATH_SUCCESS : Operation successful 868 - \ref ARM_MATH_LENGTH_ERROR : <code>blockSize</code> is not a multiple of <code>M</code> 869 */ 870 arm_status arm_fir_decimate_init_f64( 871 arm_fir_decimate_instance_f64 * S, 872 uint16_t numTaps, 873 uint8_t M, 874 const float64_t * pCoeffs, 875 float64_t * pState, 876 uint32_t blockSize); 877 878 879 /** 880 @brief Processing function for floating-point FIR decimator. 881 @param[in] S points to an instance of the floating-point FIR decimator structure 882 @param[in] pSrc points to the block of input data 883 @param[out] pDst points to the block of output data 884 @param[in] blockSize number of samples to process 885 */ 886 void arm_fir_decimate_f32( 887 const arm_fir_decimate_instance_f32 * S, 888 const float32_t * pSrc, 889 float32_t * pDst, 890 uint32_t blockSize); 891 892 893 /** 894 @brief Initialization function for the floating-point FIR decimator. 895 @param[in,out] S points to an instance of the floating-point FIR decimator structure 896 @param[in] numTaps number of coefficients in the filter 897 @param[in] M decimation factor 898 @param[in] pCoeffs points to the filter coefficients 899 @param[in] pState points to the state buffer 900 @param[in] blockSize number of input samples to process per call 901 @return execution status 902 - \ref ARM_MATH_SUCCESS : Operation successful 903 - \ref ARM_MATH_LENGTH_ERROR : <code>blockSize</code> is not a multiple of <code>M</code> 904 */ 905 arm_status arm_fir_decimate_init_f32( 906 arm_fir_decimate_instance_f32 * S, 907 uint16_t numTaps, 908 uint8_t M, 909 const float32_t * pCoeffs, 910 float32_t * pState, 911 uint32_t blockSize); 912 913 914 /** 915 * @brief Processing function for the Q15 FIR decimator. 916 * @param[in] S points to an instance of the Q15 FIR decimator structure. 917 * @param[in] pSrc points to the block of input data. 918 * @param[out] pDst points to the block of output data 919 * @param[in] blockSize number of input samples to process per call. 920 */ 921 void arm_fir_decimate_q15( 922 const arm_fir_decimate_instance_q15 * S, 923 const q15_t * pSrc, 924 q15_t * pDst, 925 uint32_t blockSize); 926 927 928 /** 929 * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. 930 * @param[in] S points to an instance of the Q15 FIR decimator structure. 931 * @param[in] pSrc points to the block of input data. 932 * @param[out] pDst points to the block of output data 933 * @param[in] blockSize number of input samples to process per call. 934 */ 935 void arm_fir_decimate_fast_q15( 936 const arm_fir_decimate_instance_q15 * S, 937 const q15_t * pSrc, 938 q15_t * pDst, 939 uint32_t blockSize); 940 941 942 /** 943 * @brief Initialization function for the Q15 FIR decimator. 944 * @param[in,out] S points to an instance of the Q15 FIR decimator structure. 945 * @param[in] numTaps number of coefficients in the filter. 946 * @param[in] M decimation factor. 947 * @param[in] pCoeffs points to the filter coefficients. 948 * @param[in] pState points to the state buffer. 949 * @param[in] blockSize number of input samples to process per call. 950 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 951 * <code>blockSize</code> is not a multiple of <code>M</code>. 952 */ 953 arm_status arm_fir_decimate_init_q15( 954 arm_fir_decimate_instance_q15 * S, 955 uint16_t numTaps, 956 uint8_t M, 957 const q15_t * pCoeffs, 958 q15_t * pState, 959 uint32_t blockSize); 960 961 962 /** 963 * @brief Processing function for the Q31 FIR decimator. 964 * @param[in] S points to an instance of the Q31 FIR decimator structure. 965 * @param[in] pSrc points to the block of input data. 966 * @param[out] pDst points to the block of output data 967 * @param[in] blockSize number of input samples to process per call. 968 */ 969 void arm_fir_decimate_q31( 970 const arm_fir_decimate_instance_q31 * S, 971 const q31_t * pSrc, 972 q31_t * pDst, 973 uint32_t blockSize); 974 975 /** 976 * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. 977 * @param[in] S points to an instance of the Q31 FIR decimator structure. 978 * @param[in] pSrc points to the block of input data. 979 * @param[out] pDst points to the block of output data 980 * @param[in] blockSize number of input samples to process per call. 981 */ 982 void arm_fir_decimate_fast_q31( 983 const arm_fir_decimate_instance_q31 * S, 984 const q31_t * pSrc, 985 q31_t * pDst, 986 uint32_t blockSize); 987 988 989 /** 990 * @brief Initialization function for the Q31 FIR decimator. 991 * @param[in,out] S points to an instance of the Q31 FIR decimator structure. 992 * @param[in] numTaps number of coefficients in the filter. 993 * @param[in] M decimation factor. 994 * @param[in] pCoeffs points to the filter coefficients. 995 * @param[in] pState points to the state buffer. 996 * @param[in] blockSize number of input samples to process per call. 997 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 998 * <code>blockSize</code> is not a multiple of <code>M</code>. 999 */ 1000 arm_status arm_fir_decimate_init_q31( 1001 arm_fir_decimate_instance_q31 * S, 1002 uint16_t numTaps, 1003 uint8_t M, 1004 const q31_t * pCoeffs, 1005 q31_t * pState, 1006 uint32_t blockSize); 1007 1008 1009 /** 1010 * @brief Instance structure for the Q15 FIR interpolator. 1011 */ 1012 typedef struct 1013 { 1014 uint8_t L; /**< upsample factor. */ 1015 uint16_t phaseLength; /**< length of each polyphase filter component. */ 1016 const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 1017 q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ 1018 } arm_fir_interpolate_instance_q15; 1019 1020 /** 1021 * @brief Instance structure for the Q31 FIR interpolator. 1022 */ 1023 typedef struct 1024 { 1025 uint8_t L; /**< upsample factor. */ 1026 uint16_t phaseLength; /**< length of each polyphase filter component. */ 1027 const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 1028 q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ 1029 } arm_fir_interpolate_instance_q31; 1030 1031 /** 1032 * @brief Instance structure for the floating-point FIR interpolator. 1033 */ 1034 typedef struct 1035 { 1036 uint8_t L; /**< upsample factor. */ 1037 uint16_t phaseLength; /**< length of each polyphase filter component. */ 1038 const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ 1039 float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */ 1040 } arm_fir_interpolate_instance_f32; 1041 1042 1043 /** 1044 * @brief Processing function for the Q15 FIR interpolator. 1045 * @param[in] S points to an instance of the Q15 FIR interpolator structure. 1046 * @param[in] pSrc points to the block of input data. 1047 * @param[out] pDst points to the block of output data. 1048 * @param[in] blockSize number of input samples to process per call. 1049 */ 1050 void arm_fir_interpolate_q15( 1051 const arm_fir_interpolate_instance_q15 * S, 1052 const q15_t * pSrc, 1053 q15_t * pDst, 1054 uint32_t blockSize); 1055 1056 1057 /** 1058 * @brief Initialization function for the Q15 FIR interpolator. 1059 * @param[in,out] S points to an instance of the Q15 FIR interpolator structure. 1060 * @param[in] L upsample factor. 1061 * @param[in] numTaps number of filter coefficients in the filter. 1062 * @param[in] pCoeffs points to the filter coefficient buffer. 1063 * @param[in] pState points to the state buffer. 1064 * @param[in] blockSize number of input samples to process per call. 1065 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 1066 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 1067 */ 1068 arm_status arm_fir_interpolate_init_q15( 1069 arm_fir_interpolate_instance_q15 * S, 1070 uint8_t L, 1071 uint16_t numTaps, 1072 const q15_t * pCoeffs, 1073 q15_t * pState, 1074 uint32_t blockSize); 1075 1076 1077 /** 1078 * @brief Processing function for the Q31 FIR interpolator. 1079 * @param[in] S points to an instance of the Q15 FIR interpolator structure. 1080 * @param[in] pSrc points to the block of input data. 1081 * @param[out] pDst points to the block of output data. 1082 * @param[in] blockSize number of input samples to process per call. 1083 */ 1084 void arm_fir_interpolate_q31( 1085 const arm_fir_interpolate_instance_q31 * S, 1086 const q31_t * pSrc, 1087 q31_t * pDst, 1088 uint32_t blockSize); 1089 1090 1091 /** 1092 * @brief Initialization function for the Q31 FIR interpolator. 1093 * @param[in,out] S points to an instance of the Q31 FIR interpolator structure. 1094 * @param[in] L upsample factor. 1095 * @param[in] numTaps number of filter coefficients in the filter. 1096 * @param[in] pCoeffs points to the filter coefficient buffer. 1097 * @param[in] pState points to the state buffer. 1098 * @param[in] blockSize number of input samples to process per call. 1099 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 1100 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 1101 */ 1102 arm_status arm_fir_interpolate_init_q31( 1103 arm_fir_interpolate_instance_q31 * S, 1104 uint8_t L, 1105 uint16_t numTaps, 1106 const q31_t * pCoeffs, 1107 q31_t * pState, 1108 uint32_t blockSize); 1109 1110 1111 /** 1112 * @brief Processing function for the floating-point FIR interpolator. 1113 * @param[in] S points to an instance of the floating-point FIR interpolator 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 input samples to process per call. 1117 */ 1118 void arm_fir_interpolate_f32( 1119 const arm_fir_interpolate_instance_f32 * S, 1120 const float32_t * pSrc, 1121 float32_t * pDst, 1122 uint32_t blockSize); 1123 1124 1125 /** 1126 * @brief Initialization function for the floating-point FIR interpolator. 1127 * @param[in,out] S points to an instance of the floating-point FIR interpolator structure. 1128 * @param[in] L upsample factor. 1129 * @param[in] numTaps number of filter coefficients in the filter. 1130 * @param[in] pCoeffs points to the filter coefficient buffer. 1131 * @param[in] pState points to the state buffer. 1132 * @param[in] blockSize number of input samples to process per call. 1133 * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if 1134 * the filter length <code>numTaps</code> is not a multiple of the interpolation factor <code>L</code>. 1135 */ 1136 arm_status arm_fir_interpolate_init_f32( 1137 arm_fir_interpolate_instance_f32 * S, 1138 uint8_t L, 1139 uint16_t numTaps, 1140 const float32_t * pCoeffs, 1141 float32_t * pState, 1142 uint32_t blockSize); 1143 1144 1145 /** 1146 * @brief Instance structure for the high precision Q31 Biquad cascade filter. 1147 */ 1148 typedef struct 1149 { 1150 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 1151 q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ 1152 const q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 1153 uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */ 1154 } arm_biquad_cas_df1_32x64_ins_q31; 1155 1156 1157 /** 1158 * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure. 1159 * @param[in] pSrc points to the block of input data. 1160 * @param[out] pDst points to the block of output data 1161 * @param[in] blockSize number of samples to process. 1162 */ 1163 void arm_biquad_cas_df1_32x64_q31( 1164 const arm_biquad_cas_df1_32x64_ins_q31 * S, 1165 const q31_t * pSrc, 1166 q31_t * pDst, 1167 uint32_t blockSize); 1168 1169 1170 /** 1171 * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure. 1172 * @param[in] numStages number of 2nd order stages in the filter. 1173 * @param[in] pCoeffs points to the filter coefficients. 1174 * @param[in] pState points to the state buffer. 1175 * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format 1176 */ 1177 void arm_biquad_cas_df1_32x64_init_q31( 1178 arm_biquad_cas_df1_32x64_ins_q31 * S, 1179 uint8_t numStages, 1180 const q31_t * pCoeffs, 1181 q63_t * pState, 1182 uint8_t postShift); 1183 1184 1185 /** 1186 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. 1187 */ 1188 typedef struct 1189 { 1190 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 1191 float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ 1192 const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 1193 } arm_biquad_cascade_df2T_instance_f32; 1194 1195 /** 1196 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. 1197 */ 1198 typedef struct 1199 { 1200 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 1201 float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ 1202 const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 1203 } arm_biquad_cascade_stereo_df2T_instance_f32; 1204 1205 /** 1206 * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. 1207 */ 1208 typedef struct 1209 { 1210 uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ 1211 float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ 1212 const float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ 1213 } arm_biquad_cascade_df2T_instance_f64; 1214 1215 1216 /** 1217 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 1218 * @param[in] S points to an instance of the filter data structure. 1219 * @param[in] pSrc points to the block of input data. 1220 * @param[out] pDst points to the block of output data 1221 * @param[in] blockSize number of samples to process. 1222 */ 1223 void arm_biquad_cascade_df2T_f32( 1224 const arm_biquad_cascade_df2T_instance_f32 * S, 1225 const float32_t * pSrc, 1226 float32_t * pDst, 1227 uint32_t blockSize); 1228 1229 1230 /** 1231 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels 1232 * @param[in] S points to an instance of the filter data structure. 1233 * @param[in] pSrc points to the block of input data. 1234 * @param[out] pDst points to the block of output data 1235 * @param[in] blockSize number of samples to process. 1236 */ 1237 void arm_biquad_cascade_stereo_df2T_f32( 1238 const arm_biquad_cascade_stereo_df2T_instance_f32 * S, 1239 const float32_t * pSrc, 1240 float32_t * pDst, 1241 uint32_t blockSize); 1242 1243 1244 /** 1245 * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 1246 * @param[in] S points to an instance of the filter data structure. 1247 * @param[in] pSrc points to the block of input data. 1248 * @param[out] pDst points to the block of output data 1249 * @param[in] blockSize number of samples to process. 1250 */ 1251 void arm_biquad_cascade_df2T_f64( 1252 const arm_biquad_cascade_df2T_instance_f64 * S, 1253 const float64_t * pSrc, 1254 float64_t * pDst, 1255 uint32_t blockSize); 1256 1257 1258 #if defined(ARM_MATH_NEON) 1259 /** 1260 @brief Compute new coefficient arrays for use in vectorized filter (Neon only). 1261 @param[in] numStages number of 2nd order stages in the filter. 1262 @param[in] pCoeffs points to the original filter coefficients. 1263 @param[in] pComputedCoeffs points to the new computed coefficients for the vectorized version. 1264 */ 1265 void arm_biquad_cascade_df2T_compute_coefs_f32( 1266 uint8_t numStages, 1267 const float32_t * pCoeffs, 1268 float32_t * pComputedCoeffs); 1269 #endif 1270 /** 1271 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. 1272 * @param[in,out] S points to an instance of the filter data structure. 1273 * @param[in] numStages number of 2nd order stages in the filter. 1274 * @param[in] pCoeffs points to the filter coefficients. 1275 * @param[in] pState points to the state buffer. 1276 */ 1277 void arm_biquad_cascade_df2T_init_f32( 1278 arm_biquad_cascade_df2T_instance_f32 * S, 1279 uint8_t numStages, 1280 const float32_t * pCoeffs, 1281 float32_t * pState); 1282 1283 1284 /** 1285 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. 1286 * @param[in,out] S points to an instance of the filter data structure. 1287 * @param[in] numStages number of 2nd order stages in the filter. 1288 * @param[in] pCoeffs points to the filter coefficients. 1289 * @param[in] pState points to the state buffer. 1290 */ 1291 void arm_biquad_cascade_stereo_df2T_init_f32( 1292 arm_biquad_cascade_stereo_df2T_instance_f32 * S, 1293 uint8_t numStages, 1294 const float32_t * pCoeffs, 1295 float32_t * pState); 1296 1297 1298 /** 1299 * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. 1300 * @param[in,out] S points to an instance of the filter data structure. 1301 * @param[in] numStages number of 2nd order stages in the filter. 1302 * @param[in] pCoeffs points to the filter coefficients. 1303 * @param[in] pState points to the state buffer. 1304 */ 1305 void arm_biquad_cascade_df2T_init_f64( 1306 arm_biquad_cascade_df2T_instance_f64 * S, 1307 uint8_t numStages, 1308 const float64_t * pCoeffs, 1309 float64_t * pState); 1310 1311 1312 /** 1313 * @brief Instance structure for the Q15 FIR lattice filter. 1314 */ 1315 typedef struct 1316 { 1317 uint16_t numStages; /**< number of filter stages. */ 1318 q15_t *pState; /**< points to the state variable array. The array is of length numStages. */ 1319 const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 1320 } arm_fir_lattice_instance_q15; 1321 1322 /** 1323 * @brief Instance structure for the Q31 FIR lattice filter. 1324 */ 1325 typedef struct 1326 { 1327 uint16_t numStages; /**< number of filter stages. */ 1328 q31_t *pState; /**< points to the state variable array. The array is of length numStages. */ 1329 const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 1330 } arm_fir_lattice_instance_q31; 1331 1332 /** 1333 * @brief Instance structure for the floating-point FIR lattice filter. 1334 */ 1335 typedef struct 1336 { 1337 uint16_t numStages; /**< number of filter stages. */ 1338 float32_t *pState; /**< points to the state variable array. The array is of length numStages. */ 1339 const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ 1340 } arm_fir_lattice_instance_f32; 1341 1342 1343 /** 1344 * @brief Initialization function for the Q15 FIR lattice filter. 1345 * @param[in] S points to an instance of the Q15 FIR lattice structure. 1346 * @param[in] numStages number of filter stages. 1347 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. 1348 * @param[in] pState points to the state buffer. The array is of length numStages. 1349 */ 1350 void arm_fir_lattice_init_q15( 1351 arm_fir_lattice_instance_q15 * S, 1352 uint16_t numStages, 1353 const q15_t * pCoeffs, 1354 q15_t * pState); 1355 1356 1357 /** 1358 * @brief Processing function for the Q15 FIR lattice filter. 1359 * @param[in] S points to an instance of the Q15 FIR lattice structure. 1360 * @param[in] pSrc points to the block of input data. 1361 * @param[out] pDst points to the block of output data. 1362 * @param[in] blockSize number of samples to process. 1363 */ 1364 void arm_fir_lattice_q15( 1365 const arm_fir_lattice_instance_q15 * S, 1366 const q15_t * pSrc, 1367 q15_t * pDst, 1368 uint32_t blockSize); 1369 1370 1371 /** 1372 * @brief Initialization function for the Q31 FIR lattice filter. 1373 * @param[in] S points to an instance of the Q31 FIR lattice structure. 1374 * @param[in] numStages number of filter stages. 1375 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. 1376 * @param[in] pState points to the state buffer. The array is of length numStages. 1377 */ 1378 void arm_fir_lattice_init_q31( 1379 arm_fir_lattice_instance_q31 * S, 1380 uint16_t numStages, 1381 const q31_t * pCoeffs, 1382 q31_t * pState); 1383 1384 1385 /** 1386 * @brief Processing function for the Q31 FIR lattice filter. 1387 * @param[in] S points to an instance of the Q31 FIR lattice structure. 1388 * @param[in] pSrc points to the block of input data. 1389 * @param[out] pDst points to the block of output data 1390 * @param[in] blockSize number of samples to process. 1391 */ 1392 void arm_fir_lattice_q31( 1393 const arm_fir_lattice_instance_q31 * S, 1394 const q31_t * pSrc, 1395 q31_t * pDst, 1396 uint32_t blockSize); 1397 1398 1399 /** 1400 * @brief Initialization function for the floating-point FIR lattice filter. 1401 * @param[in] S points to an instance of the floating-point FIR lattice structure. 1402 * @param[in] numStages number of filter stages. 1403 * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. 1404 * @param[in] pState points to the state buffer. The array is of length numStages. 1405 */ 1406 void arm_fir_lattice_init_f32( 1407 arm_fir_lattice_instance_f32 * S, 1408 uint16_t numStages, 1409 const float32_t * pCoeffs, 1410 float32_t * pState); 1411 1412 1413 /** 1414 * @brief Processing function for the floating-point FIR lattice filter. 1415 * @param[in] S points to an instance of the floating-point FIR lattice structure. 1416 * @param[in] pSrc points to the block of input data. 1417 * @param[out] pDst points to the block of output data 1418 * @param[in] blockSize number of samples to process. 1419 */ 1420 void arm_fir_lattice_f32( 1421 const arm_fir_lattice_instance_f32 * S, 1422 const float32_t * pSrc, 1423 float32_t * pDst, 1424 uint32_t blockSize); 1425 1426 1427 /** 1428 * @brief Instance structure for the Q15 IIR lattice filter. 1429 */ 1430 typedef struct 1431 { 1432 uint16_t numStages; /**< number of stages in the filter. */ 1433 q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 1434 q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 1435 q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 1436 } arm_iir_lattice_instance_q15; 1437 1438 /** 1439 * @brief Instance structure for the Q31 IIR lattice filter. 1440 */ 1441 typedef struct 1442 { 1443 uint16_t numStages; /**< number of stages in the filter. */ 1444 q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 1445 q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 1446 q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 1447 } arm_iir_lattice_instance_q31; 1448 1449 /** 1450 * @brief Instance structure for the floating-point IIR lattice filter. 1451 */ 1452 typedef struct 1453 { 1454 uint16_t numStages; /**< number of stages in the filter. */ 1455 float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ 1456 float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ 1457 float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ 1458 } arm_iir_lattice_instance_f32; 1459 1460 1461 /** 1462 * @brief Processing function for the floating-point IIR lattice filter. 1463 * @param[in] S points to an instance of the floating-point IIR lattice structure. 1464 * @param[in] pSrc points to the block of input data. 1465 * @param[out] pDst points to the block of output data. 1466 * @param[in] blockSize number of samples to process. 1467 */ 1468 void arm_iir_lattice_f32( 1469 const arm_iir_lattice_instance_f32 * S, 1470 const float32_t * pSrc, 1471 float32_t * pDst, 1472 uint32_t blockSize); 1473 1474 1475 /** 1476 * @brief Initialization function for the floating-point IIR lattice filter. 1477 * @param[in] S points to an instance of the floating-point IIR lattice structure. 1478 * @param[in] numStages number of stages in the filter. 1479 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 1480 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 1481 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1. 1482 * @param[in] blockSize number of samples to process. 1483 */ 1484 void arm_iir_lattice_init_f32( 1485 arm_iir_lattice_instance_f32 * S, 1486 uint16_t numStages, 1487 float32_t * pkCoeffs, 1488 float32_t * pvCoeffs, 1489 float32_t * pState, 1490 uint32_t blockSize); 1491 1492 1493 /** 1494 * @brief Processing function for the Q31 IIR lattice filter. 1495 * @param[in] S points to an instance of the Q31 IIR lattice structure. 1496 * @param[in] pSrc points to the block of input data. 1497 * @param[out] pDst points to the block of output data. 1498 * @param[in] blockSize number of samples to process. 1499 */ 1500 void arm_iir_lattice_q31( 1501 const arm_iir_lattice_instance_q31 * S, 1502 const q31_t * pSrc, 1503 q31_t * pDst, 1504 uint32_t blockSize); 1505 1506 1507 /** 1508 * @brief Initialization function for the Q31 IIR lattice filter. 1509 * @param[in] S points to an instance of the Q31 IIR lattice structure. 1510 * @param[in] numStages number of stages in the filter. 1511 * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. 1512 * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. 1513 * @param[in] pState points to the state buffer. The array is of length numStages+blockSize. 1514 * @param[in] blockSize number of samples to process. 1515 */ 1516 void arm_iir_lattice_init_q31( 1517 arm_iir_lattice_instance_q31 * S, 1518 uint16_t numStages, 1519 q31_t * pkCoeffs, 1520 q31_t * pvCoeffs, 1521 q31_t * pState, 1522 uint32_t blockSize); 1523 1524 1525 /** 1526 * @brief Processing function for the Q15 IIR lattice filter. 1527 * @param[in] S points to an instance of the Q15 IIR lattice structure. 1528 * @param[in] pSrc points to the block of input data. 1529 * @param[out] pDst points to the block of output data. 1530 * @param[in] blockSize number of samples to process. 1531 */ 1532 void arm_iir_lattice_q15( 1533 const arm_iir_lattice_instance_q15 * S, 1534 const q15_t * pSrc, 1535 q15_t * pDst, 1536 uint32_t blockSize); 1537 1538 1539 /** 1540 * @brief Initialization function for the Q15 IIR lattice filter. 1541 * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure. 1542 * @param[in] numStages number of stages in the filter. 1543 * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages. 1544 * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1. 1545 * @param[in] pState points to state buffer. The array is of length numStages+blockSize. 1546 * @param[in] blockSize number of samples to process per call. 1547 */ 1548 void arm_iir_lattice_init_q15( 1549 arm_iir_lattice_instance_q15 * S, 1550 uint16_t numStages, 1551 q15_t * pkCoeffs, 1552 q15_t * pvCoeffs, 1553 q15_t * pState, 1554 uint32_t blockSize); 1555 1556 1557 /** 1558 * @brief Instance structure for the floating-point LMS filter. 1559 */ 1560 typedef struct 1561 { 1562 uint16_t numTaps; /**< number of coefficients in the filter. */ 1563 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1564 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1565 float32_t mu; /**< step size that controls filter coefficient updates. */ 1566 } arm_lms_instance_f32; 1567 1568 1569 /** 1570 * @brief Processing function for floating-point LMS filter. 1571 * @param[in] S points to an instance of the floating-point LMS filter structure. 1572 * @param[in] pSrc points to the block of input data. 1573 * @param[in] pRef points to the block of reference data. 1574 * @param[out] pOut points to the block of output data. 1575 * @param[out] pErr points to the block of error data. 1576 * @param[in] blockSize number of samples to process. 1577 */ 1578 void arm_lms_f32( 1579 const arm_lms_instance_f32 * S, 1580 const float32_t * pSrc, 1581 float32_t * pRef, 1582 float32_t * pOut, 1583 float32_t * pErr, 1584 uint32_t blockSize); 1585 1586 1587 /** 1588 * @brief Initialization function for floating-point LMS filter. 1589 * @param[in] S points to an instance of the floating-point LMS filter structure. 1590 * @param[in] numTaps number of filter coefficients. 1591 * @param[in] pCoeffs points to the coefficient buffer. 1592 * @param[in] pState points to state buffer. 1593 * @param[in] mu step size that controls filter coefficient updates. 1594 * @param[in] blockSize number of samples to process. 1595 */ 1596 void arm_lms_init_f32( 1597 arm_lms_instance_f32 * S, 1598 uint16_t numTaps, 1599 float32_t * pCoeffs, 1600 float32_t * pState, 1601 float32_t mu, 1602 uint32_t blockSize); 1603 1604 1605 /** 1606 * @brief Instance structure for the Q15 LMS filter. 1607 */ 1608 typedef struct 1609 { 1610 uint16_t numTaps; /**< number of coefficients in the filter. */ 1611 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1612 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1613 q15_t mu; /**< step size that controls filter coefficient updates. */ 1614 uint32_t postShift; /**< bit shift applied to coefficients. */ 1615 } arm_lms_instance_q15; 1616 1617 1618 /** 1619 * @brief Initialization function for the Q15 LMS filter. 1620 * @param[in] S points to an instance of the Q15 LMS filter structure. 1621 * @param[in] numTaps number of filter coefficients. 1622 * @param[in] pCoeffs points to the coefficient buffer. 1623 * @param[in] pState points to the state buffer. 1624 * @param[in] mu step size that controls filter coefficient updates. 1625 * @param[in] blockSize number of samples to process. 1626 * @param[in] postShift bit shift applied to coefficients. 1627 */ 1628 void arm_lms_init_q15( 1629 arm_lms_instance_q15 * S, 1630 uint16_t numTaps, 1631 q15_t * pCoeffs, 1632 q15_t * pState, 1633 q15_t mu, 1634 uint32_t blockSize, 1635 uint32_t postShift); 1636 1637 1638 /** 1639 * @brief Processing function for Q15 LMS filter. 1640 * @param[in] S points to an instance of the Q15 LMS filter structure. 1641 * @param[in] pSrc points to the block of input data. 1642 * @param[in] pRef points to the block of reference data. 1643 * @param[out] pOut points to the block of output data. 1644 * @param[out] pErr points to the block of error data. 1645 * @param[in] blockSize number of samples to process. 1646 */ 1647 void arm_lms_q15( 1648 const arm_lms_instance_q15 * S, 1649 const q15_t * pSrc, 1650 q15_t * pRef, 1651 q15_t * pOut, 1652 q15_t * pErr, 1653 uint32_t blockSize); 1654 1655 1656 /** 1657 * @brief Instance structure for the Q31 LMS filter. 1658 */ 1659 typedef struct 1660 { 1661 uint16_t numTaps; /**< number of coefficients in the filter. */ 1662 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1663 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1664 q31_t mu; /**< step size that controls filter coefficient updates. */ 1665 uint32_t postShift; /**< bit shift applied to coefficients. */ 1666 } arm_lms_instance_q31; 1667 1668 1669 /** 1670 * @brief Processing function for Q31 LMS filter. 1671 * @param[in] S points to an instance of the Q15 LMS filter structure. 1672 * @param[in] pSrc points to the block of input data. 1673 * @param[in] pRef points to the block of reference data. 1674 * @param[out] pOut points to the block of output data. 1675 * @param[out] pErr points to the block of error data. 1676 * @param[in] blockSize number of samples to process. 1677 */ 1678 void arm_lms_q31( 1679 const arm_lms_instance_q31 * S, 1680 const q31_t * pSrc, 1681 q31_t * pRef, 1682 q31_t * pOut, 1683 q31_t * pErr, 1684 uint32_t blockSize); 1685 1686 1687 /** 1688 * @brief Initialization function for Q31 LMS filter. 1689 * @param[in] S points to an instance of the Q31 LMS filter structure. 1690 * @param[in] numTaps number of filter coefficients. 1691 * @param[in] pCoeffs points to coefficient buffer. 1692 * @param[in] pState points to state buffer. 1693 * @param[in] mu step size that controls filter coefficient updates. 1694 * @param[in] blockSize number of samples to process. 1695 * @param[in] postShift bit shift applied to coefficients. 1696 */ 1697 void arm_lms_init_q31( 1698 arm_lms_instance_q31 * S, 1699 uint16_t numTaps, 1700 q31_t * pCoeffs, 1701 q31_t * pState, 1702 q31_t mu, 1703 uint32_t blockSize, 1704 uint32_t postShift); 1705 1706 1707 /** 1708 * @brief Instance structure for the floating-point normalized LMS filter. 1709 */ 1710 typedef struct 1711 { 1712 uint16_t numTaps; /**< number of coefficients in the filter. */ 1713 float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1714 float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1715 float32_t mu; /**< step size that control filter coefficient updates. */ 1716 float32_t energy; /**< saves previous frame energy. */ 1717 float32_t x0; /**< saves previous input sample. */ 1718 } arm_lms_norm_instance_f32; 1719 1720 1721 /** 1722 * @brief Processing function for floating-point normalized LMS filter. 1723 * @param[in] S points to an instance of the floating-point normalized LMS filter structure. 1724 * @param[in] pSrc points to the block of input data. 1725 * @param[in] pRef points to the block of reference data. 1726 * @param[out] pOut points to the block of output data. 1727 * @param[out] pErr points to the block of error data. 1728 * @param[in] blockSize number of samples to process. 1729 */ 1730 void arm_lms_norm_f32( 1731 arm_lms_norm_instance_f32 * S, 1732 const float32_t * pSrc, 1733 float32_t * pRef, 1734 float32_t * pOut, 1735 float32_t * pErr, 1736 uint32_t blockSize); 1737 1738 1739 /** 1740 * @brief Initialization function for floating-point normalized LMS filter. 1741 * @param[in] S points to an instance of the floating-point LMS filter structure. 1742 * @param[in] numTaps number of filter coefficients. 1743 * @param[in] pCoeffs points to coefficient buffer. 1744 * @param[in] pState points to state buffer. 1745 * @param[in] mu step size that controls filter coefficient updates. 1746 * @param[in] blockSize number of samples to process. 1747 */ 1748 void arm_lms_norm_init_f32( 1749 arm_lms_norm_instance_f32 * S, 1750 uint16_t numTaps, 1751 float32_t * pCoeffs, 1752 float32_t * pState, 1753 float32_t mu, 1754 uint32_t blockSize); 1755 1756 1757 /** 1758 * @brief Instance structure for the Q31 normalized LMS filter. 1759 */ 1760 typedef struct 1761 { 1762 uint16_t numTaps; /**< number of coefficients in the filter. */ 1763 q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1764 q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1765 q31_t mu; /**< step size that controls filter coefficient updates. */ 1766 uint8_t postShift; /**< bit shift applied to coefficients. */ 1767 const q31_t *recipTable; /**< points to the reciprocal initial value table. */ 1768 q31_t energy; /**< saves previous frame energy. */ 1769 q31_t x0; /**< saves previous input sample. */ 1770 } arm_lms_norm_instance_q31; 1771 1772 1773 /** 1774 * @brief Processing function for Q31 normalized LMS filter. 1775 * @param[in] S points to an instance of the Q31 normalized LMS filter structure. 1776 * @param[in] pSrc points to the block of input data. 1777 * @param[in] pRef points to the block of reference data. 1778 * @param[out] pOut points to the block of output data. 1779 * @param[out] pErr points to the block of error data. 1780 * @param[in] blockSize number of samples to process. 1781 */ 1782 void arm_lms_norm_q31( 1783 arm_lms_norm_instance_q31 * S, 1784 const q31_t * pSrc, 1785 q31_t * pRef, 1786 q31_t * pOut, 1787 q31_t * pErr, 1788 uint32_t blockSize); 1789 1790 1791 /** 1792 * @brief Initialization function for Q31 normalized LMS filter. 1793 * @param[in] S points to an instance of the Q31 normalized LMS filter structure. 1794 * @param[in] numTaps number of filter coefficients. 1795 * @param[in] pCoeffs points to coefficient buffer. 1796 * @param[in] pState points to state buffer. 1797 * @param[in] mu step size that controls filter coefficient updates. 1798 * @param[in] blockSize number of samples to process. 1799 * @param[in] postShift bit shift applied to coefficients. 1800 */ 1801 void arm_lms_norm_init_q31( 1802 arm_lms_norm_instance_q31 * S, 1803 uint16_t numTaps, 1804 q31_t * pCoeffs, 1805 q31_t * pState, 1806 q31_t mu, 1807 uint32_t blockSize, 1808 uint8_t postShift); 1809 1810 1811 /** 1812 * @brief Instance structure for the Q15 normalized LMS filter. 1813 */ 1814 typedef struct 1815 { 1816 uint16_t numTaps; /**< Number of coefficients in the filter. */ 1817 q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ 1818 q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ 1819 q15_t mu; /**< step size that controls filter coefficient updates. */ 1820 uint8_t postShift; /**< bit shift applied to coefficients. */ 1821 const q15_t *recipTable; /**< Points to the reciprocal initial value table. */ 1822 q15_t energy; /**< saves previous frame energy. */ 1823 q15_t x0; /**< saves previous input sample. */ 1824 } arm_lms_norm_instance_q15; 1825 1826 1827 /** 1828 * @brief Processing function for Q15 normalized LMS filter. 1829 * @param[in] S points to an instance of the Q15 normalized LMS filter structure. 1830 * @param[in] pSrc points to the block of input data. 1831 * @param[in] pRef points to the block of reference data. 1832 * @param[out] pOut points to the block of output data. 1833 * @param[out] pErr points to the block of error data. 1834 * @param[in] blockSize number of samples to process. 1835 */ 1836 void arm_lms_norm_q15( 1837 arm_lms_norm_instance_q15 * S, 1838 const q15_t * pSrc, 1839 q15_t * pRef, 1840 q15_t * pOut, 1841 q15_t * pErr, 1842 uint32_t blockSize); 1843 1844 1845 /** 1846 * @brief Initialization function for Q15 normalized LMS filter. 1847 * @param[in] S points to an instance of the Q15 normalized LMS filter structure. 1848 * @param[in] numTaps number of filter coefficients. 1849 * @param[in] pCoeffs points to coefficient buffer. 1850 * @param[in] pState points to state buffer. 1851 * @param[in] mu step size that controls filter coefficient updates. 1852 * @param[in] blockSize number of samples to process. 1853 * @param[in] postShift bit shift applied to coefficients. 1854 */ 1855 void arm_lms_norm_init_q15( 1856 arm_lms_norm_instance_q15 * S, 1857 uint16_t numTaps, 1858 q15_t * pCoeffs, 1859 q15_t * pState, 1860 q15_t mu, 1861 uint32_t blockSize, 1862 uint8_t postShift); 1863 1864 1865 /** 1866 * @brief Correlation of floating-point sequences. 1867 * @param[in] pSrcA points to the first input sequence. 1868 * @param[in] srcALen length of the first input sequence. 1869 * @param[in] pSrcB points to the second input sequence. 1870 * @param[in] srcBLen length of the second input sequence. 1871 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1872 */ 1873 void arm_correlate_f32( 1874 const float32_t * pSrcA, 1875 uint32_t srcALen, 1876 const float32_t * pSrcB, 1877 uint32_t srcBLen, 1878 float32_t * pDst); 1879 1880 1881 /** 1882 * @brief Correlation of floating-point sequences. 1883 * @param[in] pSrcA points to the first input sequence. 1884 * @param[in] srcALen length of the first input sequence. 1885 * @param[in] pSrcB points to the second input sequence. 1886 * @param[in] srcBLen length of the second input sequence. 1887 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1888 */ 1889 void arm_correlate_f64( 1890 const float64_t * pSrcA, 1891 uint32_t srcALen, 1892 const float64_t * pSrcB, 1893 uint32_t srcBLen, 1894 float64_t * pDst); 1895 1896 1897 /** 1898 @brief Correlation of Q15 sequences 1899 @param[in] pSrcA points to the first input sequence 1900 @param[in] srcALen length of the first input sequence 1901 @param[in] pSrcB points to the second input sequence 1902 @param[in] srcBLen length of the second input sequence 1903 @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1904 @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 1905 */ 1906 void arm_correlate_opt_q15( 1907 const q15_t * pSrcA, 1908 uint32_t srcALen, 1909 const q15_t * pSrcB, 1910 uint32_t srcBLen, 1911 q15_t * pDst, 1912 q15_t * pScratch); 1913 1914 1915 /** 1916 @brief Correlation of Q15 sequences. 1917 @param[in] pSrcA points to the first input sequence 1918 @param[in] srcALen length of the first input sequence 1919 @param[in] pSrcB points to the second input sequence 1920 @param[in] srcBLen length of the second input sequence 1921 @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1922 */ 1923 void arm_correlate_q15( 1924 const q15_t * pSrcA, 1925 uint32_t srcALen, 1926 const q15_t * pSrcB, 1927 uint32_t srcBLen, 1928 q15_t * pDst); 1929 1930 1931 /** 1932 @brief Correlation of Q15 sequences (fast version). 1933 @param[in] pSrcA points to the first input sequence 1934 @param[in] srcALen length of the first input sequence 1935 @param[in] pSrcB points to the second input sequence 1936 @param[in] srcBLen length of the second input sequence 1937 @param[out] pDst points to the location where the output result is written. Length 2 * max(srcALen, srcBLen) - 1. 1938 */ 1939 void arm_correlate_fast_q15( 1940 const q15_t * pSrcA, 1941 uint32_t srcALen, 1942 const q15_t * pSrcB, 1943 uint32_t srcBLen, 1944 q15_t * pDst); 1945 1946 1947 /** 1948 @brief Correlation of Q15 sequences (fast version). 1949 @param[in] pSrcA points to the first input sequence. 1950 @param[in] srcALen length of the first input sequence. 1951 @param[in] pSrcB points to the second input sequence. 1952 @param[in] srcBLen length of the second input sequence. 1953 @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1954 @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 1955 */ 1956 void arm_correlate_fast_opt_q15( 1957 const q15_t * pSrcA, 1958 uint32_t srcALen, 1959 const q15_t * pSrcB, 1960 uint32_t srcBLen, 1961 q15_t * pDst, 1962 q15_t * pScratch); 1963 1964 1965 /** 1966 * @brief Correlation of Q31 sequences. 1967 * @param[in] pSrcA points to the first input sequence. 1968 * @param[in] srcALen length of the first input sequence. 1969 * @param[in] pSrcB points to the second input sequence. 1970 * @param[in] srcBLen length of the second input sequence. 1971 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1972 */ 1973 void arm_correlate_q31( 1974 const q31_t * pSrcA, 1975 uint32_t srcALen, 1976 const q31_t * pSrcB, 1977 uint32_t srcBLen, 1978 q31_t * pDst); 1979 1980 1981 /** 1982 @brief Correlation of Q31 sequences (fast version). 1983 @param[in] pSrcA points to the first input sequence 1984 @param[in] srcALen length of the first input sequence 1985 @param[in] pSrcB points to the second input sequence 1986 @param[in] srcBLen length of the second input sequence 1987 @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 1988 */ 1989 void arm_correlate_fast_q31( 1990 const q31_t * pSrcA, 1991 uint32_t srcALen, 1992 const q31_t * pSrcB, 1993 uint32_t srcBLen, 1994 q31_t * pDst); 1995 1996 1997 /** 1998 * @brief Correlation of Q7 sequences. 1999 * @param[in] pSrcA points to the first input sequence. 2000 * @param[in] srcALen length of the first input sequence. 2001 * @param[in] pSrcB points to the second input sequence. 2002 * @param[in] srcBLen length of the second input sequence. 2003 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 2004 * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. 2005 * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). 2006 */ 2007 void arm_correlate_opt_q7( 2008 const q7_t * pSrcA, 2009 uint32_t srcALen, 2010 const q7_t * pSrcB, 2011 uint32_t srcBLen, 2012 q7_t * pDst, 2013 q15_t * pScratch1, 2014 q15_t * pScratch2); 2015 2016 2017 /** 2018 * @brief Correlation of Q7 sequences. 2019 * @param[in] pSrcA points to the first input sequence. 2020 * @param[in] srcALen length of the first input sequence. 2021 * @param[in] pSrcB points to the second input sequence. 2022 * @param[in] srcBLen length of the second input sequence. 2023 * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. 2024 */ 2025 void arm_correlate_q7( 2026 const q7_t * pSrcA, 2027 uint32_t srcALen, 2028 const q7_t * pSrcB, 2029 uint32_t srcBLen, 2030 q7_t * pDst); 2031 2032 2033 /** 2034 * @brief Instance structure for the floating-point sparse FIR filter. 2035 */ 2036 typedef struct 2037 { 2038 uint16_t numTaps; /**< number of coefficients in the filter. */ 2039 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 2040 float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 2041 const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 2042 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 2043 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 2044 } arm_fir_sparse_instance_f32; 2045 2046 /** 2047 * @brief Instance structure for the Q31 sparse FIR filter. 2048 */ 2049 typedef struct 2050 { 2051 uint16_t numTaps; /**< number of coefficients in the filter. */ 2052 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 2053 q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 2054 const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 2055 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 2056 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 2057 } arm_fir_sparse_instance_q31; 2058 2059 /** 2060 * @brief Instance structure for the Q15 sparse FIR filter. 2061 */ 2062 typedef struct 2063 { 2064 uint16_t numTaps; /**< number of coefficients in the filter. */ 2065 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 2066 q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 2067 const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 2068 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 2069 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 2070 } arm_fir_sparse_instance_q15; 2071 2072 /** 2073 * @brief Instance structure for the Q7 sparse FIR filter. 2074 */ 2075 typedef struct 2076 { 2077 uint16_t numTaps; /**< number of coefficients in the filter. */ 2078 uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ 2079 q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ 2080 const q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ 2081 uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ 2082 int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ 2083 } arm_fir_sparse_instance_q7; 2084 2085 2086 /** 2087 * @brief Processing function for the floating-point sparse FIR filter. 2088 * @param[in] S points to an instance of the floating-point sparse FIR structure. 2089 * @param[in] pSrc points to the block of input data. 2090 * @param[out] pDst points to the block of output data 2091 * @param[in] pScratchIn points to a temporary buffer of size blockSize. 2092 * @param[in] blockSize number of input samples to process per call. 2093 */ 2094 void arm_fir_sparse_f32( 2095 arm_fir_sparse_instance_f32 * S, 2096 const float32_t * pSrc, 2097 float32_t * pDst, 2098 float32_t * pScratchIn, 2099 uint32_t blockSize); 2100 2101 2102 /** 2103 * @brief Initialization function for the floating-point sparse FIR filter. 2104 * @param[in,out] S points to an instance of the floating-point sparse FIR structure. 2105 * @param[in] numTaps number of nonzero coefficients in the filter. 2106 * @param[in] pCoeffs points to the array of filter coefficients. 2107 * @param[in] pState points to the state buffer. 2108 * @param[in] pTapDelay points to the array of offset times. 2109 * @param[in] maxDelay maximum offset time supported. 2110 * @param[in] blockSize number of samples that will be processed per block. 2111 */ 2112 void arm_fir_sparse_init_f32( 2113 arm_fir_sparse_instance_f32 * S, 2114 uint16_t numTaps, 2115 const float32_t * pCoeffs, 2116 float32_t * pState, 2117 int32_t * pTapDelay, 2118 uint16_t maxDelay, 2119 uint32_t blockSize); 2120 2121 2122 /** 2123 * @brief Processing function for the Q31 sparse FIR filter. 2124 * @param[in] S points to an instance of the Q31 sparse FIR structure. 2125 * @param[in] pSrc points to the block of input data. 2126 * @param[out] pDst points to the block of output data 2127 * @param[in] pScratchIn points to a temporary buffer of size blockSize. 2128 * @param[in] blockSize number of input samples to process per call. 2129 */ 2130 void arm_fir_sparse_q31( 2131 arm_fir_sparse_instance_q31 * S, 2132 const q31_t * pSrc, 2133 q31_t * pDst, 2134 q31_t * pScratchIn, 2135 uint32_t blockSize); 2136 2137 2138 /** 2139 * @brief Initialization function for the Q31 sparse FIR filter. 2140 * @param[in,out] S points to an instance of the Q31 sparse FIR structure. 2141 * @param[in] numTaps number of nonzero coefficients in the filter. 2142 * @param[in] pCoeffs points to the array of filter coefficients. 2143 * @param[in] pState points to the state buffer. 2144 * @param[in] pTapDelay points to the array of offset times. 2145 * @param[in] maxDelay maximum offset time supported. 2146 * @param[in] blockSize number of samples that will be processed per block. 2147 */ 2148 void arm_fir_sparse_init_q31( 2149 arm_fir_sparse_instance_q31 * S, 2150 uint16_t numTaps, 2151 const q31_t * pCoeffs, 2152 q31_t * pState, 2153 int32_t * pTapDelay, 2154 uint16_t maxDelay, 2155 uint32_t blockSize); 2156 2157 2158 /** 2159 * @brief Processing function for the Q15 sparse FIR filter. 2160 * @param[in] S points to an instance of the Q15 sparse FIR structure. 2161 * @param[in] pSrc points to the block of input data. 2162 * @param[out] pDst points to the block of output data 2163 * @param[in] pScratchIn points to a temporary buffer of size blockSize. 2164 * @param[in] pScratchOut points to a temporary buffer of size blockSize. 2165 * @param[in] blockSize number of input samples to process per call. 2166 */ 2167 void arm_fir_sparse_q15( 2168 arm_fir_sparse_instance_q15 * S, 2169 const q15_t * pSrc, 2170 q15_t * pDst, 2171 q15_t * pScratchIn, 2172 q31_t * pScratchOut, 2173 uint32_t blockSize); 2174 2175 2176 /** 2177 * @brief Initialization function for the Q15 sparse FIR filter. 2178 * @param[in,out] S points to an instance of the Q15 sparse FIR structure. 2179 * @param[in] numTaps number of nonzero coefficients in the filter. 2180 * @param[in] pCoeffs points to the array of filter coefficients. 2181 * @param[in] pState points to the state buffer. 2182 * @param[in] pTapDelay points to the array of offset times. 2183 * @param[in] maxDelay maximum offset time supported. 2184 * @param[in] blockSize number of samples that will be processed per block. 2185 */ 2186 void arm_fir_sparse_init_q15( 2187 arm_fir_sparse_instance_q15 * S, 2188 uint16_t numTaps, 2189 const q15_t * pCoeffs, 2190 q15_t * pState, 2191 int32_t * pTapDelay, 2192 uint16_t maxDelay, 2193 uint32_t blockSize); 2194 2195 2196 /** 2197 * @brief Processing function for the Q7 sparse FIR filter. 2198 * @param[in] S points to an instance of the Q7 sparse FIR structure. 2199 * @param[in] pSrc points to the block of input data. 2200 * @param[out] pDst points to the block of output data 2201 * @param[in] pScratchIn points to a temporary buffer of size blockSize. 2202 * @param[in] pScratchOut points to a temporary buffer of size blockSize. 2203 * @param[in] blockSize number of input samples to process per call. 2204 */ 2205 void arm_fir_sparse_q7( 2206 arm_fir_sparse_instance_q7 * S, 2207 const q7_t * pSrc, 2208 q7_t * pDst, 2209 q7_t * pScratchIn, 2210 q31_t * pScratchOut, 2211 uint32_t blockSize); 2212 2213 2214 /** 2215 * @brief Initialization function for the Q7 sparse FIR filter. 2216 * @param[in,out] S points to an instance of the Q7 sparse FIR structure. 2217 * @param[in] numTaps number of nonzero coefficients in the filter. 2218 * @param[in] pCoeffs points to the array of filter coefficients. 2219 * @param[in] pState points to the state buffer. 2220 * @param[in] pTapDelay points to the array of offset times. 2221 * @param[in] maxDelay maximum offset time supported. 2222 * @param[in] blockSize number of samples that will be processed per block. 2223 */ 2224 void arm_fir_sparse_init_q7( 2225 arm_fir_sparse_instance_q7 * S, 2226 uint16_t numTaps, 2227 const q7_t * pCoeffs, 2228 q7_t * pState, 2229 int32_t * pTapDelay, 2230 uint16_t maxDelay, 2231 uint32_t blockSize); 2232 2233 2234 2235 2236 2237 2238 /** 2239 * @brief floating-point Circular write function. 2240 */ 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)2241 __STATIC_FORCEINLINE void arm_circularWrite_f32( 2242 int32_t * circBuffer, 2243 int32_t L, 2244 uint16_t * writeOffset, 2245 int32_t bufferInc, 2246 const int32_t * src, 2247 int32_t srcInc, 2248 uint32_t blockSize) 2249 { 2250 uint32_t i = 0U; 2251 int32_t wOffset; 2252 2253 /* Copy the value of Index pointer that points 2254 * to the current location where the input samples to be copied */ 2255 wOffset = *writeOffset; 2256 2257 /* Loop over the blockSize */ 2258 i = blockSize; 2259 2260 while (i > 0U) 2261 { 2262 /* copy the input sample to the circular buffer */ 2263 circBuffer[wOffset] = *src; 2264 2265 /* Update the input pointer */ 2266 src += srcInc; 2267 2268 /* Circularly update wOffset. Watch out for positive and negative value */ 2269 wOffset += bufferInc; 2270 if (wOffset >= L) 2271 wOffset -= L; 2272 2273 /* Decrement the loop counter */ 2274 i--; 2275 } 2276 2277 /* Update the index pointer */ 2278 *writeOffset = (uint16_t)wOffset; 2279 } 2280 2281 2282 2283 /** 2284 * @brief floating-point Circular Read function. 2285 */ 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)2286 __STATIC_FORCEINLINE void arm_circularRead_f32( 2287 int32_t * circBuffer, 2288 int32_t L, 2289 int32_t * readOffset, 2290 int32_t bufferInc, 2291 int32_t * dst, 2292 int32_t * dst_base, 2293 int32_t dst_length, 2294 int32_t dstInc, 2295 uint32_t blockSize) 2296 { 2297 uint32_t i = 0U; 2298 int32_t rOffset; 2299 int32_t* dst_end; 2300 2301 /* Copy the value of Index pointer that points 2302 * to the current location from where the input samples to be read */ 2303 rOffset = *readOffset; 2304 dst_end = dst_base + dst_length; 2305 2306 /* Loop over the blockSize */ 2307 i = blockSize; 2308 2309 while (i > 0U) 2310 { 2311 /* copy the sample from the circular buffer to the destination buffer */ 2312 *dst = circBuffer[rOffset]; 2313 2314 /* Update the input pointer */ 2315 dst += dstInc; 2316 2317 if (dst == dst_end) 2318 { 2319 dst = dst_base; 2320 } 2321 2322 /* Circularly update rOffset. Watch out for positive and negative value */ 2323 rOffset += bufferInc; 2324 2325 if (rOffset >= L) 2326 { 2327 rOffset -= L; 2328 } 2329 2330 /* Decrement the loop counter */ 2331 i--; 2332 } 2333 2334 /* Update the index pointer */ 2335 *readOffset = rOffset; 2336 } 2337 2338 2339 /** 2340 * @brief Q15 Circular write function. 2341 */ 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)2342 __STATIC_FORCEINLINE void arm_circularWrite_q15( 2343 q15_t * circBuffer, 2344 int32_t L, 2345 uint16_t * writeOffset, 2346 int32_t bufferInc, 2347 const q15_t * src, 2348 int32_t srcInc, 2349 uint32_t blockSize) 2350 { 2351 uint32_t i = 0U; 2352 int32_t wOffset; 2353 2354 /* Copy the value of Index pointer that points 2355 * to the current location where the input samples to be copied */ 2356 wOffset = *writeOffset; 2357 2358 /* Loop over the blockSize */ 2359 i = blockSize; 2360 2361 while (i > 0U) 2362 { 2363 /* copy the input sample to the circular buffer */ 2364 circBuffer[wOffset] = *src; 2365 2366 /* Update the input pointer */ 2367 src += srcInc; 2368 2369 /* Circularly update wOffset. Watch out for positive and negative value */ 2370 wOffset += bufferInc; 2371 if (wOffset >= L) 2372 wOffset -= L; 2373 2374 /* Decrement the loop counter */ 2375 i--; 2376 } 2377 2378 /* Update the index pointer */ 2379 *writeOffset = (uint16_t)wOffset; 2380 } 2381 2382 2383 /** 2384 * @brief Q15 Circular Read function. 2385 */ 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)2386 __STATIC_FORCEINLINE void arm_circularRead_q15( 2387 q15_t * circBuffer, 2388 int32_t L, 2389 int32_t * readOffset, 2390 int32_t bufferInc, 2391 q15_t * dst, 2392 q15_t * dst_base, 2393 int32_t dst_length, 2394 int32_t dstInc, 2395 uint32_t blockSize) 2396 { 2397 uint32_t i = 0; 2398 int32_t rOffset; 2399 q15_t* dst_end; 2400 2401 /* Copy the value of Index pointer that points 2402 * to the current location from where the input samples to be read */ 2403 rOffset = *readOffset; 2404 2405 dst_end = dst_base + dst_length; 2406 2407 /* Loop over the blockSize */ 2408 i = blockSize; 2409 2410 while (i > 0U) 2411 { 2412 /* copy the sample from the circular buffer to the destination buffer */ 2413 *dst = circBuffer[rOffset]; 2414 2415 /* Update the input pointer */ 2416 dst += dstInc; 2417 2418 if (dst == dst_end) 2419 { 2420 dst = dst_base; 2421 } 2422 2423 /* Circularly update wOffset. Watch out for positive and negative value */ 2424 rOffset += bufferInc; 2425 2426 if (rOffset >= L) 2427 { 2428 rOffset -= L; 2429 } 2430 2431 /* Decrement the loop counter */ 2432 i--; 2433 } 2434 2435 /* Update the index pointer */ 2436 *readOffset = rOffset; 2437 } 2438 2439 2440 /** 2441 * @brief Q7 Circular write function. 2442 */ 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)2443 __STATIC_FORCEINLINE void arm_circularWrite_q7( 2444 q7_t * circBuffer, 2445 int32_t L, 2446 uint16_t * writeOffset, 2447 int32_t bufferInc, 2448 const q7_t * src, 2449 int32_t srcInc, 2450 uint32_t blockSize) 2451 { 2452 uint32_t i = 0U; 2453 int32_t wOffset; 2454 2455 /* Copy the value of Index pointer that points 2456 * to the current location where the input samples to be copied */ 2457 wOffset = *writeOffset; 2458 2459 /* Loop over the blockSize */ 2460 i = blockSize; 2461 2462 while (i > 0U) 2463 { 2464 /* copy the input sample to the circular buffer */ 2465 circBuffer[wOffset] = *src; 2466 2467 /* Update the input pointer */ 2468 src += srcInc; 2469 2470 /* Circularly update wOffset. Watch out for positive and negative value */ 2471 wOffset += bufferInc; 2472 if (wOffset >= L) 2473 wOffset -= L; 2474 2475 /* Decrement the loop counter */ 2476 i--; 2477 } 2478 2479 /* Update the index pointer */ 2480 *writeOffset = (uint16_t)wOffset; 2481 } 2482 2483 2484 /** 2485 * @brief Q7 Circular Read function. 2486 */ 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)2487 __STATIC_FORCEINLINE void arm_circularRead_q7( 2488 q7_t * circBuffer, 2489 int32_t L, 2490 int32_t * readOffset, 2491 int32_t bufferInc, 2492 q7_t * dst, 2493 q7_t * dst_base, 2494 int32_t dst_length, 2495 int32_t dstInc, 2496 uint32_t blockSize) 2497 { 2498 uint32_t i = 0; 2499 int32_t rOffset; 2500 q7_t* dst_end; 2501 2502 /* Copy the value of Index pointer that points 2503 * to the current location from where the input samples to be read */ 2504 rOffset = *readOffset; 2505 2506 dst_end = dst_base + dst_length; 2507 2508 /* Loop over the blockSize */ 2509 i = blockSize; 2510 2511 while (i > 0U) 2512 { 2513 /* copy the sample from the circular buffer to the destination buffer */ 2514 *dst = circBuffer[rOffset]; 2515 2516 /* Update the input pointer */ 2517 dst += dstInc; 2518 2519 if (dst == dst_end) 2520 { 2521 dst = dst_base; 2522 } 2523 2524 /* Circularly update rOffset. Watch out for positive and negative value */ 2525 rOffset += bufferInc; 2526 2527 if (rOffset >= L) 2528 { 2529 rOffset -= L; 2530 } 2531 2532 /* Decrement the loop counter */ 2533 i--; 2534 } 2535 2536 /* Update the index pointer */ 2537 *readOffset = rOffset; 2538 } 2539 2540 2541 /** 2542 @brief Levinson Durbin 2543 @param[in] phi autocovariance vector starting with lag 0 (length is nbCoefs + 1) 2544 @param[out] a autoregressive coefficients 2545 @param[out] err prediction error (variance) 2546 @param[in] nbCoefs number of autoregressive coefficients 2547 */ 2548 void arm_levinson_durbin_f32(const float32_t *phi, 2549 float32_t *a, 2550 float32_t *err, 2551 int nbCoefs); 2552 2553 2554 /** 2555 @brief Levinson Durbin 2556 @param[in] phi autocovariance vector starting with lag 0 (length is nbCoefs + 1) 2557 @param[out] a autoregressive coefficients 2558 @param[out] err prediction error (variance) 2559 @param[in] nbCoefs number of autoregressive coefficients 2560 */ 2561 void arm_levinson_durbin_q31(const q31_t *phi, 2562 q31_t *a, 2563 q31_t *err, 2564 int nbCoefs); 2565 2566 #ifdef __cplusplus 2567 } 2568 #endif 2569 2570 #endif /* ifndef _FILTERING_FUNCTIONS_H_ */ 2571