Skip to content

Usage of MFCC function arm_mfcc_q31/f32 #279

Description

@hellgheast

Dear Maintainer,

For our current development we are trying to use the function arm_mfcc_q31 in C (and in Python) and have some questions.

  • How is this function supposed to be used for more than one FFT window (assuming you have a hop length of 160) ?
    We are currently using it this way, and are not sure if it's working as expected.
 
for (uint32_t i = 0,mfcccount = 0; (i + fftLen) <= MONO_AUDIO_NB_SAMPLES/2 && mfcccount < 100; i += HOP_LENGTH, mfcccount++) {
        ARMstatus = arm_mfcc_q31(
        &S,
        (q31_t*)&InputMonoResampledBuffer[i],
        (q31_t*)&OutputMFCC[mfcccount*nbDctOutputs],
        (q31_t*)TempMFCC
        );
    }
  • Why in this file
    res=self.FFTSize*Q31toF32(resQ31)
    is the result of the Q31 MFCC conversion multiplied by the FFT length ?
  • Is there any example in C or in python for outputting an array of MFCC sample using CMSIS-DSP ?
  • We also saw this issue, Matching MFCC configuration with Librosa's #54 and when we tried the same audio sample (sine wave at 1 kHZ) we saw quite big difference between the output in float32 and q31, is it expected ?
window = sig.windows.hamming(FFTSize, sym=False)
      
filtLen,filtPos,packedFilters = mfcc.melFilterMatrix(F32,freq_min, freq_high, numOfMelFilters,sample_rate,FFTSize)

       
dctMatrixFilters = mfcc.dctMatrix(F32,numOfDctOutputs, numOfMelFilters)

mfccf32=dsp.arm_mfcc_instance_f32()

status=dsp.arm_mfcc_init_f32(mfccf32,FFTSize,numOfMelFilters,numOfDctOutputs,dctMatrixFilters,
    filtPos,filtLen,packedFilters,window)

tmp_nb = dsp.arm_mfcc_tmp_buffer_size(dt.F32,FFTSize,1)
tmp = np.zeros(tmp_nb,dtype=np.float32)
res=dsp.arm_mfcc_f32(mfccf32,pcm[0:FFTSize],tmp)

print("CMSIS-DSP")
print(res)

t = np.linspace(0,2,num_samples)
pcm = np.array(np.sin(2*math.pi * t * 1000),dtype=np.double)

mfccq31=dsp.arm_mfcc_instance_q31()

windowQ31 = dt.convert(sig.windows.hamming(FFTSize, sym=False),Q31)
filtLen,filtPos,packedFiltersQ31 = mfcc.melFilterMatrix(Q31,
                                                        freq_min, 
                                                        freq_high, 
                                                        numOfMelFilters,
                                                        sample_rate,
                                                        FFTSize)
dctMatrixFiltersQ31 = mfcc.dctMatrix(Q31,numOfDctOutputs, numOfMelFilters)


status=dsp.arm_mfcc_init_q31(mfccq31,FFTSize,numOfMelFilters,numOfDctOutputs,
    dctMatrixFiltersQ31,
    filtPos,filtLen,packedFiltersQ31,windowQ31)

#debugQ31 = toQ31(debug)

tmp_nb = dsp.arm_mfcc_tmp_buffer_size(dt.Q31,FFTSize,1)
tmp = np.zeros(tmp_nb,dtype=np.int32)

errorStatus,resQ31=dsp.arm_mfcc_q31(mfccq31,toQ31(pcm[0:FFTSize]),tmp)

res=FFTSize*Q31toF32(resQ31)

print("CMSIS-DSP-Q31")
print(resQ31)   
print(res)   

Best Regards,
Mohammed Ismail

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationquestionFurther information is requested

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions