Crate bliss_audio
source · [−]Expand description
bliss audio library
bliss is a library for making “smart” audio playlists.
The core of the library is the Song object, which relates to a
specific analyzed song and contains its path, title, analysis, and
other metadata fields (album, genre…).
Analyzing a song is as simple as running Song::from_path("/path/to/song")
.
The analysis field of each song is an array of f32, which makes the comparison between songs easy, by just using e.g. euclidean distance (see distance for instance).
Once several songs have been analyzed, making a playlist from one Song is as easy as computing distances between that song and the rest, and ordering the songs by distance, ascending.
Examples
Analyze & compute the distance between two songs
use bliss_audio::{BlissResult, Song};
fn main() -> BlissResult<()> {
let song1 = Song::from_path("/path/to/song1")?;
let song2 = Song::from_path("/path/to/song2")?;
println!("Distance between song1 and song2 is {}", song1.distance(&song2));
Ok(())
}
Make a playlist from a song, discarding failed songs
use bliss_audio::{analyze_paths, BlissResult, Song};
use noisy_float::prelude::n32;
fn main() -> BlissResult<()> {
let paths = vec!["/path/to/song1", "/path/to/song2", "/path/to/song3"];
let mut songs: Vec<Song> = analyze_paths(&paths)
.filter_map(|(_, s)| s.ok())
.collect();
// Assuming there is a first song
let first_song = songs.first().unwrap().to_owned();
songs.sort_by_cached_key(|song| n32(first_song.distance(&song)));
println!(
"Playlist is: {:?}",
songs
.iter()
.map(|song| song.path.to_string_lossy().to_string())
.collect::<Vec<String>>()
);
Ok(())
}
Modules
CUE-handling module.
Module containing various functions to build playlists, as well as various distance metrics.
Structs
Object holding the results of the song’s analysis.
Simple object used to represent a Song, with its path, analysis, and other metadata (artist, genre…)
Enums
Indexes different fields of an Analysis.
Umbrella type for bliss error types
Constants
Stores the current version of bliss-rs’ features. It is bumped every time one or more feature is added, updated or removed, so plug-ins can rescan libraries when there is a major change.
The number of features used in Analysis
Functions
Analyze songs in paths
, and return the analyzed Song objects through an
mpsc::IntoIter.
Type Definitions
bliss error type