pub struct SpectralDesc { /* private fields */ }Expand description
General object holding all the spectral descriptor.
Holds 3 spectral descriptors together. It would be better conceptually to have 3 different spectral descriptor objects, but this avoids re-computing the same FFT three times.
Current spectral descriptors are spectral centroid, spectral rolloff and
spectral flatness (see values_object for a further description of the
object.
All descriptors are currently summarized by their mean only.
Implementations§
Source§impl SpectralDesc
impl SpectralDesc
pub const WINDOW_SIZE: usize = 512usize
pub const HOP_SIZE: usize = 128usize
Sourcepub fn get_centroid(&mut self) -> Vec<Feature> ⓘ
pub fn get_centroid(&mut self) -> Vec<Feature> ⓘ
Compute score related to the
spectral centroid values,
obtained after repeatedly calling do_ on all of the song’s chunks.
Spectral centroid is used to determine the “brightness” of a sound, i.e. how much high frequency there is in an audio signal.
It of course depends of the instrument used: a piano-only track that makes use of high frequencies will still score less than a song using a lot of percussive sound, because the piano frequency range is lower.
The value range is between 0 and sample_rate / 2.
Sourcepub fn get_rolloff(&mut self) -> Vec<Feature> ⓘ
pub fn get_rolloff(&mut self) -> Vec<Feature> ⓘ
Compute score related to the spectral roll-off values, obtained
after repeatedly calling do_ on all of the song’s chunks.
Spectral roll-off is the bin frequency number below which a certain percentage of the spectral energy is found, here, 95%.
It can be used to distinguish voiced speech (low roll-off) and unvoiced speech (high roll-off). It is also a good indication of the energy repartition of a song.
The value range is between 0 and sample_rate / 2
Sourcepub fn get_flatness(&mut self) -> Vec<Feature> ⓘ
pub fn get_flatness(&mut self) -> Vec<Feature> ⓘ
Compute score related to the
spectral flatness values,
obtained after repeatedly calling do_ on all of the song’s chunks.
Spectral flatness is the ratio between the geometric mean of the spectrum and its arithmetic mean.
It is used to distinguish between tone-like and noise-like signals. Tone-like audio is f.ex. a piano key, something that has one or more specific frequencies, while (white) noise has an equal distribution of intensity among all frequencies.
The value range is between 0 and 1, since the geometric mean is always less than the arithmetic mean.
Sourcepub fn new(sample_rate: u32) -> AnalysisResult<Self>
pub fn new(sample_rate: u32) -> AnalysisResult<Self>
§Errors
This function will return an error if there is an error loading the aubio objects
Sourcepub fn do_(&mut self, chunk: &[f32]) -> AnalysisResult<()>
pub fn do_(&mut self, chunk: &[f32]) -> AnalysisResult<()>
Compute all the descriptors’ value for the given chunk.
After using this on all the song’s chunks, you can call
get_centroid, get_flatness and get_rolloff to get the respective
descriptors’ values.
Auto Trait Implementations§
impl Freeze for SpectralDesc
impl RefUnwindSafe for SpectralDesc
impl !Send for SpectralDesc
impl !Sync for SpectralDesc
impl Unpin for SpectralDesc
impl UnwindSafe for SpectralDesc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more