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
It is computed from the power spectrum
The roll-off frequency
Typical values for
Parameters
Name | Description | Unit | Limits |
---|---|---|---|
rolloff | Roll-off point | [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.
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