1
0
Fork 0

Remove post-IDFT windowing in STFT helper

There's no reason to.
This commit is contained in:
Robbert van der Helm 2022-03-06 19:07:46 +01:00
parent 175030b77c
commit 93ab08e5d5
2 changed files with 5 additions and 5 deletions

View file

@ -49,9 +49,8 @@ impl Default for Stft {
let filter_window = util::window::hann(FILTER_WINDOW_SIZE); let filter_window = util::window::hann(FILTER_WINDOW_SIZE);
real_fft_scratch_buffer[0..FILTER_WINDOW_SIZE].copy_from_slice(&filter_window); real_fft_scratch_buffer[0..FILTER_WINDOW_SIZE].copy_from_slice(&filter_window);
// And make sure to normalize this so the levels doesn't change much after convolving // And make sure to normalize this so convolution sums to 1
let filter_normalization_factor = let filter_normalization_factor = real_fft_scratch_buffer.iter().sum::<f32>().recip();
real_fft_scratch_buffer.iter().sum::<f32>().recip() * 2.0f32.sqrt() * 2.0;
for sample in real_fft_scratch_buffer.as_slice_mut() { for sample in real_fft_scratch_buffer.as_slice_mut() {
*sample *= filter_normalization_factor; *sample *= filter_normalization_factor;
} }
@ -129,7 +128,9 @@ impl Plugin for Stft {
buffer: &mut Buffer, buffer: &mut Buffer,
_context: &mut impl ProcessContext, _context: &mut impl ProcessContext,
) -> ProcessStatus { ) -> ProcessStatus {
const GAIN_COMPENSATION: f32 = 1.0 / OVERLAP_TIMES as f32 / WINDOW_SIZE as f32; // Compensate for the window function, the overlap, and the extra gain introduced by the
// IDFT operation
const GAIN_COMPENSATION: f32 = 2.0 / OVERLAP_TIMES as f32 / WINDOW_SIZE as f32;
self.stft.process_overlap_add( self.stft.process_overlap_add(
buffer, buffer,

View file

@ -248,7 +248,6 @@ impl<const NUM_SIDECHAIN_INPUTS: usize> StftHelper<NUM_SIDECHAIN_INPUTS> {
process_cb(channel_idx, None, &mut self.scratch_buffer); process_cb(channel_idx, None, &mut self.scratch_buffer);
// The actual overlap-add part of the equation // The actual overlap-add part of the equation
multiply_with_window(&mut self.scratch_buffer, window_function);
add_scratch_to_ring_buffer( add_scratch_to_ring_buffer(
&self.scratch_buffer, &self.scratch_buffer,
self.current_pos, self.current_pos,