From be39e19365251b20077a0fc0ad73a749c3ed8068 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 8 Mar 2022 13:50:45 +0100 Subject: [PATCH] Allow FFTW to destroy input arrays Since they're scratch buffers anyways. --- plugins/diopser/src/spectrum.rs | 6 +++++- plugins/examples/stft/src/lib.rs | 6 ++++-- plugins/puberty_simulator/src/lib.rs | 12 ++++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/plugins/diopser/src/spectrum.rs b/plugins/diopser/src/spectrum.rs index e1673c3c..469499be 100644 --- a/plugins/diopser/src/spectrum.rs +++ b/plugins/diopser/src/spectrum.rs @@ -75,7 +75,11 @@ impl SpectrumInput { spectrum_result_buffer: [0.0; SPECTRUM_WINDOW_SIZE / 2], plan: Plan { - r2c_plan: R2CPlan32::aligned(&[SPECTRUM_WINDOW_SIZE], Flag::MEASURE).unwrap(), + r2c_plan: R2CPlan32::aligned( + &[SPECTRUM_WINDOW_SIZE], + Flag::MEASURE | Flag::DESTROYINPUT, + ) + .unwrap(), }, compensated_window_function: util::window::hann(SPECTRUM_WINDOW_SIZE) .into_iter() diff --git a/plugins/examples/stft/src/lib.rs b/plugins/examples/stft/src/lib.rs index 68146912..02616009 100644 --- a/plugins/examples/stft/src/lib.rs +++ b/plugins/examples/stft/src/lib.rs @@ -40,8 +40,10 @@ struct StftParams {} impl Default for Stft { fn default() -> Self { - let mut r2c_plan: R2CPlan32 = R2CPlan32::aligned(&[WINDOW_SIZE], Flag::MEASURE).unwrap(); - let c2r_plan: C2RPlan32 = C2RPlan32::aligned(&[WINDOW_SIZE], Flag::MEASURE).unwrap(); + let mut r2c_plan: R2CPlan32 = + R2CPlan32::aligned(&[WINDOW_SIZE], Flag::MEASURE | Flag::DESTROYINPUT).unwrap(); + let c2r_plan: C2RPlan32 = + C2RPlan32::aligned(&[WINDOW_SIZE], Flag::MEASURE | Flag::DESTROYINPUT).unwrap(); let mut real_fft_scratch_buffer: AlignedVec = AlignedVec::new(WINDOW_SIZE); let mut complex_fft_scratch_buffer: AlignedVec = AlignedVec::new(WINDOW_SIZE / 2 + 1); diff --git a/plugins/puberty_simulator/src/lib.rs b/plugins/puberty_simulator/src/lib.rs index 5bc5e697..638a0089 100644 --- a/plugins/puberty_simulator/src/lib.rs +++ b/plugins/puberty_simulator/src/lib.rs @@ -179,8 +179,16 @@ impl Plugin for PubertySimulator { // that's good enough for now. An alternative would be to replan on a worker thread, // but this makes switching between window sizes a bit cleaner. .map(|order| Plan { - r2c_plan: R2CPlan32::aligned(&[1 << order], Flag::ESTIMATE).unwrap(), - c2r_plan: C2RPlan32::aligned(&[1 << order], Flag::ESTIMATE).unwrap(), + r2c_plan: R2CPlan32::aligned( + &[1 << order], + Flag::ESTIMATE | Flag::DESTROYINPUT, + ) + .unwrap(), + c2r_plan: C2RPlan32::aligned( + &[1 << order], + Flag::ESTIMATE | Flag::DESTROYINPUT, + ) + .unwrap(), }) .collect(); self.plan_for_order = Some(