1
0
Fork 0

Use the new overlap-add helper in the STFT example

Still without any proper FFT stuff.
This commit is contained in:
Robbert van der Helm 2022-03-06 15:28:44 +01:00
parent f7b3bd9198
commit e72203f919

View file

@ -2,6 +2,7 @@ use nih_plug::prelude::*;
use std::pin::Pin; use std::pin::Pin;
const WINDOW_SIZE: usize = 2048; const WINDOW_SIZE: usize = 2048;
const OVERLAP_TIMES: usize = 4;
struct Stft { struct Stft {
params: Pin<Box<StftParams>>, params: Pin<Box<StftParams>>,
@ -71,15 +72,20 @@ impl Plugin for Stft {
buffer: &mut Buffer, buffer: &mut Buffer,
_context: &mut impl ProcessContext, _context: &mut impl ProcessContext,
) -> ProcessStatus { ) -> ProcessStatus {
self.stft.process(buffer, [], |block, _| { self.stft.process_overlap_add(
for channel_samples in block.iter_mut() { buffer,
for sample in channel_samples { [],
// TODO: Use the FFTW bindings and do some STFT operation here instead of &self.window_function,
// reducing the gain at a 512 sample latency... OVERLAP_TIMES,
*sample *= 0.5; 2.0 / OVERLAP_TIMES as f32, // Gain compensation for the overlap
} |_channel_idx, _, _block| {
} // for sample in block {
}); // // TODO: Use the FFTW bindings and do some STFT operation here instead of
// // reducing the gain at a 2048 sample latency...
// *sample *= 0.5;
// }
},
);
ProcessStatus::Normal ProcessStatus::Normal
} }