Module analysis

Source
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 Analysis struct containing the analysis.
autocorrelation
Computes the autocorrelation of a signal of length fft_size using the FFT method described in Eyben, 45. You must zero-pad the audio before calling this function if the audio length does not match the fft_size. This autocorrelation method performs N/2 zero-padding to the left and right as described in Eyben, 45. The resulting f64 vector contains only the computed values for tau >= 0 and has length fft_size.
dbfs
Calculates dBFS. All dBFS values below epsilon will render as NEG_INFINITY. Suggested epsilon value 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 pyin crate. 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 pyin crate. 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)