Algorithms | latest | spectral-rolloff
Spectral rolloff
The
The
The roll-off frequency
Typical values for
Parameters
Name | Description | Unit | Limits |
---|---|---|---|
rolloff | Roll-off point | % | [0, 100] |
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: int):
ps = np.abs(spectrum) ** 2
ps_sum_rolloff = (rolloff / 100) * 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