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


and the fft java class is here


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);

  • $\begingroup$ It is not uncommon for algorithm implementations to differ in their output. Please can you update the question with the arguments you are feeding to each algorithm and the outputs you are obtaining. $\endgroup$ – tobassist Jun 27 '18 at 9:15
  • $\begingroup$ hello sir,thanks for offering help,i updated the paragraph and added the functions i use in java and matlab with the parameters $\endgroup$ – KamelK Jun 27 '18 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.