pub struct Analysis { /* private fields */ }Expand description
Object holding the results of the song’s analysis.
Only use it if you want to have an in-depth look of what is happening behind the scene, or make a distance metric yourself.
Under the hood, it is just an array of f32 holding different numeric features.
For more info on the different features, build the
documentation with private items included using
cargo doc --document-private-items, and / or read up
this document, that contains a description
on most of the features, except the chroma ones, which are documented
directly in this code.
Implementations§
Source§impl Analysis
impl Analysis
Sourcepub const fn new(analysis: [Feature; 20]) -> Self
pub const fn new(analysis: [Feature; 20]) -> Self
Create a new Analysis object.
Usually not needed, unless you have already computed and stored features somewhere, and need to recreate a Song with an already existing Analysis yourself.
Sourcepub fn from_vec(features: Vec<Feature>) -> Result<Self, AnalysisError>
pub fn from_vec(features: Vec<Feature>) -> Result<Self, AnalysisError>
Creates a new Analysis object from a Vec<Feature>.
invariant: features.len() == NUMBER_FEATURES
§Errors
This function will return an error if the length of the features is not equal to NUMBER_FEATURES.
Sourcepub const fn inner(&self) -> &[Feature; 20]
pub const fn inner(&self) -> &[Feature; 20]
Return the inner array of the analysis. This is mostly useful if you want to store the features somewhere.
Sourcepub fn as_vec(&self) -> Vec<Feature> ⓘ
pub fn as_vec(&self) -> Vec<Feature> ⓘ
Return a Vec<f32> representing the analysis’ features.
Particularly useful if you want iterate through the values to store them somewhere.
Sourcepub fn from_samples(audio: &ResampledAudio) -> AnalysisResult<Self>
pub fn from_samples(audio: &ResampledAudio) -> AnalysisResult<Self>
Create an Analysis object from a ResampledAudio.
This is the main function you should use to create an Analysis object.
It will compute all the features from the audio samples.
You can get a ResampledAudio object by using a Decoder to decode an audio file.
§Errors
This function will return an error if the samples are empty or too short. Or if there is an error during the analysis.
§Panics
This function will panic it cannot join the threads.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Analysis
impl<'de> Deserialize<'de> for Analysis
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Index<AnalysisIndex> for Analysis
impl Index<AnalysisIndex> for Analysis
Source§impl TryInto<Analysis> for ResampledAudio
impl TryInto<Analysis> for ResampledAudio
impl Copy for Analysis
impl StructuralPartialEq for Analysis
Auto Trait Implementations§
impl Freeze for Analysis
impl RefUnwindSafe for Analysis
impl Send for Analysis
impl Sync for Analysis
impl Unpin for Analysis
impl UnwindSafe for Analysis
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.