Class SpectralCentroid
Calculates the spectral centroid of a spectrum, or a recording segment. The spectral centroid is a considred to be a reliable estimate of the brightness of a recording. Bright recordings contain more high frequency content. It is included here as a summary index because it was found to be correlated with degree of "naturalness" of a bush soundscape. See recent papers from Sussex University (Alice Eldridge and colleagues) (1) Eldridge, Alice and Guyot, Patrice and Moscoso, Paola and Johnston, Alison and Eyre-Walker, Ying and Peck, Mika "Sounding out ecoacoustic metrics: Avian species richness is predicted by acoustic indices in temperate but not tropical habitats." (2018) Ecological Indicators, 95 (1). 939-952. ISSN 1470-160X (2) Carruthers-Jones, Jonathan, Eldridge, Alice, Guyot, Patrice, Hassal, Christopher and Holmes, George "The call of the wild: investigating the potential for ecoacoustic methods in mapping wilderness areas." (2019) Science of The Total Environment, 695. p. 133797. ISSN 0048-9697
See following for good intro to calculating the Spectral Centroid: https://www.cs.cmu.edu/~music/icm/slides/05-algorithmic-composition.pdf Also Wikipedia entry: https://en.wikipedia.org/wiki/Spectral_centroid The spectral centroid is derived from the values in the AMPLITUDE spectrogram. A single spectral centroid is calculated for each time frame. If a summary value is required for a longer signal, i.e. one second or one minute, then the centroid values for each frame are averaged over the time period. Note that the frequency value for a bin is located at the centre of the bin. For a typical bin width of 43 Hz, the centre will be at 21.5 Hz above bin minimum. The steps in the calculation are: 1: Normalise the spectrum: normalized_spectrum = spectrum / sum(spectrum) # like a probability mass function 2: Normalise the frequency values in [0,1], where the nyquist freq = 1.0. 3: spectral_centroid = sum(normalized_frequencies* normalized_spectrum) Note: When calculated this way the Spectral centroid is a ratio. Multiply this value by the Nyquist (maximum frequency) to get the centroid in Hertz.
Inherited Members
Namespace: AudioAnalysisTools
Assembly: AudioAnalysisTools.dll
Syntax
public static class SpectralCentroid
Methods
| Improve this Doc View SourceAverageSpectralCentroidsInOneSecondSegments(Double[], Double)
Declaration
public static double[] AverageSpectralCentroidsInOneSecondSegments(double[] centroidArray, double framesPerSecond)
Parameters
Type | Name | Description |
---|---|---|
Double[] | centroidArray | |
Double | framesPerSecond |
Returns
Type | Description |
---|---|
Double[] |
CalculateSpectralCentroid(Double[], Int32)
Calculates the spectral centroid of the given amplitude spectrum. See notes above.
Declaration
public static double CalculateSpectralCentroid(double[] spectrum, int nyquist)
Parameters
Type | Name | Description |
---|---|---|
Double[] | spectrum | Amplitude spectrum. |
Int32 | nyquist |
Returns
Type | Description |
---|---|
Double | Centroid. |
CalculateSpectralCentroids(AmplitudeSpectrogram)
Calculates the spectral centroid for each frame of an amplitude spectrogram.
Declaration
public static double[] CalculateSpectralCentroids(AmplitudeSpectrogram spectrogram)
Parameters
Type | Name | Description |
---|---|---|
AmplitudeSpectrogram | spectrogram | As AmplitudeSpectrogram. |
Returns
Type | Description |
---|---|
Double[] | An array of spectral centroids. |
CalculateSpectralCentroids(Double[,], Int32)
This method assumes that the rows of the passed matrix are spectra and the columns are frequency bins.
Declaration
public static double[] CalculateSpectralCentroids(double[, ] spectra, int nyquist)
Parameters
Type | Name | Description |
---|---|---|
Double[,] | spectra | As a matrix. |
Int32 | nyquist | The maximum frequency. |
Returns
Type | Description |
---|---|
Double[] | An array of spectral centroids. |
CalculateSpectralCentroidsInOneSecondSegments(AmplitudeSpectrogram)
Calculates the spectral centroid for each one-second segment of an amplitude spectrogram.
Declaration
public static double[] CalculateSpectralCentroidsInOneSecondSegments(AmplitudeSpectrogram spectrogram)
Parameters
Type | Name | Description |
---|---|---|
AmplitudeSpectrogram | spectrogram | As AmplitudeSpectrogram. |
Returns
Type | Description |
---|---|
Double[] | An array of spectral centroids. |