# What is really the Mel-filterbank?

After applying STFT to a signal, you typically need to convert the frequencies to the Mel scale. Typically the frequency values range from $$0$$ to $$N/2$$, where $$N$$ is the width of each sliding window.

I have read so many articles about Mel Spectrogram. Basically they all say to convert frequencies to Mel Scale in the following way:

1. Partition the Hz scale (i.e. partition a sequence of numbers ranging from $$0$$ to $$N/2$$). In this way we will have a number of bins. This number is for example indicated in librosa by "n_mel". These bins are called frequency bands.

2. Covert each bins into Mel Scale using the formula $$2595*log(1+f/700).$$

3. Application of triangular filters for each bins to capture the energy at each frequency band and approximate the spectrum shape.

It seems that when this is buried in the articles, nobody really knows why these operations are carried out. I find it difficult to fully understand:

1. Why divide the Hz scale into bins?

2. What exactly is meant by a frequency band?

3. Why do we apply triangular filters?

4. What exactly is a triangular filter? How is it defined mathematically and from what concept?

Can anyone explain exactly these things to me or recommend a book where these steps are explained in detail? There seems to be no book that explains these concepts exactly.

This was my first google hit: https://medium.com/analytics-vidhya/understanding-the-mel-spectrogram-fca2afa2ce53

It seems to explain both how and why?

Mel frequency binning is afaik only used when human perception is involved. Either directly, or for signals that have probably been adapted to human hearing (such as human speech). It is a way to represent signal information in a way that mimics «low level auditory perception», or could be seen as removing perceptually redundant information.

I have not understood why it is that we generally have the same temporal reolution in narrow low frequency bands, as in wide high frequency bands. Historically, it may have been due to limited processing power and the efficiency of a single STFT windowing process. And/or it could reflect the limited neuron firing rate after the acoustic-mechanical filtering carried out by our ear.

But from a dsp perspective, I would expect a variable time/frequency resolution, where high & wide bands gets more temporal resolution.

Mel Frequency Cepstral Coefficient(MFCC) tutorial

As I am a newbie in DSP and I thought this article has a clear explanation, I did not try to answer your questions myself. But you said you have read it and thought these questions are still ambiguous, then I want to try one more time to give my answers.

First, about the concepts of bins and bands, they confused me a lot in the beginning when I was trying to figure out what the Fourier Transform means, especially the Discrete Fourier Transform (DFT), which is also much related to your questions. Right now my understanding of frequency bins are specific frequency values, such as 2000, or 2001.5. A frequency band, for example from 1000 to 2000, covers a range of frequencies, and it is defined by the two frequency bins 1000 and 2000 (one is the floor, and one is the ceiling). In the physical world, the values of frequencies can take any real number, in other words, they are continuous. As to the above example, there are infinite values or frequency bins in the frequency band [1000,2000]. However, when comes to digital signal processing, in the time domain, we take finite (and integer) numbers of samples with a sampling rate, for example 44100 samples per second (i.e. 44100Hz). Later we do Discrete Fourier Transform (DFT) in ways of FFT or STFT to go to the frequency domain. When we do STFT, we do it in the unit of frame and apply hanning window to it. As you mentioned the width of the window equals to the frame size such as 2048 samples, and 2048 is your N.