aboutsummaryrefslogtreecommitdiffstats
path: root/alc/effects
diff options
context:
space:
mode:
Diffstat (limited to 'alc/effects')
-rw-r--r--alc/effects/convolution.cpp9
-rw-r--r--alc/effects/pshifter.cpp6
2 files changed, 10 insertions, 5 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
diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp
index 18be0e38..01d24333 100644
--- a/alc/effects/pshifter.cpp
+++ b/alc/effects/pshifter.cpp
@@ -226,15 +226,15 @@ void PshifterState::process(const size_t samplesToDo, const al::span<const Float
mFftBuffer[k] = std::polar(mSynthesisBuffer[k].Amplitude, mSumPhase[k]);
}
- /* Clear negative frequencies to recontruct the time-domain signal. */
- std::fill(mFftBuffer.begin()+STFT_HALF_SIZE+1, mFftBuffer.end(), complex_d{});
+ for(size_t k{STFT_HALF_SIZE+1};k < STFT_SIZE;++k)
+ mFftBuffer[k] = std::conj(mFftBuffer[STFT_SIZE-k]);
/* Apply an inverse FFT to get the time-domain siganl, and accumulate
* for the output with windowing.
*/
complex_fft(mFftBuffer, 1.0);
for(size_t k{0u};k < STFT_SIZE;k++)
- mOutputAccum[k] += HannWindow[k]*mFftBuffer[k].real() * (2.0/STFT_HALF_SIZE/OVERSAMP);
+ mOutputAccum[k] += HannWindow[k]*mFftBuffer[k].real() * (2.0/STFT_SIZE/OVERSAMP);
/* Shift FIFO and accumulator. */
fifo_iter = std::copy(mFIFO.begin()+STFT_STEP, mFIFO.end(), mFIFO.begin());