arm_mfcc_init_f16.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* ----------------------------------------------------------------------
  2. * Project: CMSIS DSP Library
  3. * Title: arm_mfcc_init_f16.c
  4. * Description: MFCC initialization function for the f16 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_f16.h"
  36. #if defined(ARM_FLOAT16_SUPPORTED)
  37. /**
  38. @brief Initialization of the MFCC F16 instance structure
  39. @param[out] S points to the mfcc instance structure
  40. @param[in] fftLen fft length
  41. @param[in] nbMelFilters number of Mel filters
  42. @param[in] nbDctOutputs number of Dct outputs
  43. @param[in] dctCoefs points to an array of DCT coefficients
  44. @param[in] filterPos points of the array of filter positions
  45. @param[in] filterLengths points to the array of filter lengths
  46. @param[in] filterCoefs points to the array of filter coefficients
  47. @param[in] windowCoefs points to the array of window coefficients
  48. @return error status
  49. @par Description
  50. The matrix of Mel filter coefficients is sparse.
  51. Most of the coefficients are zero.
  52. To avoid multiplying the spectrogram by those zeros, the
  53. filter is applied only to a given position in the spectrogram
  54. and on a given number of FFT bins (the filter length).
  55. It is the reason for the arrays filterPos and filterLengths.
  56. window coefficients can describe (for instance) a Hamming window.
  57. The array has the same size as the FFT length.
  58. The folder Scripts is containing a Python script which can be used
  59. to generate the filter, dct and window arrays.
  60. */
  61. arm_status arm_mfcc_init_f16(
  62. arm_mfcc_instance_f16 * S,
  63. uint32_t fftLen,
  64. uint32_t nbMelFilters,
  65. uint32_t nbDctOutputs,
  66. const float16_t *dctCoefs,
  67. const uint32_t *filterPos,
  68. const uint32_t *filterLengths,
  69. const float16_t *filterCoefs,
  70. const float16_t *windowCoefs
  71. )
  72. {
  73. arm_status status;
  74. S->fftLen=fftLen;
  75. S->nbMelFilters=nbMelFilters;
  76. S->nbDctOutputs=nbDctOutputs;
  77. S->dctCoefs=dctCoefs;
  78. S->filterPos=filterPos;
  79. S->filterLengths=filterLengths;
  80. S->filterCoefs=filterCoefs;
  81. S->windowCoefs=windowCoefs;
  82. #if defined(ARM_MFCC_CFFT_BASED)
  83. status=arm_cfft_init_f16(&(S->cfft),fftLen);
  84. #else
  85. status=arm_rfft_fast_init_f16(&(S->rfft),fftLen);
  86. #endif
  87. return(status);
  88. }
  89. #endif /* defined(ARM_FLOAT16_SUPPORTED) */
  90. /**
  91. @} end of MFCC group
  92. */