Function bliss_audio::analyze_paths

source ·
pub fn analyze_paths<P: Into<PathBuf>, F: IntoIterator<Item = P>>(
    paths: F
) -> IntoIter<(PathBuf, BlissResult<Song>)>
Expand description

Analyze songs in paths, and return the analyzed Song objects through an mpsc::IntoIter.

Returns an iterator, whose items are a tuple made of the song path (to display to the user in case the analysis failed), and a Result.

Note

This function also works with CUE files - it finds the audio files mentionned in the CUE sheet, and then runs the analysis on each song defined by it, returning a proper Song object for each one of them.

Make sure that you don’t submit both the audio file along with the CUE sheet if your library uses them, otherwise the audio file will be analyzed as one, single, long song. For instance, with a CUE sheet named cue-file.cue with the corresponding audio files album-1.wav and album-2.wav defined in the CUE sheet, you would just pass cue-file.cue to analyze_paths, and it will return Songs from both files, with more information about which file it is extracted from in the cue info field.

Example:

use bliss_audio::{analyze_paths, BlissResult};

fn main() -> BlissResult<()> {
    let paths = vec![String::from("/path/to/song1"), String::from("/path/to/song2")];
    for (path, result) in analyze_paths(&paths) {
        match result {
            Ok(song) => println!("Do something with analyzed song {} with title {:?}", song.path.display(), song.title),
            Err(e) => println!("Song at {} could not be analyzed. Failed with: {}", path.display(), e),
        }
    }
    Ok(())
}