From dce2bb42955772908ba8b47d96938133f6c51fa2 Mon Sep 17 00:00:00 2001 From: Polochon-street Date: Sat, 5 Jun 2021 23:56:01 +0200 Subject: [PATCH] =?UTF-8?q?Make=20`Analysis::new`=C2=A0public?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +++++ Cargo.toml | 2 +- src/song.rs | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7357a83..81de34d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## bliss 0.2.1 +* Made `Analysis::new` public. +* Made `Analysis` serializable. + +## bliss 0.2.0 + * Added an `Analysis` struct to `Song`, as well as an `AnalysisIndex` to index it easily. * Changed some logging parameters for the Library trait. diff --git a/Cargo.toml b/Cargo.toml index 62868de..95de739 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bliss-audio" -version = "0.2.0" +version = "0.2.1" authors = ["Polochon-street "] edition = "2018" license = "GPL-3.0-only" diff --git a/src/song.rs b/src/song.rs index b51abd5..d537562 100644 --- a/src/song.rs +++ b/src/song.rs @@ -104,6 +104,7 @@ pub enum AnalysisIndex { } const NUMBER_FEATURES: usize = AnalysisIndex::COUNT; +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Default, PartialEq, Clone, Copy)] /// Object holding the results of the song's analysis. /// @@ -143,7 +144,12 @@ impl fmt::Debug for Analysis { } impl Analysis { - pub(crate) fn new(analysis: [f32; NUMBER_FEATURES]) -> Analysis { + /// Create a new Analysis object. + /// + /// Usually not needed, unless you have already computed and stored + /// features somewhere, and need to recreate a Song with an already + /// existing Analysis yourself. + pub fn new(analysis: [f32; NUMBER_FEATURES]) -> Analysis { Analysis { internal_analysis: analysis, }