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.
If you want to implement a bliss plugin for an already existing audio player, the 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::FFmpeg 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::FFmpeg 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-handling module.
- Module holding all the nitty-gritty decoding details.
- 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
Type Aliases§
- bliss error type