I have a block of audio and I have performed an FFT on it. Now what I want to do is convert this FFT into a set of MFCCs, however while I know I need to do something with weighting the FFT samples based upon a set f triangular filters I haven't really got a clue what this involves.

Can anyone go into some good detail on it? If you are going to give me a matlab example please explain each step well as matlab allows you to cut quite a few corners and I'm trying to implement MFCC extraction on iPhone.


1 Answer 1


There's a lot of literature on MFCCs on the web, so it would be a bit easier if you could be more specific as to which part of the processing you don't understand. But I'll give an overview of what needs to be done, hoping this is helpful for you:

  1. compute the squared magnitudes of the FFT bins
  2. weigh the bins using triangular windows; usually the windows are chosen such that the centers of the triangles are equidistant on a mel-frequency scale, and such that each triangle begins and ends at the centers of the two adjacent triangles. The mel-frequency scale is defined by $$m=2595\log_{10}(1+f/700)$$ where $f$ is the frequency in Hz. Look at the figure to see how it works: enter image description here Note that the kernels are normalized such that the sum of the weights per triangle equals 1. Usually around 20 such triangular windows are used.
  3. Take the logarithm of the weighted coefficients.
  4. Compute the DCT.
  • $\begingroup$ Cheers Matt, I have read all this but where I fall down is "weigh the bins using triangular windows" I haven't got a clue exactly what this means. Should I be taking a set of bins and then weighting each bin dependent on this triangular "window" and then adding them all together and calling that a "bin"? (This is m best guess). If so, how do I calculate the triangular window? The mel frequency equation you posted ... I don't get how multiple frequencies can relate to one mel "bin" via that ... Any further information on this specific step would be hugely appreciated! :) $\endgroup$
    – Goz
    May 10, 2013 at 21:31
  • $\begingroup$ You're right about the windows: you compute weighted sums of your FFT bins. The weights are the individual values of the triangular functions. The mel scale is just for centering the triangles. Choose e.g. 20 equidistant points on the mel scale and transform back to Hertz via the formula to get the center frequencies in Hz. Of course you need to round the result to match the values to valid FFT bins. $\endgroup$
    – Matt L.
    May 10, 2013 at 21:34
  • $\begingroup$ Cheers the centering the bins part makes sense. But how do I triangularly (bad choice of word but its great to try and say ;)) weight the windows? ie How wide should they be? Also why triangular and not some other window type? Gaussian perhaps? $\endgroup$
    – Goz
    May 10, 2013 at 21:36
  • $\begingroup$ As another aside (And potentially should be asked in another questions) why do you calculate MFCCs (ignoring the weighting) so differently to a cepstrum? ie why the DCT and not inverse FFT? $\endgroup$
    – Goz
    May 10, 2013 at 21:39
  • $\begingroup$ Well, you don't weigh the windows but the FFT bins. Simple example: triangle with values 1,2,1, so your weighted output for this triangle would be 1*(first FFT bin) + 2*(second FFT bin) + 3*(third FFT bin). Why triangular is a good question, that's just the standard way of doing it. Try others if you like, but I doubt you'll get considerably better results. $\endgroup$
    – Matt L.
    May 10, 2013 at 21:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.