mel_spectrogram
Builtin index · Signal processing
mel_spectrogram(x, fs, [n_mels=40], [fmin=0], [fmax=fs/2], [nfft=256], [hop=nfft/2])
Input: x, fs, n_mels, fmin, fmax, nfft, hop · Output: no output
What it is
x is a length-N real vector or Signal; fs (number, Hz) is the sample rate, or is carried by a Signal. n_mels (optional number, default 40) is how many mel bands to collapse the spectrum onto; fmin/fmax (optional numbers, Hz, default 0 and Nyquist) bound the filterbank; nfft/hop (optional numbers) are the STFT frame size and stride, exactly as in stft. Mel-scale spectrogram: an stft power spectrogram folded onto perceptually-spaced bands by triangular filters laid out on mel = 2595*log10(1+f/700). Equal steps in mel are equal steps in perceived pitch, which equal steps in Hz are not. Built on the same stft that spectrogram and spectral_entropy use, so all of them agree frame-for-frame. Draws a dB heatmap and returns a Record with fields power (an (n_mels, frames) Mat of band powers, row 0 = the lowest band), freq (length-n_mels Vec of band centre frequencies in Hz — crowded at the bottom of the range, spread out at the top) and time (length-frames Vec, seconds). A band narrower than the STFT's own bin spacing fs/nfft can fall entirely between two bins and come back zero: that is n_mels asking for finer resolution than nfft supplies, so raise nfft or lower n_mels. Added in v0.3.0.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
mel_spectrogram(x, fs, [n_mels=40], [fmin=0], [fmax=fs/2], [nfft=256], [hop=nfft/2]) | x vector or Signalx is a length-N real vector or Signal.fs number or Signalfs (number, Hz) is the sample rate, or is carried by a Signal.n_mels number, optional (default 40)n_mels (optional number, default 40) is how many mel bands to collapse the spectrum onto.fmin number, optional (default 0)fmin/fmax (optional numbers, Hz, default 0 and Nyquist) bound the filterbank.fmax number, optional (default fs/2)fmin/fmax (optional numbers, Hz, default 0 and Nyquist) bound the filterbank.nfft number, optional (default 256)nfft/hop (optional numbers) are the STFT frame size and stride, exactly as in stft.hop number, optional (default nfft/2)nfft/hop (optional numbers) are the STFT frame size and stride, exactly as in stft. | not documented yet | Mel-scale spectrogram: an stft power spectrogram folded onto perceptually-spaced bands by triangular filters laid out on mel = 2595*log10(1+f/700). Equal steps in mel are equal steps in perceived pitch, which equal steps in Hz are not. Built on the same stft that spectrogram and spectral_entropy use, so all of them agree frame-for-frame. Added in v0.3.0. |
Examples
No documentation example calls this form yet. The Signal processing chapter is where one belongs.
How it works
mel_spectrogram(x, fs, [n_mels=40], [fmin=0], [fmax=fs/2], [nfft=256], [hop=nfft/2]) — an stft power spectrogram collapsed onto perceptually-spaced bands by a triangular mel filterbank. Built on the same stft this file's own stft/spectral_entropy/spectrogram use, so all four agree frame-for-frame.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.