Crate bliss_audio[][src]

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::new("/path/to/song").

The analysis field of each song is an array of f32, which makes the comparison between songs easy, by just using 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.

It is also convenient to make plug-ins for existing audio players. It should be as easy as implementing the necessary traits for Library. A reference implementation for the MPD player is available here

Examples

Analyze & compute the distance between two songs

use bliss_audio::{BlissResult, Song};

fn main() -> BlissResult<()> {
    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_audio::{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> = paths
        .iter()
        .map(|path| Song::new(path))
        .collect::<BlissResult<Vec<Song>>>()?;

    // 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

distance

Module containing various distance metric functions.

Structs

Analysis

Object holding the results of the song’s analysis.

Song

Simple object used to represent a Song, with its path, analysis, and other metadata (artist, genre…)

Enums

AnalysisIndex

Indexes different fields of an Analysis.

BlissError

Umbrella type for bliss error types

Constants

NUMBER_FEATURES

The number of features used in Analysis

Traits

Library

Library trait to make creating plug-ins for existing audio players easier.

Type Definitions

BlissResult

bliss error type