From 68e2d00f9b44465c4c9d3ce4b1e1e6dc1105f5b1 Mon Sep 17 00:00:00 2001 From: martynshaw99 Date: Wed, 2 May 2012 21:37:45 +0000 Subject: [PATCH] Restore default behaviour if no clips found to pre-r11704 status, whilst still get proper max and min for severely-offset waveforms. --- src/WaveTrack.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 63939594e..4b5b32998 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -1539,7 +1539,9 @@ double WaveTrack::GetEndTime() bool WaveTrack::GetMinMax(float *min, float *max, double t0, double t1) { - *min = FLT_MAX; + bool clipFound = false; + + *min = FLT_MAX; // we need these at extremes to make sure we find true min and max *max = -FLT_MAX; if (t0 > t1) @@ -1556,6 +1558,7 @@ bool WaveTrack::GetMinMax(float *min, float *max, if (t1 >= clip->GetStartTime() && t0 <= clip->GetEndTime()) { + clipFound = true; float clipmin, clipmax; if (it->GetData()->GetMinMax(&clipmin, &clipmax, t0, t1)) { @@ -1570,6 +1573,12 @@ bool WaveTrack::GetMinMax(float *min, float *max, } } + if(!clipFound) + { + *min = float(0.0); // sensible defaults if no clips found + *max = float(0.0); + } + return result; }