Use the new overlap-add helper in the STFT example
Still without any proper FFT stuff.
This commit is contained in:
parent
f7b3bd9198
commit
e72203f919
1 changed files with 15 additions and 9 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue