Search

Search papers and lessons

Mel Scale

Level 2 · 10 min read

The mel scale re-labels frequency so that equal steps sound equally far apart to a listener: fine detail at low pitches, coarse detail at high ones, as the ear hears it.

On this page

  • Colour = topic mix
  • Discrete math
  • Calculus
  • Signal processing
  • Linear algebra
  • ReadReady to readNot yet

TL;DR

The mel scale is a way of measuring pitch in which equal steps sound equally far apart to a listener. It stretches the low end of the frequency axis and squeezes the high end, the way human hearing does: a 100 Hz step from 200 Hz to 300 Hz is a far bigger change to the ear than the same 100 Hz step from 7000 Hz to 7100 Hz. Speech and audio systems use it to decide how to group frequencies before they learn from the sound.

Builds on: Logarithm, Time-Frequency Representation · Leads to: Mel Spectrogram, Automatic Speech Recognition

Where it's used

  • Speech recognition. For decades, speech recognizers turned each short slice of audio into a few dozen numbers called mel-frequency cepstral coefficients, computed from energies in mel-spaced bands. The bands are the mel scale's job: they put most of the detail where the ear is sharpest.
  • Neural speech models. Modern systems often skip the cepstrum and feed a log-mel spectrogram directly to the network. Whisper, OpenAI's speech recognizer, takes a log-mel spectrogram as its input, so the mel scale sets what the network can see.
  • Sound classification. Tools that sort recordings by type, such as birdsong, music genre or a cough versus a siren, often work on mel-spaced energies, because the grouping keeps the features compact (a few dozen numbers per slice) and still close to what a listener hears.

How it works

Take a single pure tone and trace where the mel scale puts it, then see what it does to a set of filters. Each step uses round numbers and one idea.

  1. Start with a frequency in hertz. A tone at 1000 Hz is one cycle per millisecond. A spectrogram lists energy at many frequencies in hertz, which is the layout we want to change.
  2. Convert hertz to mel. The conversion is m=2595log⁡10 ⁣(1+f700)m = 2595 \log_{10}\!\left(1 + \frac{f}{700}\right). Check: f=1000f = 1000 Hz gives m=1000m = 1000 mel. By convention the scale is anchored there.
  3. Compare steps in hertz and in mel. Going from 500 Hz to 1000 Hz covers 500 Hz, which is about 392 mel. Going from 1000 Hz to 2000 Hz covers 1000 Hz, which is only about 522 mel. Doubling the frequency does not double the mel value, so the high octaves are squeezed. Check: 500 Hz is 607.5 mel and 2000 Hz is 1522 mel, so the two spans are 392.5 and 522.
  4. Place filters evenly in mel. Pick three filter centers at 0, 1000 and 2000 mel. Convert them back to hertz with the inverse conversion, f=700(10m/2595−1)f = 700\left(10^{m/2595} - 1\right): they sit at 0 Hz, 1000 Hz and about 3429 Hz. Check: 2000 mel gives about 3429 Hz, and going forward again gives 2000 mel. In hertz, the centers are 1000 Hz apart at the bottom and about 2429 Hz apart at the top.
  5. Share each tone among the filters. Each filter is a triangle on the mel axis, with weight 1 at its center and falling to 0 one thousand mel away. A 2000 Hz tone is at 1522 mel, so the middle filter gives it weight 1−0.522=0.4781 - 0.522 = 0.478 and the top filter gives it weight 0.5220.522. Check: the weights add to 1, so no energy is lost or double-counted.
  6. Repeat for every slice of audio. Stacking the filter energies over time gives a mel spectrogram. Taking the logarithm of each energy, as many systems do, is the subject of the mel spectrogram lesson.
05001000150020002500300035004000050010001500200025003000frequency (Hz)pitch (mel)
  • mel scale
  • linear (mel = Hz)
The mel curve rises steeply at low frequencies and flattens above a few kilohertz. The dashed line shows the linear scale, which would give high frequencies the same resolution as low ones. The two agree at 1000 Hz, the scale's reference point.

The math

Definition: Mel scale

The mel scale maps a frequency ff in hertz to a pitch mm in mel by m(f)=2595log⁡10 ⁣(1+f700)m(f) = 2595 \log_{10}\!\left(1 + \frac{f}{700}\right). Its inverse maps mel back to hertz: f(m)=700(10m/2595−1)f(m) = 700\left(10^{m/2595} - 1\right). The constants are chosen so that m(1000)=1000m(1000) = 1000.

