1
0
Fork 0

Allow FFTW to destroy input arrays

Since they're scratch buffers anyways.
This commit is contained in:
Robbert van der Helm 2022-03-08 13:50:45 +01:00
parent da1e850722
commit be39e19365
3 changed files with 19 additions and 5 deletions

View file

@ -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()

View file

@ -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<f32> = AlignedVec::new(WINDOW_SIZE);
let mut complex_fft_scratch_buffer: AlignedVec<c32> = AlignedVec::new(WINDOW_SIZE / 2 + 1);

View file

@ -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(