Clean up unused members / includes
This commit is contained in:
parent
6028d5ca05
commit
2df27bec85
@ -1,11 +1,8 @@
|
|||||||
use num::complex::ComplexFloat;
|
use num::{Float, FromPrimitive, Num, ToPrimitive};
|
||||||
use num::traits::real::Real;
|
|
||||||
use num::traits::AsPrimitive;
|
|
||||||
use num::{Float, FromPrimitive, Num, Signed, ToPrimitive};
|
|
||||||
use realfft::{RealFftPlanner, RealToComplex};
|
use realfft::{RealFftPlanner, RealToComplex};
|
||||||
use ringbuf::{HeapRb, Rb};
|
use ringbuf::{HeapRb, Rb};
|
||||||
use rustfft::num_complex::Complex;
|
use rustfft::num_complex::Complex;
|
||||||
use rustfft::{Fft, FftNum};
|
use rustfft::FftNum;
|
||||||
|
|
||||||
use std::fmt::{Debug, Display};
|
use std::fmt::{Debug, Display};
|
||||||
use std::iter::repeat;
|
use std::iter::repeat;
|
||||||
@ -137,7 +134,7 @@ impl<T: Num + ToPrimitive, U: FftNum + Float + AddAssign, const NUM_CHANNELS: us
|
|||||||
self.cur_peaks[channel] = bin
|
self.cur_peaks[channel] = bin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn accum_td_sample(&mut self, sample: T, channel: usize) {}
|
fn accum_td_sample(&mut self, _sample: T, _channel: usize) {}
|
||||||
fn finalize(&mut self, channel: usize) {
|
fn finalize(&mut self, channel: usize) {
|
||||||
self.last_peaks[channel] = self.cur_peaks[channel]
|
self.last_peaks[channel] = self.cur_peaks[channel]
|
||||||
}
|
}
|
||||||
@ -212,10 +209,8 @@ pub struct FftAnalyzer<T, U: FftNum, const NUM_CHANNELS: usize> {
|
|||||||
fft_length: usize,
|
fft_length: usize,
|
||||||
sample_rate: U,
|
sample_rate: U,
|
||||||
channels: usize,
|
channels: usize,
|
||||||
norm_factor: U,
|
|
||||||
bin_freqs: Vec<U>,
|
bin_freqs: Vec<U>,
|
||||||
|
|
||||||
planner: RealFftPlanner<U>,
|
|
||||||
processor: Arc<dyn RealToComplex<U>>,
|
processor: Arc<dyn RealToComplex<U>>,
|
||||||
window: HanningWindow<U>,
|
window: HanningWindow<U>,
|
||||||
|
|
||||||
@ -240,13 +235,11 @@ impl<T: Num, U: FftNum, const NUM_CHANNELS: usize> FftAnalyzer<T, U, NUM_CHANNEL
|
|||||||
fft_length,
|
fft_length,
|
||||||
sample_rate,
|
sample_rate,
|
||||||
channels,
|
channels,
|
||||||
norm_factor: U::from_f64(1.0 / (fft_length as f64).sqrt()).unwrap(),
|
|
||||||
bin_freqs,
|
bin_freqs,
|
||||||
|
|
||||||
log_plot: true,
|
log_plot: true,
|
||||||
|
|
||||||
processor: planner.plan_fft_forward(fft_length),
|
processor: planner.plan_fft_forward(fft_length),
|
||||||
planner,
|
|
||||||
window: HanningWindow::new(fft_length),
|
window: HanningWindow::new(fft_length),
|
||||||
audio_buf: Arc::new(Mutex::new(AudioBuf::<T> {
|
audio_buf: Arc::new(Mutex::new(AudioBuf::<T> {
|
||||||
samples: repeat(0)
|
samples: repeat(0)
|
||||||
@ -335,9 +328,6 @@ impl<T: Num, U: FftNum, const NUM_CHANNELS: usize> FftAnalyzer<T, U, NUM_CHANNEL
|
|||||||
|
|
||||||
self.last_analysis = result;
|
self.last_analysis = result;
|
||||||
}
|
}
|
||||||
fn progress(&self) -> f32 {
|
|
||||||
self.audio_buf.lock().unwrap().read_since_last_update as f32 / self.fft_length as f32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<
|
||||||
|
@ -2,7 +2,7 @@ use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
|||||||
|
|
||||||
use egui::epaint::Hsva;
|
use egui::epaint::Hsva;
|
||||||
use egui::Widget;
|
use egui::Widget;
|
||||||
use egui_plot::{log_grid_spacer, GridInput, GridMark, Legend, Line, Plot};
|
use egui_plot::{GridInput, GridMark, Legend, Line, Plot};
|
||||||
|
|
||||||
use std::mem::swap;
|
use std::mem::swap;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
@ -10,12 +10,9 @@ use std::sync::mpsc::{channel, Receiver, Sender};
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread::{self, JoinHandle};
|
use std::thread::{self, JoinHandle};
|
||||||
|
|
||||||
use log::debug;
|
|
||||||
|
|
||||||
mod analyzer;
|
mod analyzer;
|
||||||
use analyzer::{
|
use analyzer::{
|
||||||
lin_to_db, Analyzer, FftAnalysis, FftAnalyzer, FftMeasurement, FftMeasurementValue,
|
lin_to_db, Analyzer, FftAnalysis, FftAnalyzer, FftMeasurementValue, PeakFreqAmplitude,
|
||||||
PeakFreqAmplitude,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::analyzer::RmsAmplitudeMeasurement;
|
use crate::analyzer::RmsAmplitudeMeasurement;
|
||||||
@ -200,6 +197,7 @@ impl MyApp {
|
|||||||
let plot_data = last_fft_result.plot_data.lock().unwrap();
|
let plot_data = last_fft_result.plot_data.lock().unwrap();
|
||||||
let plot_min = plot_data.plot_min.min(-120.0);
|
let plot_min = plot_data.plot_min.min(-120.0);
|
||||||
let plot_max = plot_data.plot_max.max(0.0);
|
let plot_max = plot_data.plot_max.max(0.0);
|
||||||
|
// TODO: Need coordinates_formatter for log and linear plots
|
||||||
let mut plot = Plot::new("FFT")
|
let mut plot = Plot::new("FFT")
|
||||||
.allow_drag(false)
|
.allow_drag(false)
|
||||||
.include_y(plot_min)
|
.include_y(plot_min)
|
||||||
|
Loading…
Reference in New Issue
Block a user