1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-08 14:13:57 +01:00

GetMinMax, GetRMS functions take a mayThrow argument, return numbers

This commit is contained in:
Paul Licameli
2016-12-25 08:40:15 -05:00
parent dcac8788ff
commit 70d9e4bdc7
17 changed files with 183 additions and 184 deletions

View File

@@ -164,8 +164,8 @@ bool EffectAmplify::Init()
for (Track *t = iter.First(); t; t = iter.Next())
{
float min, max;
((WaveTrack *)t)->GetMinMax(&min, &max, mT0, mT1);
auto pair = ((WaveTrack *)t)->GetMinMax(mT0, mT1); // may throw
const float min = pair.first, max = pair.second;
float newpeak = (fabs(min) > fabs(max) ? fabs(min) : fabs(max));
if (newpeak > mPeak)

View File

@@ -84,7 +84,8 @@ bool ContrastDialog::GetDB(float &dB)
return false;
}
((WaveTrack *)t)->GetRMS(&rms, mT0, mT1);
// Don't throw in this analysis dialog
rms = ((WaveTrack *)t)->GetRMS(mT0, mT1, false);
meanSq += rms * rms;
t = (WaveTrack *) iter.Next();
}

View File

@@ -344,7 +344,10 @@ bool EffectNormalize::AnalyseTrack(const WaveTrack * track, const wxString &msg,
wxMilliSleep(100);
}
track->GetMinMax(&min, &max, mCurT0, mCurT1);
// set mMin, mMax. No progress bar here as it's fast.
auto pair = track->GetMinMax(mCurT0, mCurT1); // may throw
min = pair.first, max = pair.second;
} else {
min = -1.0, max = 1.0; // sensible defaults?
}

View File

@@ -968,7 +968,8 @@ bool NyquistEffect::ProcessOne()
if (mCurNumChannels > 1) clips += wxT(" )");
float min, max;
mCurTrack[i]->GetMinMax(&min, &max, mT0, mT1);
auto pair = mCurTrack[i]->GetMinMax(mT0, mT1); // may throw
min = pair.first, max = pair.second;
maxPeak = wxMax(wxMax(fabs(min), fabs(max)), maxPeak);
maxPeakLevel = wxMax(maxPeakLevel, maxPeak);
@@ -980,8 +981,7 @@ bool NyquistEffect::ProcessOne()
peakString += wxT("nil");
}
float rms = 0.0;
mCurTrack[i]->GetRMS(&rms, mT0, mT1);
float rms = mCurTrack[i]->GetRMS(mT0, mT1); // may throw
if (!std::isinf(rms) && !std::isnan(rms)) {
rmsString += wxString::Format(wxT("(float %s) "), Internat::ToString(rms).c_str());
} else {