Bug1636: fix Crash on OK selecting RIAA or Telephone Eq curve...

... Really two crashes, one in case Linear frequency scale is selected, the
other if Logarithmic.

Problem was introduced at commit 7d5e54e364
This commit is contained in:
Paul Licameli 2017-07-14 10:50:28 -04:00
parent 54af4f1ff7
commit 4a500c77dd
1 changed files with 20 additions and 7 deletions

View File

@ -1680,12 +1680,20 @@ void EffectEqualization::setCurve(int currentCurve)
break;
}
else {
// There are more points at higher freqs,
// so interpolate next one then stop.
when = 1.0;
double lastF = mCurves[currentCurve].points[pointCount-1].Freq;
double nextF = mCurves[currentCurve].points[pointCount].Freq;
double lastDB = mCurves[currentCurve].points[pointCount-1].dB;
double nextDB = mCurves[currentCurve].points[pointCount].dB;
value = lastDB + ((nextDB - lastDB) * ((mHiFreq - lastF) / (nextF - lastF)));
if (pointCount > 0) {
double nextF = mCurves[currentCurve].points[pointCount].Freq;
double lastF = mCurves[currentCurve].points[pointCount-1].Freq;
double lastDB = mCurves[currentCurve].points[pointCount-1].dB;
value = lastDB +
((nextDB - lastDB) *
((mHiFreq - lastF) / (nextF - lastF)));
}
else
value = nextDB;
env->InsertOrReplace(when, value);
break;
}
@ -1751,9 +1759,14 @@ void EffectEqualization::setCurve(int currentCurve)
// interpolate the final point instead
when = 1.0;
double logLastF = log10(mCurves[currentCurve].points[pointCount-1].Freq);
double lastDB = mCurves[currentCurve].points[pointCount-1].dB;
value = lastDB + ((value - lastDB) * ((log10(mHiFreq) - logLastF) / (flog - logLastF)));
if (pointCount > 0) {
double lastDB = mCurves[currentCurve].points[pointCount-1].dB;
double logLastF =
log10(mCurves[currentCurve].points[pointCount-1].Freq);
value = lastDB +
((value - lastDB) *
((log10(mHiFreq) - logLastF) / (flog - logLastF)));
}
env->InsertOrReplace(when, value);
break;
}