* Warn and recover if time or pitch ratio is zero (or smaller)

This commit is contained in:
Chris Cannam
2008-10-13 19:13:21 +00:00
parent 02c1d67034
commit 4d875a5ef4

View File

@@ -342,6 +342,19 @@ RubberBandStretcher::Impl::calculateSizes()
size_t windowSize = m_baseWindowSize; size_t windowSize = m_baseWindowSize;
size_t outputIncrement; size_t outputIncrement;
if (m_pitchScale <= 0.0) {
// This special case is likelier than one might hope, because
// of naive initialisations in programs that set it from a
// variable
std::cerr << "RubberBandStretcher: WARNING: Pitch scale must be greater than zero!\nResetting it from " << m_pitchScale << " to the default of 1.0: no pitch change will occur" << std::endl;
m_pitchScale = 1.0;
}
if (m_timeRatio <= 0.0) {
// Likewise
std::cerr << "RubberBandStretcher: WARNING: Time ratio must be greater than zero!\nResetting it from " << m_timeRatio << " to the default of 1.0: no time stretch will occur" << std::endl;
m_timeRatio = 1.0;
}
double r = getEffectiveRatio(); double r = getEffectiveRatio();
if (m_realtime) { if (m_realtime) {