From 1a6d0bafdab0b7808d7d1195ba16291ea19b420e Mon Sep 17 00:00:00 2001 From: Polochon-street Date: Tue, 8 Jun 2021 21:40:46 +0200 Subject: [PATCH] Change some docs --- README.md | 32 ++++++++++---------------------- src/lib.rs | 1 - src/temporal.rs | 2 +- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 8a7b33d..585873e 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,6 @@ used by C-bliss, since it uses different, more accurate values, based on [actual literature](https://lelele.io/thesis.pdf). It is also faster. -Note 2: The `bliss-rs` crate is outdated. You should use `bliss-audio` -(this crate) instead. - ## Examples For simple analysis / distance computing, a look at `examples/distance.rs` and `examples/analyse.rs`. @@ -32,20 +29,20 @@ Ready to use examples: ### Compute the distance between two songs ``` -use bliss_audio::Song; +use bliss_audio::{BlissError, Song}; -fn main() { - let song1 = Song::new("/path/to/song1"); - let song2 = Song::new("/path/to/song2"); - - println!("Distance between song1 and song2 is {}", song1.distance(song2)); +fn main() -> Result<(), BlissError> { + let song1 = Song::new("/path/to/song1")?; + let song2 = Song::new("/path/to/song2")?; + + println!("Distance between song1 and song2 is {}", song1.distance(&song2)); + Ok(()) } ``` ### Make a playlist from a song ``` -use bliss_rs::{BlissError, Song}; -use ndarray::{arr1, Array}; +use bliss_audio::{BlissError, Song}; use noisy_float::prelude::n32; fn main() -> Result<(), BlissError> { @@ -56,18 +53,9 @@ fn main() -> Result<(), BlissError> { .collect::, BlissError>>()?; // Assuming there is a first song - let analysis_first_song = arr1(&songs[0].analysis); + let first_song = songs.first().unwrap().to_owned(); - // Identity matrix used to compute the distance. - // Note that it can be changed to alter feature ponderation, which - // may yield to better playlists (subjectively). - let m = Array::eye(analysis_first_song.len()); - - songs.sort_by_cached_key(|song| { - n32((arr1(&song.analysis) - &analysis_first_song) - .dot(&m) - .dot(&(arr1(&song.analysis) - &analysis_first_song))) - }); + songs.sort_by_cached_key(|song| n32(first_song.distance(&song))); println!( "Playlist is: {:?}", songs diff --git a/src/lib.rs b/src/lib.rs index 3b69b6b..d415017 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,7 +38,6 @@ //! ### Make a playlist from a song //! ```no_run //! use bliss_audio::{BlissError, Song}; -//! use ndarray::{arr1, Array}; //! use noisy_float::prelude::n32; //! //! fn main() -> Result<(), BlissError> { diff --git a/src/temporal.rs b/src/temporal.rs index 8aa41d7..74acad4 100644 --- a/src/temporal.rs +++ b/src/temporal.rs @@ -19,7 +19,7 @@ use noisy_float::prelude::*; * It indicates the (subjective) "speed" of a music piece. The higher the BPM, * the "quicker" the song will feel. * - * It uses `WPhase`, a phase-deviation onset detection function to perform + * It uses `SpecFlux`, a phase-deviation onset detection function to perform * onset detection; it proved to be the best for finding out the BPM of a panel * of songs I had, but it could very well be replaced by something better in the * future.