Skip to content

Spectral rolloff

The spectral roll-off point is defined as the frequency below which a specified proportion of the total energy of the spectrum is contained. This proportion is given by the rolloff parameter, which is a value in the range [0,1].

It is computed from the power spectrum Xp=|X|2RM. The roll-off point is estimated by iteratively increasing r[0,M) in the following equation until the equation becomes valid:

m=0rXp[m]nm=0M1Xp[m]

The roll-off frequency frolloff can be computed from r and the sampling rate fs:

frolloff=fs2rM

Typical values for n are 0.95, 0.90, 0.75 and 0.50.

Parameters

NameDescriptionUnitLimits
rolloffRoll-off point n[0, 1]

References

  • Peeters, G. (2004). A large set of audio features for sound description (similarity and classification) in the CUIDADO project. In CUIDADO IST Project Report (Vol. 54).
  • Eyben, F. (2016). Real-time Speech and Music Classification by Large Audio Feature Space Extraction. https://doi.org/10.1007/978-3-319-27299-3

Code

INFO

The following snippet is written in a generic and unoptimized manner. The code aims to be comprehensible to programmers familiar with various programming languages and may not represent the most efficient or idiomatic Python practices. Please refer to implementations for optimized implementations in different programming languages.

py
import numpy as np


def spectral_rolloff(spectrum: np.ndarray, samplerate: float, rolloff: float):
    ps = np.abs(spectrum) ** 2
    ps_sum_rolloff = rolloff * np.sum(ps)
    ps_sum = 0.0
    for i, magnitude in enumerate(ps):
        ps_sum += magnitude
        if ps_sum >= ps_sum_rolloff:
            return 0.5 * samplerate / (len(ps) - 1) * i
    return 0.5 * samplerate

Run in playground