Defend against NaN/Inf and negative ratios

This commit is contained in:
Chris Cannam
2022-09-30 10:36:29 +01:00
parent 50b231ee23
commit 1bd266cdb6
2 changed files with 31 additions and 3 deletions

View File

@@ -385,7 +385,13 @@ R2Stretcher::calculateSizes()
m_log.log(0, "WARNING: Time ratio must be greater than zero! Resetting it to default, no time stretch will happen", m_timeRatio);
m_timeRatio = 1.0;
}
if (m_pitchScale != m_pitchScale || m_timeRatio != m_timeRatio ||
m_pitchScale == m_pitchScale/2.0 || m_timeRatio == m_timeRatio/2.0) {
m_log.log(0, "WARNING: NaN or Inf presented for time ratio or pitch scale! Resetting it to default, no time stretch will happen", m_timeRatio, m_pitchScale);
m_timeRatio = 1.0;
m_pitchScale = 1.0;
}
double r = getEffectiveRatio();
if (m_realtime) {