Some fixes for the new CI

This commit is contained in:
Polochon-street 2022-02-17 22:43:28 +01:00
parent 80f4ed11aa
commit 51e8cf9344
5 changed files with 28 additions and 30 deletions

View file

@ -34,6 +34,10 @@ jobs:
run: cargo +nightly-2022-02-16 bench --verbose --features=bench --no-run run: cargo +nightly-2022-02-16 bench --verbose --features=bench --no-run
- name: Build examples - name: Build examples
run: cargo build --examples --verbose --features=serde run: cargo build --examples --verbose --features=serde
- name: Lint
run: cargo clippy --examples --features=serde -- -D warnings
- name: Check format
run: cargo fmt -- --check
build-test-lint-windows: build-test-lint-windows:
name: Windows - build, test and lint name: Windows - build, test and lint
@ -65,14 +69,10 @@ jobs:
override: true override: true
components: rustfmt, clippy components: rustfmt, clippy
- name: Build - name: Build
run: | run: cargo build --examples
cargo build --examples
- name: Test - name: Test
run: | run: cargo test --examples --features=serde
cargo test --examples
- name: Lint - name: Lint
run: | run: cargo clippy --examples --features=serde -- -D warnings
cargo clippy --examples -- -D warnings
- name: Check format - name: Check format
run: | run: cargo fmt -- --check
cargo fmt -- --check

View file

