MFCC, Log-Mel Spectrogram and Spectral Contrast

These three analyses convert a recording into the input representations that acoustic machine learning models expect. MFCC gives a compact cepstral description of the spectral envelope, Log-Mel Spectrogram gives the mel-band time-frequency matrix that convolutional audio models are trained on, and Spectral Contrast describes how strongly peaks stand out from valleys within octave sub-bands — a direct measure of tonality against broadband background.

All three are available as a time-axis analysis and as a vs. RPM analysis, so the same descriptor can be tracked over a run-up.

Signal Chain

signal → frames → window → FFT → |X|² power → mel filter bank → log → (DCT) → feature

MFCC and Log-Mel share the mel filter bank; MFCC adds the discrete cosine transform at the end. Spectral Contrast skips the mel stage and works on the linear magnitude spectrum with DC and Nyquist bins removed.

Mel Scale and Filter Bank

The mel scale compresses frequency in a way that approximates the resolution of hearing:

mel(f) = 2595 · log₁₀(1 + f / 700)    f(mel) = 700 · (10mel/2595 − 1)

NMels triangular filters are laid out with equal spacing on the mel axis between FMin and FMax. Each triangle rises linearly from its lower edge to its centre and falls back to its upper edge, and is scaled to unit area so that wide high-frequency filters do not accumulate more energy than narrow low-frequency ones:

area scaling of filter m = 2 / (fm+2 − fm)
frequency (Hz, linear axis) weight narrow, tall at low f wide, low at high f Triangular mel filter bank, unit area per filter

MFCC (with Δ and ΔΔ)

Definition

Each frame is transformed to a power spectrum, integrated by the mel filter bank into NMels band energies Em, converted to a logarithmic scale and finally decorrelated by an orthonormal DCT-II. The first NMfcc coefficients are kept:

Lm = 10 · log₁₀( max(Em, 10−10) )
cn = √(2/M) · Σm=0..M−1 Lm · cos( π · n · (m + 0.5) / M )

Coefficient c₀ reflects the overall level of the frame, the low coefficients describe the coarse shape of the spectral envelope and the higher ones describe increasingly fine detail. The result is displayed as a colormap with the coefficient index on one axis and time (or speed) on the other.

Delta and Delta-Delta

Dynamic coefficients capture how the envelope moves. They are computed by the classical regression formula over a window of DeltaWidth frames on each side, with edge frames repeated at the boundaries:

dt = Σi=1..M i · (ct+i − ct−i) / (2 · Σi=1..M i²)

DeltaOrder = 1 adds a ΔMFCC colormap, DeltaOrder = 2 additionally adds a ΔΔMFCC colormap (the same operator applied to ΔMFCC). A linear ramp in a coefficient therefore produces a constant Δ, and a constant coefficient produces Δ = 0.

Parameters

ParameterDefaultNotes
NMfcc13Number of cepstral coefficients kept
NMels64Mel filters; forced to be at least NMfcc
FFTSize1024 (vs. Time) / 4096 (vs. RPM)Block length in samples
Overlap50 (%)vs. Time only
WindowHanningApplied before the FFT
FMin / FMax0 / fs∕2 HzFrequency range covered by the filter bank
DeltaOrder20 = MFCC only, 1 = +Δ, 2 = +Δ and ΔΔ
DeltaWidth2Regression half-width in frames
RpmStep50 rpmvs. RPM only
SlopeModeAutoDetectvs. RPM only: AutoDetect / Runup / Rundown / All

Log-Mel Spectrogram

Framing in milliseconds

This analysis is deliberately parameterized in milliseconds rather than in FFT points, because pretrained acoustic models specify their input that way. The frame length is FrameMs, the hop is HopMs, both converted to samples at the current sample rate. Each frame is windowed at its true length and then zero-padded to the next power of two before the FFT, which is the usual convention for this class of model:

frame = round(fs · FrameMs / 1000)   hop = round(fs · HopMs / 1000)   NFFT = next power of two ≥ frame

The default set — 25 ms frames, 10 ms hop, 64 mel bands from 125 Hz to 7500 Hz — is the layout used by the widely deployed VGGish-style front end, so the exported matrix can be handed to such a model without resampling the feature grid.

Log modes: dB and ln

LogModeMappingUse
dB (default)10 · log₁₀( max(E, 10−10) )Display and reporting — readable decibel values
lnln( E + 0.01 )Model input — the training-domain scaling of VGGish-style front ends

The colormap axis is labelled with the mel band centre frequencies in Hz, and the value unit follows the selected mode (dB or ln).

Parameters

ParameterDefaultNotes
NMels64Number of mel bands
FrameMs25 msvs. Time only
HopMs10 msvs. Time only
FMin125 HzLower edge of the filter bank
FMax7500 HzUpper edge; clipped to fs∕2
LogModedBdB or ln
WindowHanningApplied to the frame before zero padding
FFTSize4096vs. RPM only — block length taken at each RPM step
RpmStep50 rpmvs. RPM only
SlopeModeAutoDetectvs. RPM only

Spectral Contrast

Sub-band layout

The spectrum is divided into octave sub-bands starting at ContrastFMin. With ContrastBands = B the band edges are

[ 0, fmin, 2fmin, 4fmin, …, fmin · 2B ]

which yields B + 1 sub-bands (the lowest one covers everything below ContrastFMin). Each sub-band is labelled by the geometric mean of its edges; for the lowest band the lower edge is taken as ContrastFMin∕2 so that the label stays finite.

Peak and valley contrast

Within each sub-band the power spectral lines are sorted. The mean of the top ContrastAlpha fraction is the peak estimate, the mean of the bottom ContrastAlpha fraction is the valley estimate, and the contrast is their level difference:

Contrastb = 10 · log₁₀(peakb) − 10 · log₁₀(valleyb)  [dB]

A flat, noise-like sub-band gives a contrast near 0 dB. A single strong tone rising out of a quiet background gives a large contrast. Because the estimate is a quantile average rather than a single extreme line, it is far less sensitive to a stray spike than a plain peak-to-mean ratio.

Parameters

ParameterDefaultNotes
SpectrumSize4096Block length in samples
Overlap0.5vs. Time only; a value ≥ 1 is interpreted as a percentage
WindowHanningApplied before the FFT
ContrastFMin200 HzLower edge of the first octave sub-band
ContrastBands6Octave bands; the result has ContrastBands + 1 rows
ContrastAlpha0.02Quantile fraction used for the peak and valley estimates
RpmStep50 rpmvs. RPM only
SlopeModeAutoDetectvs. RPM only

vs. Time and vs. RPM

In the vs. Time form the analysis advances by a fixed hop along the recording and produces one column per block; the block centre defines the time stamp. In the vs. RPM form one block is taken at every crossing of an RPM step, so the horizontal axis is speed in rpm. Steps for which no complete block fits inside the recording are left empty rather than extrapolated.

Applications

Formulas follow the established public conventions for these descriptors: the HTK mel scale with unit-area triangular filters and orthonormal DCT-II for MFCC, the classical HTK regression formula for Δ/ΔΔ, and the octave sub-band peak/valley definition of spectral contrast.

© 2026 Deepsona. All Rights Reserved.