Step 2 in symbols: the conversion

For a tone at frequency ff, the logarithm is base 10, so log⁡10x\log_{10} x is the power to which 10 must be raised to give xx. The argument 1+f/7001 + f/700 is always at least 1, so mm is never negative and is zero at f=0f = 0.

Check at 1000 Hz: 1+1000/700=2.42861 + 1000/700 = 2.4286, log⁡102.4286=0.3854\log_{10} 2.4286 = 0.3854, and 2595×0.3854=1000.02595 \times 0.3854 = 1000.0.

Step 3 in symbols: how fast the scale stretches

The slope of the scale is its derivative:

dmdf=2595ln⁡10 (700+f)≈1127700+f\frac{dm}{df} = \frac{2595}{\ln 10 \,(700 + f)} \approx \frac{1127}{700 + f}

At f=0f = 0 the slope is about 1.61.6 mel per hertz. At f=1000f = 1000 Hz it is about 0.660.66, and at f=8000f = 8000 Hz it is about 0.130.13. So each hertz at the top of the band spans about one-twelfth as many mel as each hertz at the bottom. That falling slope is the squeeze in step 3 of the walkthrough.

Steps 4 and 5 in symbols: the filter weights

Filter kk has its center at mel value ckc_k, and the filters are spaced Δ\Delta mel apart. Its triangular weight for a tone at mel value mm is

Hk(m)=max⁡ ⁣(0,  1−∣m−ck∣Δ)H_k(m) = \max\!\left(0,\; 1 - \frac{|m - c_k|}{\Delta}\right)

With centers 00, 10001000, 20002000 and Δ=1000\Delta = 1000, a tone at m=1522m = 1522 receives H2=1−522/1000=0.478H_2 = 1 - 522/1000 = 0.478 from the filter at 1000 and H3=1−478/1000=0.522H_3 = 1 - 478/1000 = 0.522 from the filter at 2000. Neighboring triangles overlap so that their weights always add to 1 between two centers. The energy in band kk is the sum of Hk(m)H_k(m) times the energy of each tone.

Where a frequency falls between two bins of a discrete spectrum, the weight is computed by linear interpolation between the bins.

Worked examples

Example
Tiny: convert 1000 Hz
  1. Write the formula: m=2595log⁡10(1+f/700)m = 2595 \log_{10}(1 + f/700).
  2. Put in f=1000f = 1000: 1+1000/700=2.42861 + 1000/700 = 2.4286.
  3. Take the base-10 logarithm: log⁡102.4286=0.3854\log_{10} 2.4286 = 0.3854.
  4. Multiply: 2595×0.3854=10002595 \times 0.3854 = 1000.

Interpretation: 1000 Hz is 1000 mel. This is the reference point, and any other frequency is judged against it.

Example
Standard: weights for two tones on a three-filter bank

Filters are centered at 0, 1000 and 2000 mel, with Δ=1000\Delta = 1000. Take two tones.

  1. A 250 Hz tone: m=2595log⁡10(1+250/700)=344m = 2595 \log_{10}(1 + 250/700) = 344 mel.
  2. Weight from the filter at 0 mel: 1−344/1000=0.6561 - 344/1000 = 0.656.
  3. Weight from the filter at 1000 mel: 1−(1000−344)/1000=0.3441 - (1000 - 344)/1000 = 0.344.
  4. Check: 0.656+0.344=10.656 + 0.344 = 1.
  5. A 3000 Hz tone: m=2595log⁡10(1+3000/700)=1877m = 2595 \log_{10}(1 + 3000/700) = 1877 mel.
  6. Weight from the filter at 1000 mel: 1−(1877−1000)/1000=0.121 - (1877 - 1000)/1000 = 0.12.
  7. Weight from the filter at 2000 mel: 1−(2000−1877)/1000=0.881 - (2000 - 1877)/1000 = 0.88.
  8. Check: 0.12+0.88=10.12 + 0.88 = 1.

Interpretation: the low tone falls mostly in the lowest band and the high tone mostly in the top band, and the bands never lose any of the tone's energy.

Example
Realistic: a 40-filter bank for speech up to 8 kHz

