2021-05-17 21:23:29 +01:00
|
|
|
use bliss_audio::Song;
|
2021-05-14 15:35:08 +01:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple utility to print distance between two songs according to bliss.
|
|
|
|
*
|
2022-04-01 23:05:57 +01:00
|
|
|
* Takes two file paths, and analyze the corresponding songs, printing
|
2021-05-14 15:35:08 +01:00
|
|
|
* the distance between the two files according to bliss.
|
|
|
|
*/
|
|
|
|
fn main() -> Result<(), String> {
|
|
|
|
let mut paths = env::args().skip(1).take(2);
|
|
|
|
|
|
|
|
let first_path = paths.next().ok_or("Help: ./distance <song1> <song2>")?;
|
|
|
|
let second_path = paths.next().ok_or("Help: ./distance <song1> <song2>")?;
|
|
|
|
|
2022-04-02 18:47:06 +01:00
|
|
|
let song1 = Song::from_path(&first_path).map_err(|x| x.to_string())?;
|
|
|
|
let song2 = Song::from_path(&second_path).map_err(|x| x.to_string())?;
|
2021-05-14 15:35:08 +01:00
|
|
|
|
|
|
|
println!(
|
2021-06-13 13:07:17 +01:00
|
|
|
"d({:?}, {:?}) = {}",
|
2021-05-14 15:35:08 +01:00
|
|
|
song1.path,
|
|
|
|
song2.path,
|
|
|
|
song1.distance(&song2)
|
|
|
|
);
|
|
|
|
Ok(())
|
|
|
|
}
|