[Convolver] Normalize HRTF impulse when resampling

When resampling the impulse according to the playback rate, it becomes
necessary to normalize the resulting impulse by the inverse of the
sample ratio, as resampling adds more or less loudness by virtue of
interpolating samples.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
swiftingly
Christopher Snowhill 2022-05-30 01:39:12 -07:00
parent 7e0b7f2008
commit 50342891af
1 changed files with 4 additions and 0 deletions

View File

@ -256,6 +256,10 @@ static const int8_t speakers_to_hesuvi_14[11][2] = {
free(impulseBuffer); free(impulseBuffer);
impulseBuffer = resampledImpulse; impulseBuffer = resampledImpulse;
sampleCount = (int)outputDone; sampleCount = (int)outputDone;
// Normalize resampled impulse by sample ratio
float fSampleRatio = (float)sampleRatio;
vDSP_vsdiv(impulseBuffer, 1, &fSampleRatio, impulseBuffer, 1, sampleCount * impulseChannels);
} }
channelCount = channels; channelCount = channels;