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: PathBufSong’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: Analysisbliss analysis results
duration: DurationThe song’s duration
features_version: FeaturesVersionVersion 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
impl Song
Sourcepub fn analyze(sample_array: &[f32]) -> BlissResult<Analysis>
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)
Sourcepub fn analyze_with_options(
sample_array: &[f32],
analysis_options: &AnalysisOptions,
) -> BlissResult<Analysis>
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.
Sourcepub fn distance(&self, other: &Song) -> f32
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>
impl<T: Serialize + DeserializeOwned + Clone> AsRef<Song> for LibrarySong<T>
Source§impl<'de> Deserialize<'de> for Song
impl<'de> Deserialize<'de> for Song
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>,
impl StructuralPartialEq for Song
Source§impl TryFrom<PreAnalyzedSong> for Song
impl TryFrom<PreAnalyzedSong> for Song
Source§type Error = BlissError
type Error = BlissError
Source§fn try_from(raw_song: PreAnalyzedSong) -> BlissResult<Song>
fn try_from(raw_song: PreAnalyzedSong) -> BlissResult<Song>
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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