How to apply a mel-filterbank to a signal?

I found this description. According to this, the next step is a "binning" where

binning means that each FFT magnitude coefficient is multiplied by the corresponding filter gain and the results accumulated. What is the exact procedure they are describing?

Binning is an averaging operation on the (squared) magnitudes of the DFT. You would maybe have $256$ DFT bins but only around $20$ outputs of the filter bank. So you need to average groups of DFT bins to reduce the dimension from $256$ to $20$. For a mel-scaled filter bank, the averaging functions (kernels) are usually triangular, i.e. the center DFT bins get more weight than the rest. As an example, let the first kernel that is used for averaging the lowest DFT frequencies be stored in an array $W_1[k]$, $k=0,\ldots,K-1$, then the output of that filter bank channel is computed as

$$y_1=\sum_{k=0}^{K-1}W_1[k]R[k]\tag{1}$$

where $R[k]$ are the (squared) DFT magnitudes. In this way you compute all $20$ filter bank outputs. You just need to know (define) the weights $W_i[k]$ and the range of DFT indices that are averaged by the respective kernel.

This answer to a related question might also be helpful (also have a look at the comments).

• thank you for your answer.. Can you please have a look at my edited question?.. Are the calculations looking good? (the used algorithm for DFT (FFT) is requiring n² datapoints (does this affect the MFCC?).. I do not know how to proceed.. what is the parameter 'k' in my case?
– Jan
Commented Feb 26, 2017 at 21:47
• ps I know it is a bad example as there are fewer/same number of mfcc-bins and dct-bins.. but i wanted it to be comprehensible..
– Jan
Commented Feb 27, 2017 at 9:01
• @Jan: Your original question was about binning, i.e., about using the filter bank on the output of the DFT. That's what I've tried to explain. Is it still unclear? I do not intend to look at long rows of numbers to judge whether they "look good" or not. Commented Feb 27, 2017 at 9:08
• yes it is still unclear... What is $k$? I have an one-dimensional Filterbank.. ($1*n$).. And what do you mean by 'the lowest DFT frequencies'?
– Jan
Commented Feb 27, 2017 at 9:50
• @Jan: $k$ is just an index running through the DFT bins that are being averaged to get one filter bank output. And $K$ is the number of bins averaged by the first kernel. You decide what $K$ is, or which specification you want to follow. By "lowest DFT frequencies" I literally mean the lowest (starting from frequency zero); you take the first $K$ frequencies, weigh them, and add them up to obtain the output of the first filter bank channel. And similarly for all other channels. Commented Feb 27, 2017 at 9:54

You can find some examples in the Voicebox matlab toolbox:

http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html

At the Mathworks website you can find a possible answer:

https://www.mathworks.com/matlabcentral/fileexchange/32849-htk-mfcc-matlab/content/mfcc/mfcc.m

Can you post your own version or efforts?

Find maximum frequency in Mels: If your frequency range is 300Hz-8kHz for example you will have 401-2835 Mels (using freq. to Mels convertions). Find bin center Mel freq: If you want 10 bins you must have 12 points eleven zones; so bin width=(2835-401)/11=222; the bins will be approx: bwm(i) = 401.3, 622.5, 843.8, 1065.0, 1286.3, 1507.5, 1728.8, 1950.0, 2171.2, 2392.5, 2613.8, 2835; Convert Mel freq back to lin freq: values will be: bwf(i) = 300, 517, 782, 1104, 1496, 1973, 2554, 3262, 4123, 5171, 6446, 8000; Then you can proceed with the calculations.

Some code:

f1=300;
f2=3700;
n=10;
fm1=2595*log10(1+f1/700);
fm2=2595*log10(1+f2/700);
fmw=(fm2-fm1)/(n+1);
fm=fm1:fmw:fm2;
f=700*(exp(fm/1125)-1);
% for plotting
x1=ones(1,n+2);
x1(1:2:(n+2))=0;
x2= zeros(1,n+2);
x2(1:2:(n+2))=1;
plot(f(1:11),x1(1:11))
hold on
plot(f(2:12),x2(2:12))
hold off