Browse Source

Fix scaling of RealTimeConvolver

tags/v0.6.2
Andrew Belt 6 years ago
parent
commit
1685d41d38
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      include/dsp/fir.hpp

+ 3
- 2
include/dsp/fir.hpp View File

@@ -123,7 +123,7 @@ struct RealTimeConvolver {
// Note: This is the CPU bottleneck loop
for (size_t i = 0; i < kernelBlocks; i++) {
size_t pos = (inputPos - i + kernelBlocks) % kernelBlocks;
pffft_zconvolve_accumulate(pffft, &kernelFfts[blockSize*2 * i], &inputFfts[blockSize*2 * pos], tmpBlock, 1.0);
pffft_zconvolve_accumulate(pffft, &kernelFfts[blockSize*2 * i], &inputFfts[blockSize*2 * pos], tmpBlock, 1.f);
}
// Compute output
pffft_transform(pffft, tmpBlock, tmpBlock, NULL, PFFFT_BACKWARD);
@@ -132,9 +132,10 @@ struct RealTimeConvolver {
tmpBlock[i] += outputTail[i];
}
// Copy output block to output
float scale = 1.f / (blockSize*2);
for (size_t i = 0; i < blockSize; i++) {
// Scale based on FFT
output[i] = tmpBlock[i] / blockSize;
output[i] = tmpBlock[i] * scale;
}
// Set tail
for (size_t i = 0; i < blockSize; i++) {


Loading…
Cancel
Save