Feat: rescale spectrum
This commit is contained in:
@@ -118,10 +118,10 @@ impl SpectrumAnalyzer {
|
||||
0.5 * (1.0 - (2.0 * std::f32::consts::PI * i as f32 / (FFT_SIZE - 1) as f32).cos())
|
||||
});
|
||||
|
||||
let nyquist = sample_rate / 2.0;
|
||||
let min_freq: f32 = 20.0;
|
||||
let max_freq: f32 = 16000.0;
|
||||
let log_min = min_freq.ln();
|
||||
let log_max = nyquist.ln();
|
||||
let log_max = max_freq.ln();
|
||||
let band_edges: [usize; NUM_BANDS + 1] = std::array::from_fn(|i| {
|
||||
let freq = (log_min + (log_max - log_min) * i as f32 / NUM_BANDS as f32).exp();
|
||||
let bin = (freq * FFT_SIZE as f32 / sample_rate).round() as usize;
|
||||
|
||||
Reference in New Issue
Block a user