arm_welch_f32.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_welch_f32.c
  4. * Description: Floating-point (f32) Welch window
  5. *
  6. * $Date: 14 December 2022
  7. * $Revision: v1.15.0
  8. *
  9. * Target Processor: Cortex-M and Cortex-A cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2022 ARM Limited or its affiliates. All rights reserved.
  13. *
  14. * SPDX-License-Identifier: Apache-2.0
  15. *
  16. * Licensed under the Apache License, Version 2.0 (the License); you may
  17. * not use this file except in compliance with the License.
  18. * You may obtain a copy of the License at
  19. *
  20. * www.apache.org/licenses/LICENSE-2.0
  21. *
  22. * Unless required by applicable law or agreed to in writing, software
  23. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  24. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  25. * See the License for the specific language governing permissions and
  26. * limitations under the License.
  27. */
  28. #include "dsp/window_functions.h"
  29. /**
  30. @ingroup groupWindow
  31. */
  32. /**
  33. @addtogroup WindowNormal
  34. @{
  35. */
  36. /**
  37. @defgroup WindowWELCH Welch window function (21.3 dB)
  38. */
  39. /**
  40. @ingroup WindowWELCH
  41. */
  42. /**
  43. @brief Welch window generating function (f32).
  44. @param[out] pDst points to the output generated window
  45. @param[in] blockSize number of samples in the window
  46. @par Parameters of the window
  47. | Parameter | Value |
  48. | ------------------------------------: | -----------------: |
  49. | Peak sidelobe level | 21.3 dB |
  50. | Normalized equivalent noise bandwidth | 1.2 bins |
  51. | 3 dB bandwidth | 1.1535 bins |
  52. | Flatness | -2.2248 dB |
  53. | Recommended overlap | 29.3 % |
  54. */
  55. void arm_welch_f32(
  56. float32_t * pDst,
  57. uint32_t blockSize)
  58. {
  59. float32_t k = 2.0f / ((float32_t) blockSize);
  60. float32_t w;
  61. for(uint32_t i=0;i<blockSize;i++)
  62. {
  63. w = i * k - 1.0f;
  64. w = 1.0f - w * w;
  65. pDst[i] = w;
  66. }
  67. }
  68. /**
  69. @} end of WindowNormal group
  70. */