@ -1,13 +1,20 @@
#[cfg(feature = "serde")]
use anyhow::Result; use anyhow::Result;
#[cfg(feature = "serde")]
use bliss_audio::distance::{closest_to_first_song, dedup_playlist, euclidean_distance}; use bliss_audio::distance::{closest_to_first_song, dedup_playlist, euclidean_distance};
#[cfg(feature = "serde")]
use bliss_audio::{library::analyze_paths_streaming, Song}; use bliss_audio::{library::analyze_paths_streaming, Song};
#[cfg(feature = "serde")]
use clap::{App, Arg}; use clap::{App, Arg};
#[cfg(feature = "serde")]
use glob::glob; use glob::glob;
use mime_guess; #[cfg(feature = "serde")]
use serde_json;
use std::env; use std::env;
#[cfg(feature = "serde")]
use std::fs; use std::fs;
#[cfg(feature = "serde")]
use std::io::BufReader; use std::io::BufReader;
#[cfg(feature = "serde")]
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
/* Analyzes a folder recursively, and make a playlist out of the file /* Analyzes a folder recursively, and make a playlist out of the file

View file

@ -207,13 +207,13 @@ fn chroma_filter(
wts *= &freq_bins; wts *= &freq_bins;
// np.roll(), np bro // np.roll(), np bro
let mut uninit: Vec<f64> = Vec::with_capacity((&wts).len()); let mut uninit: Vec<f64> = vec![0.; (&wts).len()];
unsafe { unsafe {
uninit.set_len(wts.len()); uninit.set_len(wts.len());
} }
let mut b = Array::from(uninit) let mut b = Array::from(uninit)
.into_shape(wts.dim()) .into_shape(wts.dim())
.map_err(|e| BlissError::AnalysisError(format!("in chroma: {}", e.to_string())))?; .map_err(|e| BlissError::AnalysisError(format!("in chroma: {}", e)))?;
b.slice_mut(s![-3.., ..]).assign(&wts.slice(s![..3, ..])); b.slice_mut(s![-3.., ..]).assign(&wts.slice(s![..3, ..]));
b.slice_mut(s![..-3, ..]).assign(&wts.slice(s![3.., ..])); b.slice_mut(s![..-3, ..]).assign(&wts.slice(s![3.., ..]));
@ -308,7 +308,7 @@ fn pitch_tuning(
} }
let max_index = counts let max_index = counts
.argmax() .argmax()
.map_err(|e| BlissError::AnalysisError(format!("in chroma: {}", e.to_string())))?; .map_err(|e| BlissError::AnalysisError(format!("in chroma: {}", e)))?;
// Return the bin with the most reoccuring frequency. // Return the bin with the most reoccuring frequency.
Ok((-50. + (100. * resolution * max_index as f64)) / 100.) Ok((-50. + (100. * resolution * max_index as f64)) / 100.)
@ -332,7 +332,7 @@ fn estimate_tuning(
let threshold: N64 = Array::from(filtered_mag.to_vec()) let threshold: N64 = Array::from(filtered_mag.to_vec())
.quantile_axis_mut(Axis(0), n64(0.5), &Midpoint) .quantile_axis_mut(Axis(0), n64(0.5), &Midpoint)
.map_err(|e| BlissError::AnalysisError(format!("in chroma: {}", e.to_string())))? .map_err(|e| BlissError::AnalysisError(format!("in chroma: {}", e)))?
.into_scalar(); .into_scalar();
let mut pitch = filtered_pitch let mut pitch = filtered_pitch

View file

@ -48,10 +48,7 @@ impl BPMDesc {
sample_rate, sample_rate,
) )
.map_err(|e| { .map_err(|e| {
BlissError::AnalysisError(format!( BlissError::AnalysisError(format!("error while loading aubio tempo object: {}", e))
"error while loading aubio tempo object: {}",
e.to_string()
))
})?, })?,
bpms: Vec::new(), bpms: Vec::new(),
}) })
@ -59,10 +56,7 @@ impl BPMDesc {
pub fn do_(&mut self, chunk: &[f32]) -> BlissResult<()> { pub fn do_(&mut self, chunk: &[f32]) -> BlissResult<()> {
let result = self.aubio_obj.do_result(chunk).map_err(|e| { let result = self.aubio_obj.do_result(chunk).map_err(|e| {
BlissError::AnalysisError(format!( BlissError::AnalysisError(format!("aubio error while computing tempo {}", e))
"aubio error while computing tempo {}",
e.to_string()
))
})?; })?;
if result > 0. { if result > 0. {

View file

@ -126,21 +126,21 @@ impl SpectralDesc {
.map_err(|e| { .map_err(|e| {
BlissError::AnalysisError(format!( BlissError::AnalysisError(format!(
"error while loading aubio centroid object: {}", "error while loading aubio centroid object: {}",
e.to_string() e
)) ))
})?, })?,
rolloff_aubio_desc: SpecDesc::new(SpecShape::Rolloff, SpectralDesc::WINDOW_SIZE) rolloff_aubio_desc: SpecDesc::new(SpecShape::Rolloff, SpectralDesc::WINDOW_SIZE)
.map_err(|e| { .map_err(|e| {
BlissError::AnalysisError(format!( BlissError::AnalysisError(format!(
"error while loading aubio rolloff object: {}", "error while loading aubio rolloff object: {}",
e.to_string() e
)) ))
})?, })?,
phase_vocoder: PVoc::new(SpectralDesc::WINDOW_SIZE, SpectralDesc::HOP_SIZE).map_err( phase_vocoder: PVoc::new(SpectralDesc::WINDOW_SIZE, SpectralDesc::HOP_SIZE).map_err(
|e| { |e| {
BlissError::AnalysisError(format!( BlissError::AnalysisError(format!(
"error while loading aubio pvoc object: {}", "error while loading aubio pvoc object: {}",
e.to_string() e
)) ))
}, },
)?, )?,
@ -163,10 +163,7 @@ impl SpectralDesc {
self.phase_vocoder self.phase_vocoder
.do_(chunk, fftgrain.as_mut_slice()) .do_(chunk, fftgrain.as_mut_slice())
.map_err(|e| { .map_err(|e| {
BlissError::AnalysisError(format!( BlissError::AnalysisError(format!("error while processing aubio pv object: {}", e))
"error while processing aubio pv object: {}",
e.to_string()
))
})?; })?;
let bin = self let bin = self
@ -175,7 +172,7 @@ impl SpectralDesc {
.map_err(|e| { .map_err(|e| {
BlissError::AnalysisError(format!( BlissError::AnalysisError(format!(
"error while processing aubio centroid object: {}", "error while processing aubio centroid object: {}",
e.to_string() e
)) ))
})?; })?;