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