Expand description
§Analysis
The analysis module contains functionality for audio and spectrum analysis.
Some analysis tools are based on formulas from Florian Eyben, “Real-Time Speech and Music Classification,” Springer, 2016.
Structs§
- Analysis
- Represents a spectral analysis of a FFT frame. Contains computed spectral features.
Enums§
- Norm
- Represents a L1 or L2 norm.
Functions§
- alpha_
ratio - Calculates the alpha ratio from provided magnitude spectrum. The alpha ratio is calculated by summing the bins from 50Hz to 1kHz, and dividing this by the sum of the bins from 1kHz to 2kHz. This function suggests the use of the magnitude spectrum, although you can choose to use another spectrum. (Eyben, p. 38)
- analyzer
- Performs a suite of spectral analysis tools on a provided rFFT magnitude spectrum.
This function is more efficient than calculating the spectral features separately.
It returns an
Analysisstruct containing the analysis. - autocorrelation
- Computes the autocorrelation of a signal of length
fft_sizeusing the FFT method described in Eyben, 45. You must zero-pad the audio before calling this function if theaudiolength does not match thefft_size. This autocorrelation method performsN/2zero-padding to the left and right as described in Eyben, 45. The resultingf64vector contains only the computed values fortau >= 0and has lengthfft_size. - dbfs
- Calculates dBFS. All dBFS values below
epsilonwill render as NEG_INFINITY. Suggestedepsilonvalue is 1e-20, corresponding to -400.0 dBFS. - dbfs_
max - Calculates the max dBFS in a list of audio samples.
- dc_bias
- Calculates the DC bias of the signal.
- energy
- Extracts the RMS energy of the signal. (Eyben, pp. 21-22)
- hammarberg_
index - Calculates the Hammarberg index from provided magnitude spectrum. This function suggests the use of the magnitude spectrum, although you can choose to use another spectrum. (Eyben, p. 38)
- harmonicity
- Calculates the harmonicity of a magnitude pectrum (determines how harmonic a signal is). (Eyben, 43-44)
- make_
power_ spectrum - Creates a power spectrum based on a provided magnitude spectrum.
- pyin_
pitch_ estimator - Performs pYIN pitch estimation using the
pyincrate. Returns the pYIN output vectors (timestamp, pitch estimation, probability, voiced). See https://docs.rs/pyin/1.2.0/pyin/struct.PYINExecutor.html#method.pyin for details. - pyin_
pitch_ estimator_ single - Performs pYIN pitch estimation using the
pyincrate. This wrapper expects the pitch to be the same for the entire audio array, so it will run the pYIN algorithm and choose the median output frequency. - spectral_
centroid - Calculates the spectral centroid from provided magnitude spectrum. (Eyben, pp. 39-40)
- spectral_
difference - Computes the spectral difference between two STFT frames using the L2 norm. You can optionally choose to only considere positive spectral differences in this calculation. (Eyben, 42)
- spectral_
entropy - Calculates the spectral entropy from provided magnitude spectrum. (Eyben, pp. 23, 40, 41)
- spectral_
flatness - Calculates the spectral flatness from provided magnitude spectrum. (Eyben, p. 39, https://en.wikipedia.org/wiki/Spectral_flatness)
- spectral_
flux - Computes the spectral flux between two STFT frames. You can choose which normalization coefficients will be used (None, which corresponds to 1, or the L1 or L2 norm.) (Eyben, 42-43)
- spectral_
kurtosis - Calculates the spectral kurtosis from provided magnitude spectrum and real FFT frequency list. (Eyben, pp. 23, 39-40)
- spectral_
roll_ off_ point - Calculates the spectral roll off frequency from provided magnitude spectrum, real FFT frequency list, and roll-off point.
The parameter
n(0.0 <= n <= 1.00) indicates the roll-off point we wish to calculate. (Eyben, p. 41) - spectral_
skewness - Calculates the spectral skewness from provided magnitude spectrum and real FFT frequency list. (Eyben, pp. 23, 39-40)
- spectral_
slope - Calculates the spectral slope from provided magnitude spectrum. (Eyben, pp. 35-38)
- spectral_
slope_ region - Calculates the spectral slope from provided magnitude spectrum, between the frequencies specified. The frequencies specified do not have to align with the frequencies in the real FFT frequency list. (Eyben, pp. 35-38)
- spectral_
variance - Calculates the spectral variance from provided magnitude spectrum and real FFT frequency list. (Eyben, pp. 23, 39-40)
- zero_
crossing_ rate - Calculates the zero crossing rate. (Eyben, p. 20)