Skip to content

Commit 7b91606

Browse files
committed
chore: fmt
1 parent cb665bf commit 7b91606

1 file changed

Lines changed: 7 additions & 25 deletions

File tree

prpr-auto-offset/src/audio/superflux.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ use crate::Signal;
66
/// from:
77
/// "Maximum Filter Vibrato Suppression for Onset Detection"
88
/// Sebastian Böck and Gerhard Widmer, DAFx-13, Maynooth, Ireland, September 2013.
9-
///
9+
///
1010
/// Paper: https://www.dafx.de/paper-archive/2013/papers/09.dafx2013_submission_12.pdf
11-
///
11+
///
1212
/// Reference Python implementation: https://github.com/CPJKU/SuperFlux/blob/master/SuperFlux.py
13-
///
13+
///
1414
/// Processing steps:
1515
/// 1. High-pass filter (50 Hz) to remove sub-bass rumble
1616
/// 2. Log-scale triangular filterbank (24 bands/octave, 30 Hz – 17 kHz)
@@ -162,24 +162,14 @@ impl Filterbank {
162162
/// * `fmin` - Minimum frequency in Hz (default: 30).
163163
/// * `fmax` - Maximum frequency in Hz (default: 17000, capped at Nyquist).
164164
/// * `equal` - If true, normalize each triangular filter to have area 1.
165-
pub fn new(
166-
sample_rate: u32,
167-
window_size: usize,
168-
bands_per_octave: usize,
169-
fmin: f32,
170-
fmax: f32,
171-
equal: bool,
172-
) -> Self {
165+
pub fn new(sample_rate: u32, window_size: usize, bands_per_octave: usize, fmin: f32, fmax: f32, equal: bool) -> Self {
173166
let n_fft_bins = window_size / 2;
174167
let fmax = fmax.min(sample_rate as f32 / 2.0);
175168

176169
// Generate log-spaced frequencies and map to FFT bins
177170
let frequencies = log_frequencies(bands_per_octave, fmin, fmax);
178171
let factor = (sample_rate as f32 / 2.0) / n_fft_bins as f32;
179-
let mut bins: Vec<usize> = frequencies
180-
.iter()
181-
.map(|&f| (f / factor).round() as usize)
182-
.collect();
172+
let mut bins: Vec<usize> = frequencies.iter().map(|&f| (f / factor).round() as usize).collect();
183173
bins.sort();
184174
bins.dedup();
185175
bins.retain(|&b| b < n_fft_bins);
@@ -194,11 +184,7 @@ impl Filterbank {
194184
let mid = bins[band + 1];
195185
let stop = bins[band + 2];
196186

197-
let height = if equal {
198-
2.0 / (stop - start) as f32
199-
} else {
200-
1.0
201-
};
187+
let height = if equal { 2.0 / (stop - start) as f32 } else { 1.0 };
202188

203189
// Rising edge: start..mid
204190
let n_rise = mid - start;
@@ -270,11 +256,7 @@ pub fn compute_spectrogram(
270256
.into_par_iter()
271257
.map(|frame_idx| {
272258
let start = frame_idx * hop_size;
273-
let mut windowed: Vec<f32> = samples[start..start + window_size]
274-
.iter()
275-
.zip(&window)
276-
.map(|(&s, &w)| s * w)
277-
.collect();
259+
let mut windowed: Vec<f32> = samples[start..start + window_size].iter().zip(&window).map(|(&s, &w)| s * w).collect();
278260

279261
let mut spectrum = r2c.make_output_vec();
280262
r2c.process(&mut windowed, &mut spectrum).unwrap();

0 commit comments

Comments
 (0)