Skip to main content

Song

Struct Song 

Source
pub struct Song {
    pub path: PathBuf,
    pub artist: Option<String>,
    pub title: Option<String>,
    pub album: Option<String>,
    pub album_artist: Option<String>,
    pub track_number: Option<i32>,
    pub disc_number: Option<i32>,
    pub genre: Option<String>,
    pub analysis: Analysis,
    pub duration: Duration,
    pub features_version: FeaturesVersion,
    pub cue_info: Option<CueInfo>,
}
Expand description

Simple object used to represent a Song, with its path, analysis, and other metadata (artist, genre…)

Fields§

§path: PathBuf

Song’s provided file path

§artist: Option<String>

Song’s artist, read from the metadata

§title: Option<String>

Song’s title, read from the metadata

§album: Option<String>

Song’s album name, read from the metadata

§album_artist: Option<String>

Song’s album’s artist name, read from the metadata

§track_number: Option<i32>

Song’s tracked number, read from the metadata

§disc_number: Option<i32>

Song’s disc number, read from the metadata

§genre: Option<String>

Song’s genre, read from the metadata

§analysis: Analysis

bliss analysis results

§duration: Duration

The song’s duration

§features_version: FeaturesVersion

Version of the features the song was analyzed with. A simple integer that is bumped every time a breaking change is introduced in the features.

§cue_info: Option<CueInfo>

Populated only if the song was extracted from a larger audio file, through the use of a CUE sheet. By default, such a song’s path would be path/to/cue_file.wav/CUE_TRACK00<track_number>. Using this field, you can change song.path to fit your needs.

Implementations§

Source§

impl Song

Source

pub fn analyze(sample_array: &[f32]) -> BlissResult<Analysis>

Analyze a song decoded in sample_array. This function should NOT be used manually, unless you want to explore analyzing a sample array you already decoded yourself. Most people will want to use Decoder::song_from_path instead to just analyze a file from its path.

The current implementation doesn’t make use of it, but the song can also be streamed wrt. each descriptor (with the exception of the chroma descriptor which yields worse results when streamed).

Useful in the rare cases where the full song is not completely available.

If you do want to use this with a song already decoded by yourself, the sample format of sample_array should be f32le, one channel, and the sampling rate 22050 Hz. Anything other than that will yield wrong results. To double-check that your sample array has the right format, you could run ffmpeg -i path_to_your_song.flac -ar 22050 -ac 1 -c:a pcm_f32le -f hash -hash addler32 -, which will give you the addler32 checksum of the sample array if the song has been decoded properly. You can then compute the addler32 checksum of your sample array (see _test_decode in the tests) and make sure both are the same.

(Running ffmpeg -i path_to_your_song.flac -ar 22050 -ac 1 -c:a pcm_f32le will simply give you the raw sample array as it should look like, if you’re not into computing checksums)

Source

pub fn analyze_with_options( sample_array: &[f32], analysis_options: &AnalysisOptions, ) -> BlissResult<Analysis>

This function is the same as Song::analyze, but allows to compute an analysis using old features_version. Do not use, unless for backwards compatibility.

Source

pub fn distance(&self, other: &Song) -> f32

Return the distance between the song and another song, using the default distance for the FeaturesVersion.

Will underperform if used over a large number of songs: for bulk playlist generation, use distance_metric with a bulk-playlist generation function in the playlist module, such as closest_to_songs.

Panics if the songs’ features have mismatched versions.

Trait Implementations§

Source§

impl<T: Serialize + DeserializeOwned + Clone> AsRef<Song> for LibrarySong<T>

Source§

fn as_ref(&self) -> &Song

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Song> for Song

Source§

fn as_ref(&self) -> &Song

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Song

Source§

fn clone(&self) -> Song

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Song

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Song

Source§

fn default() -> Song

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Song

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Song

Source§

fn eq(&self, other: &Song) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Song

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Song

Source§

impl TryFrom<PreAnalyzedSong> for Song

Source§

type Error = BlissError

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

fn try_from(raw_song: PreAnalyzedSong) -> BlissResult<Song>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Song

§

impl RefUnwindSafe for Song

§

impl Send for Song

§

impl Sync for Song

§

impl Unpin for Song

§

impl UnsafeUnpin for Song

§

impl UnwindSafe for Song

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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