Replace occurences of analyse by analyze

This commit is contained in:
Polochon-street 2022-04-02 00:05:57 +02:00
parent 5f366b0d80
commit 5930d2bc93
9 changed files with 62 additions and 59 deletions

View File

@ -1,5 +1,9 @@
#Changelog #Changelog
## bliss 0.5.0
* Remove all traces of the "analyse" word vs "analyze" to make the codebase
more coherent.
## bliss 0.4.6 ## bliss 0.4.6
* Bump ffmpeg crate version to allow for cross-compilation. * Bump ffmpeg crate version to allow for cross-compilation.

80
Cargo.lock generated
View File

@ -37,9 +37,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.53" version = "1.0.56"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27"
[[package]] [[package]]
name = "atty" name = "atty"
@ -72,7 +72,7 @@ dependencies = [
"peeking_take_while", "peeking_take_while",
"proc-macro2", "proc-macro2",
"quote", "quote",
"regex 1.5.4", "regex 1.5.5",
"rustc-hash", "rustc-hash",
"shlex", "shlex",
] ]
@ -85,7 +85,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bliss-audio" name = "bliss-audio"
version = "0.4.5" version = "0.5.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bliss-audio-aubio-rs", "bliss-audio-aubio-rs",
@ -196,9 +196,9 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.72" version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
dependencies = [ dependencies = [
"jobserver", "jobserver",
] ]
@ -279,9 +279,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-channel" name = "crossbeam-channel"
version = "0.5.2" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
@ -300,10 +300,11 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-epoch" name = "crossbeam-epoch"
version = "0.9.7" version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c"
dependencies = [ dependencies = [
"autocfg",
"cfg-if", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
"lazy_static 1.4.0", "lazy_static 1.4.0",
@ -313,9 +314,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-queue" name = "crossbeam-queue"
version = "0.3.4" version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dd435b205a4842da59efd07628f921c096bc1cc0a156835b4fa0bcb9a19bcce" checksum = "1f25d8400f4a7a5778f0e4e52384a48cbd9b5c495d110786187fc750075277a2"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
@ -323,9 +324,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.7" version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"lazy_static 1.4.0", "lazy_static 1.4.0",
@ -364,7 +365,7 @@ dependencies = [
"atty", "atty",
"humantime", "humantime",
"log", "log",
"regex 1.5.4", "regex 1.5.5",
"termcolor", "termcolor",
] ]
@ -376,9 +377,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]] [[package]]
name = "ffmpeg-next" name = "ffmpeg-next"
version = "5.0.2" version = "5.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70a1fc87054b079ade0b081b023c5fef309cd4bbcb569c09eed2aa39b25a0a11" checksum = "585e5eaf57eceaa199ba6f6a1f46bdad7992930bb7b45b40275d9445b5ba2bc8"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"ffmpeg-sys-next", "ffmpeg-sys-next",
@ -473,9 +474,9 @@ dependencies = [
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.4" version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@ -520,9 +521,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.8.0" version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" checksum = "0f647032dfaa1f8b6dc29bd3edb7bbef4861b8b8007ebb118d6db284fd59f6ee"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown",
@ -582,9 +583,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.118" version = "0.2.121"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94" checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
[[package]] [[package]]
name = "libloading" name = "libloading"
@ -598,9 +599,9 @@ dependencies = [
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.14" version = "0.4.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
@ -652,9 +653,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]] [[package]]
name = "mime_guess" name = "mime_guess"
version = "2.0.3" version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
dependencies = [ dependencies = [
"mime", "mime",
"unicase", "unicase",
@ -730,13 +731,12 @@ dependencies = [
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.0" version = "7.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
dependencies = [ dependencies = [
"memchr 2.4.1", "memchr 2.4.1",
"minimal-lexical", "minimal-lexical",
"version_check",
] ]
[[package]] [[package]]
@ -882,9 +882,9 @@ dependencies = [
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.24" version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
@ -925,9 +925,9 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.15" version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" checksum = "632d02bff7f874a36f33ea8bb416cd484b90cc66c1194b1a1110d067a7013f58"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -1008,9 +1008,9 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.5.4" version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [ dependencies = [
"aho-corasick 0.7.18", "aho-corasick 0.7.18",
"memchr 2.4.1", "memchr 2.4.1",
@ -1153,9 +1153,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.86" version = "1.0.90"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" checksum = "704df27628939572cd88d33f171cd6f896f4eaca85252c6e0a72d8d8287ee86f"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1164,9 +1164,9 @@ dependencies = [
[[package]] [[package]]
name = "termcolor" name = "termcolor"
version = "1.1.2" version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
dependencies = [ dependencies = [
"winapi-util", "winapi-util",
] ]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "bliss-audio" name = "bliss-audio"
version = "0.4.6" version = "0.5.0"
authors = ["Polochon-street <polochonstreet@gmx.fr>"] authors = ["Polochon-street <polochonstreet@gmx.fr>"]
edition = "2018" edition = "2018"
license = "GPL-3.0-only" license = "GPL-3.0-only"

View File

@ -2,7 +2,7 @@
[![build](https://github.com/Polochon-street/bliss-rs/workflows/Rust/badge.svg)](https://github.com/Polochon-street/bliss-rs/actions) [![build](https://github.com/Polochon-street/bliss-rs/workflows/Rust/badge.svg)](https://github.com/Polochon-street/bliss-rs/actions)
[![doc](https://docs.rs/bliss-audio/badge.svg)](https://docs.rs/bliss-audio/) [![doc](https://docs.rs/bliss-audio/badge.svg)](https://docs.rs/bliss-audio/)
# bliss music analyser - Rust version # bliss music analyzer - Rust version
bliss-rs is the Rust improvement of [bliss](https://github.com/Polochon-street/bliss), a bliss-rs is the Rust improvement of [bliss](https://github.com/Polochon-street/bliss), a
library used to make playlists by analyzing songs, and computing distance between them. library used to make playlists by analyzing songs, and computing distance between them.
@ -24,7 +24,7 @@ different, more accurate values, based on
## Examples ## Examples
For simple analysis / distance computing, take a look at `examples/distance.rs` and For simple analysis / distance computing, take a look at `examples/distance.rs` and
`examples/analyse.rs`. `examples/analyze.rs`.
If you simply want to try out making playlists from a folder containing songs, If you simply want to try out making playlists from a folder containing songs,
[this example](https://github.com/Polochon-street/bliss-rs/blob/master/examples/playlist.rs) [this example](https://github.com/Polochon-street/bliss-rs/blob/master/examples/playlist.rs)

View File

@ -4,7 +4,7 @@ use std::env;
/** /**
* Simple utility to print the result of an Analysis. * Simple utility to print the result of an Analysis.
* *
* Takes a list of files to analyse an the result of the corresponding Analysis. * Takes a list of files to analyze an the result of the corresponding Analysis.
*/ */
fn main() { fn main() {
let args: Vec<String> = env::args().skip(1).collect(); let args: Vec<String> = env::args().skip(1).collect();

View File

@ -4,7 +4,7 @@ use std::env;
/** /**
* Simple utility to print distance between two songs according to bliss. * Simple utility to print distance between two songs according to bliss.
* *
* Takes two file paths, and analyse the corresponding songs, printing * Takes two file paths, and analyze the corresponding songs, printing
* the distance between the two files according to bliss. * the distance between the two files according to bliss.
*/ */
fn main() -> Result<(), String> { fn main() -> Result<(), String> {

View File

@ -114,7 +114,7 @@ pub type BlissResult<T> = Result<T, BlissError>;
/// When making an extension for an audio player, prefer /// When making an extension for an audio player, prefer
/// implementing the `Library` trait. /// implementing the `Library` trait.
#[doc(hidden)] #[doc(hidden)]
pub fn bulk_analyse(paths: Vec<String>) -> Vec<BlissResult<Song>> { pub fn bulk_analyze(paths: Vec<String>) -> Vec<BlissResult<Song>> {
let mut songs = Vec::with_capacity(paths.len()); let mut songs = Vec::with_capacity(paths.len());
let num_cpus = num_cpus::get(); let num_cpus = num_cpus::get();
@ -161,8 +161,8 @@ mod tests {
} }
#[test] #[test]
fn test_bulk_analyse() { fn test_bulk_analyze() {
let results = bulk_analyse(vec![ let results = bulk_analyze(vec![
String::from("data/s16_mono_22_5kHz.flac"), String::from("data/s16_mono_22_5kHz.flac"),
String::from("data/s16_mono_22_5kHz.flac"), String::from("data/s16_mono_22_5kHz.flac"),
String::from("nonexistent"), String::from("nonexistent"),
@ -181,7 +181,7 @@ mod tests {
.collect(); .collect();
errored_songs.sort_by(|a, b| a.cmp(b)); errored_songs.sort_by(|a, b| a.cmp(b));
let mut analysed_songs: Vec<String> = results let mut analyzed_songs: Vec<String> = results
.iter() .iter()
.filter_map(|x| { .filter_map(|x| {
x.as_ref() x.as_ref()
@ -189,7 +189,7 @@ mod tests {
.map(|x| x.path.to_str().unwrap().to_string()) .map(|x| x.path.to_str().unwrap().to_string())
}) })
.collect(); .collect();
analysed_songs.sort_by(|a, b| a.cmp(b)); analyzed_songs.sort_by(|a, b| a.cmp(b));
assert_eq!( assert_eq!(
vec![ vec![
@ -206,7 +206,7 @@ mod tests {
String::from("data/s16_mono_22_5kHz.flac"), String::from("data/s16_mono_22_5kHz.flac"),
String::from("data/s16_stereo_22_5kHz.flac"), String::from("data/s16_stereo_22_5kHz.flac"),
], ],
analysed_songs, analyzed_songs,
); );
} }
} }

View File

@ -254,13 +254,13 @@ impl Song {
album: raw_song.album, album: raw_song.album,
track_number: raw_song.track_number, track_number: raw_song.track_number,
genre: raw_song.genre, genre: raw_song.genre,
analysis: Song::analyse(raw_song.sample_array)?, analysis: Song::analyze(raw_song.sample_array)?,
features_version: FEATURES_VERSION, features_version: FEATURES_VERSION,
}) })
} }
/** /**
* Analyse a song decoded in `sample_array`, with one channel @ 22050 Hz. * Analyze a song decoded in `sample_array`, with one channel @ 22050 Hz.
* *
* The current implementation doesn't make use of it, * The current implementation doesn't make use of it,
* but the song can also be streamed wrt. * but the song can also be streamed wrt.
@ -270,7 +270,7 @@ impl Song {
* Useful in the rare cases where the full song is not * Useful in the rare cases where the full song is not
* completely available. * completely available.
**/ **/
fn analyse(sample_array: Vec<f32>) -> BlissResult<Analysis> { fn analyze(sample_array: Vec<f32>) -> BlissResult<Analysis> {
let largest_window = vec![ let largest_window = vec![
BPMDesc::WINDOW_SIZE, BPMDesc::WINDOW_SIZE,
ChromaDesc::WINDOW_SIZE, ChromaDesc::WINDOW_SIZE,
@ -625,13 +625,13 @@ mod tests {
#[test] #[test]
fn test_analysis_too_small() { fn test_analysis_too_small() {
let error = Song::analyse(vec![0.]).unwrap_err(); let error = Song::analyze(vec![0.]).unwrap_err();
assert_eq!( assert_eq!(
error, error,
BlissError::AnalysisError(String::from("empty or too short song.")) BlissError::AnalysisError(String::from("empty or too short song."))
); );
let error = Song::analyse(vec![]).unwrap_err(); let error = Song::analyze(vec![]).unwrap_err();
assert_eq!( assert_eq!(
error, error,
BlissError::AnalysisError(String::from("empty or too short song.")) BlissError::AnalysisError(String::from("empty or too short song."))
@ -639,7 +639,7 @@ mod tests {
} }
#[test] #[test]
fn test_analyse() { fn test_analyze() {
let song = Song::new(Path::new("data/s16_mono_22_5kHz.flac")).unwrap(); let song = Song::new(Path::new("data/s16_mono_22_5kHz.flac")).unwrap();
let expected_analysis = vec![ let expected_analysis = vec![
0.3846389, 0.3846389,

View File

@ -101,8 +101,7 @@ pub(crate) fn geometric_mean(input: &[f32]) -> f32 {
let mut exponents: i32 = 0; let mut exponents: i32 = 0;
let mut mantissas: f64 = 1.; let mut mantissas: f64 = 1.;
for ch in input.chunks_exact(8) { for ch in input.chunks_exact(8) {
let mut m; let mut m = (ch[0] as f64 * ch[1] as f64) * (ch[2] as f64 * ch[3] as f64);
m = (ch[0] as f64 * ch[1] as f64) * (ch[2] as f64 * ch[3] as f64);
m *= 3.273390607896142e150; // 2^500 : avoid underflows and denormals m *= 3.273390607896142e150; // 2^500 : avoid underflows and denormals
m *= (ch[4] as f64 * ch[5] as f64) * (ch[6] as f64 * ch[7] as f64); m *= (ch[4] as f64 * ch[5] as f64) * (ch[6] as f64 * ch[7] as f64);
if m == 0. { if m == 0. {