Struct SpectralDesc

Source
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

Source

pub const WINDOW_SIZE: usize = 512usize

Source

pub const HOP_SIZE: usize = 128usize

Source

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.

Source

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

Source

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.

Source

pub fn new(sample_rate: u32) -> AnalysisResult<Self>

§Errors

This function will return an error if there is an error loading the aubio objects

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V