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 Decoder::song_from_path(“/path/to/song”).
The analysis field of each song is an array of f32, which makes the comparison between songs easy, either by simply calling Song::distance directly, or by using other distances on the analysis, e.g. playlist::euclidean_distance.
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.
If you want to implement a bliss plugin for an already existing audio player, the crate::library::Library struct is a collection of goodies that should prove useful (it contains utilities to store analyzed songs in a self-contained database file, to make playlists directly from the database, etc). blissify for both an example of how the library::Library struct works, and a real-life demo of bliss implemented for MPD.
§Examples
§Analyze & compute the distance between two songs
use bliss_audio::decoder::Decoder as DecoderTrait;
use bliss_audio::decoder::ffmpeg::FFmpegDecoder as Decoder;
use bliss_audio::playlist::euclidean_distance;
use bliss_audio::BlissResult;
fn main() -> BlissResult<()> {
let song1 = Decoder::song_from_path("/path/to/song1")?;
let song2 = Decoder::song_from_path("/path/to/song2")?;
println!(
"Distance between song1 and song2 is {}",
euclidean_distance(&song1.analysis.as_arr1(), &song2.analysis.as_arr1())
);
Ok(())
}§Make a playlist from a song, discarding failed songs
use bliss_audio::decoder::Decoder as DecoderTrait;
use bliss_audio::decoder::ffmpeg::FFmpegDecoder as Decoder;
use bliss_audio::{
playlist::{closest_to_songs, euclidean_distance},
BlissResult, Song,
};
fn main() -> BlissResult<()> {
let paths = vec!["/path/to/song1", "/path/to/song2", "/path/to/song3"];
let mut songs: Vec<Song> = Decoder::analyze_paths(&paths).filter_map(|(_, s)| s.ok()).collect();
// Assuming there is a first song
let first_song = songs.first().unwrap().to_owned();
closest_to_songs(&[first_song], &mut songs, &euclidean_distance);
println!("Playlist is:");
for song in songs {
println!("{}", song.path.display());
}
Ok(())
}Modules§
- cue
- CUE-handling module.
- decoder
- Module holding all the nitty-gritty decoding details.
- library
- Module containing utilities to properly manage a library of Songs, for people wanting to e.g. implement a bliss plugin for an existing audio player. A good resource to look at for inspiration is blissify’s source code.
- playlist
- Module containing various functions to build playlists, as well as various distance metrics.
Structs§
- Analysis
- Object holding the results of the song’s analysis.
- Analysis
Options - Various options bliss should be aware of while performing the analysis of a song.
- Song
- Simple object used to represent a Song, with its path, analysis, and other metadata (artist, genre…)
Enums§
- Analysis
Index - Indexes different fields of an Analysis.
- Bliss
Error - Umbrella type for bliss error types
- Features
Version - The versions of the features used for analysis. Used for backwards-compatibility reasons in case people want to keep using older features version.
Constants§
- NUMBER_
FEATURES - The number of features used in the latest
Analysisversion.
Type Aliases§
- Bliss
Result - bliss error type