Commit 3c0cee6 1 parent 45591bf commit 3c0cee6 Copy full SHA for 3c0cee6
File tree 2 files changed +5
-4
lines changed
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,9 @@ use crate::ui::state::UiState;
10
10
/// The spectrum is calculated using the FFT algorithm and a Hann window. The corresponding window size is specified in [`FFT_WINDOW_SIZE`].
11
11
/// The spectrum is then mapped to a logarithmic scale and returned.
12
12
/// * `microphone` - The microphone to calculate the spectrum for.
13
- /// * `delta_t` - The time between two samples.
14
13
/// * `ui_state` - The current state of the UI.
15
14
pub fn calc_mic_spectrum (
16
15
microphone : & mut Microphone ,
17
- delta_t : f32 ,
18
16
ui_state : & UiState ,
19
17
) -> Vec < [ f64 ; 2 ] > {
20
18
let samples = if microphone. record . len ( ) < FFT_WINDOW_SIZE {
@@ -29,7 +27,10 @@ pub fn calc_mic_spectrum(
29
27
// always returns frequencies up to sampling_rate/2
30
28
let spectrum_hann_window = samples_fft_to_spectrum (
31
29
& hann_window,
32
- ( 1. / delta_t) as u32 ,
30
+ // "Normally" the sample rate should be calculated as: (1. / delta_t) as u32
31
+ // But because the rate of samples provided does not actually change when changing delta_l,
32
+ // we can just use the constant value. Calculated as 1/(0.001 / 343) = 343200
33
+ 343200 ,
33
34
FrequencyLimit :: All ,
34
35
Some ( & scale_to_zero_to_one) ,
35
36
)
Original file line number Diff line number Diff line change @@ -895,7 +895,7 @@ pub fn draw_egui(
895
895
== ui_state. current_fft_microphone . expect ( "no mic selected" )
896
896
} ) {
897
897
let mapped_spectrum =
898
- calc_mic_spectrum ( & mut mic, grid . delta_t , & ui_state) ;
898
+ calc_mic_spectrum ( & mut mic, & ui_state) ;
899
899
// remove the first element, because of log it is at x=-inf
900
900
let mapped_spectrum = & mapped_spectrum[ 1 ..] ;
901
901
You can’t perform that action at this time.
0 commit comments