aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-01-19 11:49:53 -0800
committerChris Robinson <[email protected]>2023-01-19 11:49:53 -0800
commit28d1cd0681440aa413ef24ea83eea988a8fe152e (patch)
tree7742cb140fe6aee53f9acde9fe00aac5c9289740 /alc
parenta56b373f2503f9361974fdb836fe4945a6bdbf63 (diff)
Slightly improve phase wrapping in the pitch shifter
Diffstat (limited to 'alc')
-rw-r--r--alc/effects/pshifter.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp
index 6bdcb26b..62057f50 100644
--- a/alc/effects/pshifter.cpp
+++ b/alc/effects/pshifter.cpp
@@ -120,13 +120,13 @@ void PshifterState::deviceUpdate(const DeviceBase*, const Buffer&)
mPitchShiftI = MixerFracOne;
mPitchShift = 1.0;
- std::fill(mFIFO.begin(), mFIFO.end(), 0.0);
- std::fill(mLastPhase.begin(), mLastPhase.end(), 0.0);
- std::fill(mSumPhase.begin(), mSumPhase.end(), 0.0);
- std::fill(mOutputAccum.begin(), mOutputAccum.end(), 0.0);
- std::fill(mFftBuffer.begin(), mFftBuffer.end(), complex_d{});
- std::fill(mAnalysisBuffer.begin(), mAnalysisBuffer.end(), FrequencyBin{});
- std::fill(mSynthesisBuffer.begin(), mSynthesisBuffer.end(), FrequencyBin{});
+ mFIFO.fill(0.0);
+ mLastPhase.fill(0.0);
+ mSumPhase.fill(0.0);
+ mOutputAccum.fill(0.0);
+ mFftBuffer.fill(complex_d{});
+ mAnalysisBuffer.fill(FrequencyBin{});
+ mSynthesisBuffer.fill(FrequencyBin{});
std::fill(std::begin(mCurrentGains), std::end(mCurrentGains), 0.0f);
std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f);
@@ -260,9 +260,10 @@ void PshifterState::process(const size_t samplesToDo,
* grow indefinitely, it will lose precision and produce less exact
* phase over time.
*/
- int qpd{double2int(tmp * al::numbers::inv_pi)};
- tmp -= al::numbers::pi * (qpd + (qpd%2));
- mSumPhase[k] = tmp;
+ tmp *= al::numbers::inv_pi;
+ int qpd{double2int(tmp)};
+ tmp -= qpd + (qpd%2);
+ mSumPhase[k] = tmp * al::numbers::pi;
mFftBuffer[k] = std::polar(mSynthesisBuffer[k].Magnitude, mSumPhase[k]);
}