arm_mfcc_init_f32.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_mfcc_init_f32.c
  4. * Description: MFCC initialization function for the f32 version
  5. *
  6. * $Date: 07 September 2021
  7. * $Revision: V1.10.0
  8. *
  9. * Target Processor: Cortex-M and Cortex-A cores
  10. * -------------------------------------------------------------------- */
  11. /*
  12. * Copyright (C) 2010-2021 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. /**
  29. @ingroup groupTransforms
  30. */
  31. /**
  32. @addtogroup MFCC
  33. @{
  34. */
  35. #include "dsp/transform_functions.h"
  36. /**
  37. @brief Initialization of the MFCC F32 instance structure
  38. @param[out] S points to the mfcc instance structure
  39. @param[in] fftLen fft length
  40. @param[in] nbMelFilters number of Mel filters
  41. @param[in] nbDctOutputs number of Dct outputs
  42. @param[in] dctCoefs points to an array of DCT coefficients
  43. @param[in] filterPos points of the array of filter positions
  44. @param[in] filterLengths points to the array of filter lengths
  45. @param[in] filterCoefs points to the array of filter coefficients
  46. @param[in] windowCoefs points to the array of window coefficients
  47. @return error status
  48. @par Description
  49. The matrix of Mel filter coefficients is sparse.
  50. Most of the coefficients are zero.
  51. To avoid multiplying the spectrogram by those zeros, the
  52. filter is applied only to a given position in the spectrogram
  53. and on a given number of FFT bins (the filter length).
  54. It is the reason for the arrays filterPos and filterLengths.
  55. window coefficients can describe (for instance) a Hamming window.
  56. The array has the same size as the FFT length.
  57. The folder Scripts is containing a Python script which can be used
  58. to generate the filter, dct and window arrays.
  59. */
  60. arm_status arm_mfcc_init_f32(
  61. arm_mfcc_instance_f32 * S,
  62. uint32_t fftLen,
  63. uint32_t nbMelFilters,
  64. uint32_t nbDctOutputs,
  65. const float32_t *dctCoefs,
  66. const uint32_t *filterPos,
  67. const uint32_t *filterLengths,
  68. const float32_t *filterCoefs,
  69. const float32_t *windowCoefs
  70. )
  71. {
  72. arm_status status;
  73. S->fftLen=fftLen;
  74. S->nbMelFilters=nbMelFilters;
  75. S->nbDctOutputs=nbDctOutputs;
  76. S->dctCoefs=dctCoefs;
  77. S->filterPos=filterPos;
  78. S->filterLengths=filterLengths;
  79. S->filterCoefs=filterCoefs;
  80. S->windowCoefs=windowCoefs;
  81. #if defined(ARM_MFCC_CFFT_BASED)
  82. status=arm_cfft_init_f32(&(S->cfft),fftLen);
  83. #else
  84. status=arm_rfft_fast_init_f32(&(S->rfft),fftLen);
  85. #endif
  86. return(status);
  87. }
  88. /**
  89. @} end of MFCC group
  90. */