diff options
author | Chris Robinson <[email protected]> | 2020-09-08 22:56:30 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-09-08 23:20:06 -0700 |
commit | f4a55cc8c2e8093e1156686292a38ae10a738a08 (patch) | |
tree | 443e84925803dac41ec667491a8615a8d4ae6ec1 /alc/effects/convolution.cpp | |
parent | 29566b995cfd80f00f8c4c7e2c3d4c798bcffdfe (diff) |
Don't leave the negative frequencies as 0 for inverse FFT
Diffstat (limited to 'alc/effects/convolution.cpp')
-rw-r--r-- | alc/effects/convolution.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 102bed59..bbf8cb3f 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -266,8 +266,7 @@ void ConvolutionState::update(const ALCcontext *context, const ALeffectslot *slo /* The iFFT'd response is scaled up by the number of bins, so apply the * inverse to the output mixing gain. */ - constexpr size_t m{ConvolveUpdateSize/2 + 1}; - const float gain{slot->Params.Gain * (1.0f/m)}; + const float gain{slot->Params.Gain * (1.0f/float{ConvolveUpdateSize})}; auto &chans = *mChans; if(mChannels == FmtBFormat3D || mChannels == FmtBFormat2D) { @@ -386,6 +385,12 @@ void ConvolutionState::process(const size_t samplesToDo, mFftBuffer[i] += *input * *filter; } + /* Reconstruct the mirrored/negative frequencies to do a proper + * inverse FFT. + */ + for(size_t i{m};i < ConvolveUpdateSize;++i) + mFftBuffer[i] = std::conj(mFftBuffer[ConvolveUpdateSize-i]); + /* Apply iFFT to get the 1024 (really 1023) samples for output. The * 512 output samples are combined with the last output's 511 * second-half samples (and this output's second half is |