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