From 9599800c211da7e408a586e50a9f571073f4e90e Mon Sep 17 00:00:00 2001 From: TerraMaster85 Date: Wed, 15 Jan 2025 23:14:42 -0500 Subject: [PATCH] bang head --- src/audio_receiver/input_dsp.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/audio_receiver/input_dsp.rs b/src/audio_receiver/input_dsp.rs index 9c5b4f9..7aef7d3 100644 --- a/src/audio_receiver/input_dsp.rs +++ b/src/audio_receiver/input_dsp.rs @@ -28,7 +28,6 @@ pub fn take_input_pcm( let mut fft_planner = FftPlanner::::new(); - // Zero-pad for a better freq resolution. 8192 fft should be fast enough let mut window_offset = 0; let mut prev_phase = f64::MAX; @@ -36,9 +35,12 @@ pub fn take_input_pcm( while !carrier.acquired && window_offset + fft_size < pcm_buffer.len() { trace!("carrier acq: trying, window offset {window_offset}"); let pcm_buffer_contiguous = pcm_buffer.make_contiguous(); - let mut fft_frame: Vec> = if fft_size < 8192 { + // Zero-pad for a better freq resolution. 8192 fft should be fast enough + const MAX_ZERO_PAD: usize = 8192; + let mut fft_frame: Vec> = if fft_size < MAX_ZERO_PAD { let mut frm = - [Complex { re: 0.0f64, im: 0.0f64 }].repeat(8192 - fft_size); + [Complex { re: 0.0f64, im: 0.0f64 }] + .repeat(MAX_ZERO_PAD - fft_size); frm.extend( &pcm_buffer_contiguous[window_offset..(fft_size+window_offset)] );