Browse Source

Convolution: Compensate for volume changes when resampling IRs

When normalisation is disabled, the Convolution will now adjust the gain
of the IR using the ratio of the source and destination sampling rates.
This should keep the output level constant when the Convolution's
sampling rate is changed.
tags/2021-05-28
reuk 4 years ago
parent
commit
68d30f9c8d
2 changed files with 7 additions and 2 deletions
  1. +2
    -0
      modules/juce_dsp/frequency/juce_Convolution.cpp
  2. +5
    -2
      modules/juce_dsp/frequency/juce_Convolution_test.cpp

+ 2
- 0
modules/juce_dsp/frequency/juce_Convolution.cpp View File

@@ -781,6 +781,8 @@ private:
if (wantsNormalise == Convolution::Normalise::yes)
normaliseImpulseResponse (resampled);
else
resampled.applyGain ((float) (originalSampleRate / processSpec.sampleRate));
const auto currentLatency = jmax (processSpec.maximumBlockSize, (uint32) latency.latencyInSamples);
const auto maxBufferSize = shouldBeZeroLatency ? static_cast<int> (processSpec.maximumBlockSize)


+ 5
- 2
modules/juce_dsp/frequency/juce_Convolution_test.cpp View File

@@ -514,6 +514,9 @@ public:
AudioBuffer<float> result (original.getNumChannels(), finalSize);
resamplingSource.getNextAudioBlock ({ &result, 0, result.getNumSamples() });
result.applyGain ((float) resampleRatio);
return result;
}();
@@ -550,10 +553,10 @@ public:
const auto ramp = makeRamp (static_cast<int> (spec.maximumBlockSize) * 8);
using BlockSize = decltype (spec.maximumBlockSize);
for (auto latency : { /*static_cast<BlockSize> (0),
for (auto latency : { static_cast<BlockSize> (0),
spec.maximumBlockSize / 3,
spec.maximumBlockSize,
spec.maximumBlockSize * 2, */
spec.maximumBlockSize * 2,
static_cast<BlockSize> (spec.maximumBlockSize * 2.5) })
{
testConvolution (spec,


Loading…
Cancel
Save