Skip to content

Commit

Permalink
fix #65, and comment debugging code related to #47
Browse files Browse the repository at this point in the history
  • Loading branch information
vberthiaume committed Jun 13, 2016
1 parent e55cba2 commit 7d325b6
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 82 deletions.
154 changes: 77 additions & 77 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ void SpatGrisAudioProcessor::sendOscSpatValues(){
message.addFloat32(elevspan_osc);
message.addFloat32(gain_osc);
JUCE_COMPILER_WARNING("NOT SENDING MESSAGES BECAUSE SENDING ON 0.0.0.0")
// if (!mOscSpatSender.send(message)) {
// DBG("Error: could not send OSC message.");
// return;
// }
if (!mOscSpatSender.send(message)) {
DBG("Error: could not send OSC message.");
return;
}
}
}

Expand Down Expand Up @@ -1317,38 +1317,38 @@ 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);
}



Expand Down Expand Up @@ -1407,47 +1407,47 @@ void SpatGrisAudioProcessor::ProcessDataPanVolumeMode(float **p_ppfInputs, float




//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<allThetas.size(); ++i) {
float cur = allThetas[i];
if (cur != prev){
cout << i << ": " << cur << newLine;
prev = cur;
}

}
bThetasPrinted = true;
}

}
//
// //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<allThetas.size(); ++i) {
// float cur = allThetas[i];
// if (cur != prev){
// cout << i << ": " << cur << newLine;
// prev = cur;
// }
//
// }
// bThetasPrinted = true;
// }
//
// }



Expand Down
13 changes: 8 additions & 5 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,15 @@ class SpatGrisAudioProcessor : public AudioProcessor

//calculate xy distance from origin, and clamp it to 2 (ie ignore outside of circle)
float hypo = hypotf(pXY.x, pXY.y);
if (hypo > 2){
hypo = 2;
if (hypo > kRadiusMax){
hypo = kRadiusMax;
}
float fElev = acosf(hypo/kRadiusMax); //fElev is elevation in radian, [0,pi/2)
fElev /= (M_PI/2); //making range [0,1]
fElev /= 2.; //making range [0,.5] because that's what the zirkonium wants

// float fElev = acosf(hypo/kRadiusMax); //fElev is elevation in radian, [0,pi/2)
// fElev /= (M_PI/2); //making range [0,1]
// fElev /= 2.; //making range [0,.5] because that's what the zirkonium wants

float fElev = (kRadiusMax-hypo)/4;

return FPoint(fAzim, fElev);
}
Expand Down

0 comments on commit 7d325b6

Please sign in to comment.