Don't do gain compensation in STFT helper

You'll likely want to add some scaling yourself anyways, so this would
just be a wasted operation since the scaling also depends on your window
function.
This commit is contained in:
Robbert van der Helm
2022-03-06 15:33:16 +01:00
parent e72203f919
commit 2343485c1c
2 changed files with 12 additions and 14 deletions

View File

@@ -72,18 +72,18 @@ impl Plugin for Stft {
buffer: &mut Buffer,
_context: &mut impl ProcessContext,
) -> ProcessStatus {
const GAIN_COMPENSATION: f32 = 2.0 / OVERLAP_TIMES as f32;
self.stft.process_overlap_add(
buffer,
[],
&self.window_function,
OVERLAP_TIMES,
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;
// }
|_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 *= GAIN_COMPENSATION;
}
},
);