I am working on a project for recognizing and identifying the sounds in real time(like baby crying, birds, door knocking...)by java, so I made a model by using audio files for 9 categories of sound by using the mel coefficient function from Matlab documentation website
and after getting the model and using it in the java project I am not obtaining the same mel coefficients, even if I use the same audio file for testing in Matlab and in java
in the java, I am using tarsos DSP mel function
https://github.com/JorenSix/TarsosDSP/blob/master/src/core/be/tarsos/dsp/mfcc/MFCC.java
and the fft java class is here
https://github.com/JorenSix/TarsosDSP/blob/master/src/core/be/tarsos/dsp/util/fft/FFT.java
I have tried to trace and debug both codes in Java and Matlab but I couldn't find where is the different step that makes the final result different, so if anyone can help I will appreciate it. thanks in advance.
update1 in the mfcc function of the matlab the parameters are Tw = 25; % analysis frame duration (ms) Ts = 10; % analysis frame shift (ms) alpha = 0.97; % preemphasis coefficient R = [300 3700]; % frequency range to consider M = 20; % number of filterbank channels C = 13; % number of cepstral coefficients L = 22; % cepstral sine lifter parameter naumberOfFramesPerSecond=25 ; %like in java % hamming window hamming = @(N)(0.54-0.46*cos(2*pi*[0:N-1].'/(N-1)));
and the function is: [coef,FBE,frames]=mfcc(babycryaverage,fs , Tw, Ts, alpha, hamming, R, M, C, L)
in _java_the function that i call from the class is: MFCC(int samplesPerFrame, float sampleRate, int amountOfCepstrumCoef, int amountOfMelFilters, float lowerFilterFreq, float upperFilterFreq)
so the parameters that i use in java are: MFCC(bufferSize,sampleRate,13,20,300f,3700f)
i calcuate the buffer size from sample rate multiply the frame size sampleRate=16000f; framesize=0.025f;//25ms bufferSize= Math.round(sampleRate*framesize);//400
and the AudioDispatcher which is the step of preparing the audio file before the process of mfcc function is: dispatcher = AudioDispatcherFactory.fromFile(audioFile,bufferSize, bufferOverlap)
the bufferoverlap calculated by : int bufferOverlap=(int) (0.015f * sampleRate);