fix fft window init
This commit is contained in:
parent
385bd830ad
commit
c7e0640401
1 changed files with 3 additions and 4 deletions
|
@ -11,7 +11,6 @@ pub type AudioBuffer = [i32; AUDIO_SAMPLES_PER_BUF];
|
|||
pub type DspBuffer = [f32; AUDIO_SAMPLES_PER_BUF];
|
||||
|
||||
static FFT_WINDOW_CELL: StaticCell<DspBuffer> = StaticCell::new();
|
||||
static FFT_WINDOW: Option<&DspBuffer> = None;
|
||||
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub struct AudioStats {
|
||||
|
@ -22,6 +21,7 @@ pub struct AudioStats {
|
|||
|
||||
pub struct AudioProcessor {
|
||||
pub stats: AudioStats,
|
||||
window: &'static DspBuffer,
|
||||
}
|
||||
|
||||
impl Default for AudioProcessor {
|
||||
|
@ -32,14 +32,13 @@ impl Default for AudioProcessor {
|
|||
esp_dsp::dsps_wind_hann_f32(buf.as_mut_ptr(), AUDIO_SAMPLES_PER_BUF as i32);
|
||||
}
|
||||
|
||||
FFT_WINDOW_CELL.init(buf);
|
||||
|
||||
AudioProcessor {
|
||||
stats: AudioStats {
|
||||
floating_max: 0i32,
|
||||
current_powers: [0f32; AUDIO_BANDS],
|
||||
avg_powers: [0f32; AUDIO_BANDS],
|
||||
},
|
||||
window: FFT_WINDOW_CELL.init(buf),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +75,7 @@ impl AudioProcessor {
|
|||
unsafe {
|
||||
esp_nofail!(esp_dsp::dsps_mul_f32_ae32(
|
||||
fft.as_ptr(),
|
||||
FFT_WINDOW.expect("windows not initialized!").as_ptr(),
|
||||
self.window.as_ptr(),
|
||||
fft.as_mut_ptr(),
|
||||
AUDIO_SAMPLES_PER_BUF as i32,
|
||||
1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue