diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index f736bc8..026f515 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -1317,42 +1317,41 @@ void SpatGrisAudioProcessor::ProcessDataPanVolumeMode(float **p_ppfInputs, float - //figure out tetha, ramping if we pass the center - float fNewTheta; - //SITUATION 1 WE'RE RIGHT IN THE MIDDLE OF THE CIRCLE. If fCurSampleR < .025, we use fPrevLockedTheta, but if fCurSampleR is [.025,.05], we use a ramp between fPrevLockedTheta and fCurSampleT - if (fCurSampleR < kThetaLockRadius) { - //if fCurSampleR is smaller than .025 (kThetaLockRampRadius), fProportionOfCurrentTheta is 0, so we use 100% of fPrevTheta - //if fCurSampleR is within [.025, .05], fProportionOfCurrentTheta is == fCurSampleR normalized to [0,1] - float fProportionOfCurrentTheta = (fCurSampleR >= kThetaLockRampRadius) ? ((fCurSampleR - kThetaLockRampRadius) / (kThetaLockRadius - kThetaLockRampRadius)) : 0; - //calculate difference between previous and current theta - float fPrevLockedTheta = mLockedThetas.getUnchecked(iCurSource); - float fDeltaTheta = abs(fPrevLockedTheta - fCurSampleT); - if (fDeltaTheta > kQuarterCircle) { - // assume flipped side - if (fPrevLockedTheta > fCurSampleT) { - fPrevLockedTheta -= kHalfCircle; - } else { - fPrevLockedTheta += kHalfCircle; - } - } - //fNewTheta is a ramp between previous value (fPrevLockedTheta) and current value (fCurSampleT) - fNewTheta = fProportionOfCurrentTheta * fCurSampleT + (1 - fProportionOfCurrentTheta) * fPrevLockedTheta; - - if (fNewTheta < 0) { - fNewTheta += kThetaMax; - } else if (fNewTheta >= kThetaMax) { - fNewTheta -= kThetaMax; - } - } - //if fCurSampleR is bigger than kThetaLockRadius (which is the case if we're not right in the center), store theta of current source - else { - fNewTheta = fCurSampleT; - mLockedThetas.setUnchecked(iCurSource, fCurSampleT); - } +// //figure out tetha, ramping if we pass the center +// float fNewTheta; +// //SITUATION 1 WE'RE RIGHT IN THE MIDDLE OF THE CIRCLE. If fCurSampleR < .025, we use fPrevLockedTheta, but if fCurSampleR is [.025,.05], we use a ramp between fPrevLockedTheta and fCurSampleT +// if (fCurSampleR < kThetaLockRadius) { +// //if fCurSampleR is smaller than .025 (kThetaLockRampRadius), fProportionOfCurrentTheta is 0, so we use 100% of fPrevTheta +// //if fCurSampleR is within [.025, .05], fProportionOfCurrentTheta is == fCurSampleR normalized to [0,1] +// float fProportionOfCurrentTheta = (fCurSampleR >= kThetaLockRampRadius) ? ((fCurSampleR - kThetaLockRampRadius) / (kThetaLockRadius - kThetaLockRampRadius)) : 0; +// //calculate difference between previous and current theta +// float fPrevLockedTheta = mLockedThetas.getUnchecked(iCurSource); +// float fDeltaTheta = abs(fPrevLockedTheta - fCurSampleT); +// if (fDeltaTheta > kQuarterCircle) { +// // assume flipped side +// if (fPrevLockedTheta > fCurSampleT) { +// fPrevLockedTheta -= kHalfCircle; +// } else { +// fPrevLockedTheta += kHalfCircle; +// } +// } +// //fNewTheta is a ramp between previous value (fPrevLockedTheta) and current value (fCurSampleT) +// fNewTheta = fProportionOfCurrentTheta * fCurSampleT + (1 - fProportionOfCurrentTheta) * fPrevLockedTheta; +// +// if (fNewTheta < 0) { +// fNewTheta += kThetaMax; +// } else if (fNewTheta >= kThetaMax) { +// fNewTheta -= kThetaMax; +// } +// } +// //if fCurSampleR is bigger than kThetaLockRadius (which is the case if we're not right in the center), store theta of current source +// else { +// fNewTheta = fCurSampleT; +// mLockedThetas.setUnchecked(iCurSource, fCurSampleT); +// } - - + @@ -1409,30 +1408,46 @@ void SpatGrisAudioProcessor::ProcessDataPanVolumeMode(float **p_ppfInputs, float - - - -// float fNewTheta = fCurSampleT; -// float fPrevTheta = mPrevTs.getUnchecked(iCurSource); -// float fDeltaTheta = fNewTheta - fPrevTheta; -// if (abs(fDeltaTheta) > 3*M_PI_2){ -// const float kfMaxDeltaTheta = M_PI / 100 ; -// fNewTheta = (fDeltaTheta > 0) ? fPrevTheta + kfMaxDeltaTheta : fPrevTheta - kfMaxDeltaTheta; -// if (fNewTheta < 0) { -// fNewTheta += kThetaMax; -// } else if (fNewTheta >= kThetaMax) { -// fNewTheta -= kThetaMax; -// } -// } -// -// mPrevTs.setUnchecked(iCurSource, fNewTheta); + //MY NEW ALGORITHM + float fNewTheta = fCurSampleT; + float fPrevTheta = mPrevTs.getUnchecked(iCurSource); + float fDeltaTheta = fNewTheta - fPrevTheta; + if (abs(fDeltaTheta) > 3*M_PI_2){ + const float kfMaxDeltaTheta = M_PI / 1 ; + fNewTheta = (fDeltaTheta > 0) ? fPrevTheta + kfMaxDeltaTheta : fPrevTheta - kfMaxDeltaTheta; + if (fNewTheta < 0) { + fNewTheta += kThetaMax; + } else if (fNewTheta >= kThetaMax) { + fNewTheta -= kThetaMax; + } + } + + mPrevTs.setUnchecked(iCurSource, fNewTheta); - - + // PRINTING THINGS + if (iCurSource == 0){ + allThetas.push_back(fNewTheta); + float sampleRate = 1 * getSampleRate(); + if (allThetas.size() >= sampleRate && !bThetasPrinted ){ + + cout << "\n\n\n\n"; + float prev = -1.f; + for (int i=0; i mLockedThetas; Array mPrevRs; Array mPrevTs; + + vector allThetas; + bool bThetasPrinted = false; #define kChunkSize (256) struct IOBuf { float b[kChunkSize]; }; diff --git a/dev_notes.txt b/dev_notes.txt index c051984..3e5bdb4 100644 --- a/dev_notes.txt +++ b/dev_notes.txt @@ -206,3 +206,7 @@ So. Here's how the algorithm should go: * no: we need to not store mLockedThetas when r < kThetaLockRadius + +continuing this on 2016-06-13. I created a reaper file with a crazy sharp automation on x position. I get clicks when the source oscillates over the center, but not when it oscillates over a non-center mid point. + +so I did a bunch of excel plots, and my algorithm doesn't work at all! Need to find a way to make it smoother when transitioning.