1
0
Fork 0

Fix FFT FIR crossover latency calculation

This commit is contained in:
Robbert van der Helm 2022-06-07 20:46:23 +02:00
parent c23cf8e7ee
commit b389268168
2 changed files with 8 additions and 5 deletions

View file

@ -108,7 +108,9 @@ impl FirCrossover {
// Actually, that's a lie, since we currently only do linear-phase filters with a constant
// size
match self.mode {
FirCrossoverType::LinkwitzRiley24LinearPhase => FFT_INPUT_SIZE as u32,
FirCrossoverType::LinkwitzRiley24LinearPhase => {
(FFT_INPUT_SIZE + (FILTER_SIZE / 2)) as u32
}
}
}

View file

@ -26,10 +26,11 @@ use crate::NUM_CHANNELS;
/// smaller since it will be padding with zeroes to compensate for the otherwise overlapping tail
/// caused by the convolution.
pub const FFT_SIZE: usize = 4096;
/// The input chunk size the FFT convolution is processing. This is also the latency. By having this
/// be exactly half of FFT_SIZE, we can make the overlap-add part of the FFT convolution a lot
/// simpler for ourselves. (check the `StftHelper` struct in NIH-plug itself for an examples that
/// can handle arbitrary padding)
/// The input chunk size the FFT convolution is processing. This is also part of the latency, with
/// the total latency being `FFT_INPUT_SIZE + (FILTER_SIZE / 2)` samples. By having this be exactly
/// half of FFT_SIZE, we can make the overlap-add part of the FFT convolution a lot simpler for
/// ourselves. (check the `StftHelper` struct in NIH-plug itself for an examples that can handle
/// arbitrary padding)
pub const FFT_INPUT_SIZE: usize = FFT_SIZE / 2;
/// The size of the FIR filter window, or the number of taps. Convoling `FFT_INPUT_SIZE` samples
/// with this filter should fit exactly in `FFT_SIZE`, and it should be an odd number.