pytimbre.timbre_features.metrics.spectral.SpectralMetrics¶
- class pytimbre.timbre_features.metrics.spectral.SpectralMetrics¶
Bases:
objectThis class represents spectral metrics from the spectrum.
- __init__()¶
This creates the internal representation of the spectral timbre metrics
Methods
__init__()This creates the internal representation of the spectral timbre metrics
from_spectrum(spec)This creates an instance of the class and updates the internal representations of the spectral features that are calculated for a single spectrum.
get_features()Attributes
mean_centerSpectral centroid represents the spectral center of gravity.
The spectral crest measure is obtained by comparing the maximum value and arithmetical mean of the spectrum.
spectral_dataSpectral decrease was proposed by Krimphoff (1993) in relation to perceptual studies.
A summation of the energy within the spectrum
Spectral flatness is obtained by comparing the geometrical mean and the arithmetical mean of the spectrum.
Spectral kurtosis gives a measure of the flatness of the spectrum around its mean value.
Spectral roll-off was proposed by Scheirer and Slaney (1997).
Spectral skewness gives a measure of the asymmetry of the spectrum around its mean value.
Spectral slope is computed using a linear regression over the spectral amplitude values.
Spectral spread or spectral standard-deviation represents the spread of the spectrum around its mean value.
- static from_spectrum(spec: Spectrum)¶
This creates an instance of the class and updates the internal representations of the spectral features that are calculated for a single spectrum. :param spec: the sound pressure level spectrum for the spectral metrics :type spec: Spectrum :return: the class with the various spectral timbre features :rtype: SpectralMetrics
- property spectral_centroid¶
Spectral centroid represents the spectral center of gravity.
- property spectral_crest¶
The spectral crest measure is obtained by comparing the maximum value and arithmetical mean of the spectrum.
- property spectral_decrease¶
Spectral decrease was proposed by Krimphoff (1993) in relation to perceptual studies. It averages the set of slopes between frequency f[k] and f[1]. It therefore emphasizes the slopes of the lowest frequencies.
- property spectral_energy¶
A summation of the energy within the spectrum
- property spectral_flatness¶
Spectral flatness is obtained by comparing the geometrical mean and the arithmetical mean of the spectrum. The original formulation first splot the spectrum into various frequency bands (Johnston, 1988). However, in the context of timbre characterization, we use a single frequency band covering the whole frequency range. For tonal signals, the spectral flatness is close to 0( a peaky spectrum), whereas for noisy signals it is close to 1 (flat spectrum).
- property spectral_kurtosis¶
Spectral kurtosis gives a measure of the flatness of the spectrum around its mean value. Values approximately 3 indicate a normal (Gaussian) distribution, values less than 3 indicate a flatter distributions, and values greater than 3 indicate a peakier distribution.
- property spectral_roll_off¶
Spectral roll-off was proposed by Scheirer and Slaney (1997). It is defined as the frequency below which 95% of the signal energy is contained. The value is returned as the normalized frequency (i.e. you must multiply by the sample rate to determine the actual frequency of the roll-off.
- property spectral_skewness¶
Spectral skewness gives a measure of the asymmetry of the spectrum around its mean value. A value of 0 indicates a symmetric distribution, a value < 0 more energy at frequencies lower than the mean value, and values > 0 more energy at higher frequencies.
- property spectral_slope¶
Spectral slope is computed using a linear regression over the spectral amplitude values. It should be noted that the spectral slope is linearly dependent on the spectral centroid.
- property spectral_spread¶
Spectral spread or spectral standard-deviation represents the spread of the spectrum around its mean value.