A speech system covers 0 to 8000 Hz with 40 filters spaced evenly in mel.

  1. The top of the band is m(8000)=2595log⁡10(1+8000/700)=2840m(8000) = 2595 \log_{10}(1 + 8000/700) = 2840 mel.
  2. Forty evenly spaced filters give a spacing of 2840/40=712840/40 = 71 mel.
  3. The first filter's edge is at f(71)=700(1071/2595−1)=46f(71) = 700(10^{71/2595} - 1) = 46 Hz, so the lowest band spans about 46 Hz.
  4. Near the top, the band edges sit at f(2769)≈7469f(2769) \approx 7469 Hz and f(2840)=8000f(2840) = 8000 Hz.
  5. Try it: how many hertz wide is the top band, from 7469 Hz to 8000 Hz?

Answer: about 530 Hz. The bottom band is about 46 Hz wide and the top band about 530 Hz wide, roughly eleven times wider. The filters follow the ear, not a uniform grid.

Common mistakes and tradeoffs

It is tempting to think the mel scale measures loudness. In fact it measures pitch, the perceived height of a tone. Loudness is a separate perception, tied to sound level, which is usually reported in decibels.

It is tempting to think that a pitch of 2000 mel is twice as high as 1000 mel. The scale was built from listening tests, where listeners judged when intervals sounded equal. It is a convenient fit to those tests, not a ratio scale, and other fits exist, such as the Bark and ERB scales.

It is tempting to think that the mel scale is always the right choice. It is a good choice for speech and general sound classification, where detail at high frequencies matters less than the overall shape. It is a poor choice for tasks that need precise high-frequency detail, such as tracking a harmonic at 6 kHz in music, because its top bands are wide. In those cases a linear frequency axis, as in a plain Fourier transform spectrum, is better. Some modern systems learn their filters from data instead of fixing them to the mel scale, at the cost of needing more training data.

Frequency axisStrengthWeakness
Linear (hertz)Full detail at every frequencyWastes detail at high frequencies that the ear cannot separate
MelCompact, matches hearing for speechCoarse at high frequencies; fixed in advance
Learned filtersAdapts to the taskNeeds more data and training

History

In the 1930s, researchers were trying to measure how the ear maps frequency to pitch. In 1937, Stevens, Volkmann and Newman asked listeners to judge when one tone sounded half as high as another, and fitted a scale to the results, with 1000 mel defined as 1000 Hz. The name comes from "melody". The scale stayed a laboratory curiosity until engineers needed a compact description of speech.

In 1980, Davis and Mermelstein introduced mel-frequency cepstral coefficients for recognizing spoken words. Their features used mel-spaced filters and became the standard front end for speech recognition for decades. When neural networks replaced hand-built pipelines, the mel-spaced energies stayed in use as the network's input, which is why the mel spectrogram remains a common first step.

Recap

  • Frequency in hertz is not how the ear hears pitch: the ear is sharper at low frequencies and coarser at high ones.
  • The mel formula m=2595log⁡10(1+f/700)m = 2595 \log_{10}(1 + f/700) converts hertz to mel, with 1000 Hz mapped to 1000 mel.
  • Filters spaced evenly in mel are narrow in hertz at the bottom and wide at the top.
  • A tone between two filter centers splits its energy between them with triangular weights that sum to 1.
  • Read next: Mel Spectrogram for the time-frequency picture built from these bands, and Automatic Speech Recognition for the main system that uses them.

Check yourself

QuestionWhat is the pitch in mel of a tone at 1000 Hz?Show answer

1000 mel. The scale is defined so that 1000 Hz maps to 1000 mel: 2595log⁡10(1+1000/700)≈10002595 \log_{10}(1 + 1000/700) \approx 1000.

QuestionCompute the pitch in mel of a 4000 Hz tone.Show answer

About 2146 mel. Compute 1+4000/700=6.71431 + 4000/700 = 6.7143, then log⁡106.7143=0.8270\log_{10} 6.7143 = 0.8270, then 2595×0.8270=21462595 \times 0.8270 = 2146. Note that 4000 Hz is four times 1000 Hz but only about twice 1000 mel.

QuestionWhy do speech systems not use filters spaced evenly in hertz?Show answer

Evenly spaced hertz filters would give the same width everywhere, which is too coarse at low frequencies, where the ear is sharp, and too fine at high frequencies, where the ear cannot separate nearby tones. Spacing the filters evenly in mel puts more of them where hearing resolves detail and fewer where it does not, and it keeps the number of features small.

QuestionA music tool must find the exact frequency of a harmonic near 6 kHz. Should it use mel-spaced bands?Show answer

No. The top mel bands are hundreds of hertz wide, about 530 Hz near 8 kHz, so a harmonic near 6 kHz would fall into a band too wide to pin its exact frequency. A linear frequency axis gives the uniform resolution this task needs.

Sources