Clean up unused members / includes

This commit is contained in:
Keenan Tims 2023-11-13 13:41:44 -08:00
parent 6028d5ca05
commit 2df27bec85
Signed by: ktims
GPG Key ID: 11230674D69038D4
2 changed files with 6 additions and 18 deletions

View File

@ -1,11 +1,8 @@
use num::complex::ComplexFloat;
use num::traits::real::Real;
use num::traits::AsPrimitive;
use num::{Float, FromPrimitive, Num, Signed, ToPrimitive};
use num::{Float, FromPrimitive, Num, ToPrimitive};
use realfft::{RealFftPlanner, RealToComplex};
use ringbuf::{HeapRb, Rb};
use rustfft::num_complex::Complex;
use rustfft::{Fft, FftNum};
use rustfft::FftNum;
use std::fmt::{Debug, Display};
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
}
}
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) {
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,
sample_rate: U,
channels: usize,
norm_factor: U,
bin_freqs: Vec<U>,
planner: RealFftPlanner<U>,
processor: Arc<dyn RealToComplex<U>>,
window: HanningWindow<U>,
@ -240,13 +235,11 @@ impl<T: Num, U: FftNum, const NUM_CHANNELS: usize> FftAnalyzer<T, U, NUM_CHANNEL
fft_length,
sample_rate,
channels,
norm_factor: U::from_f64(1.0 / (fft_length as f64).sqrt()).unwrap(),
bin_freqs,
log_plot: true,
processor: planner.plan_fft_forward(fft_length),
planner,
window: HanningWindow::new(fft_length),
audio_buf: Arc::new(Mutex::new(AudioBuf::<T> {
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;
}
fn progress(&self) -> f32 {
self.audio_buf.lock().unwrap().read_since_last_update as f32 / self.fft_length as f32
}
}
impl<

View File

@ -2,7 +2,7 @@ use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use egui::epaint::Hsva;
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::sync::atomic::{AtomicUsize, Ordering};
@ -10,12 +10,9 @@ use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::{Arc, Mutex};
use std::thread::{self, JoinHandle};
use log::debug;
mod analyzer;
use analyzer::{
lin_to_db, Analyzer, FftAnalysis, FftAnalyzer, FftMeasurement, FftMeasurementValue,
PeakFreqAmplitude,
lin_to_db, Analyzer, FftAnalysis, FftAnalyzer, FftMeasurementValue, PeakFreqAmplitude,
};
use crate::analyzer::RmsAmplitudeMeasurement;
@ -200,6 +197,7 @@ impl MyApp {
let plot_data = last_fft_result.plot_data.lock().unwrap();
let plot_min = plot_data.plot_min.min(-120.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")
.allow_drag(false)
.include_y(plot_min)