* fix bug in initial state of accumulator; fix compiler warnings

This commit is contained in:
Chris Cannam
2009-01-28 11:19:00 +00:00
parent 0da1cfd87a
commit c5a293da33
5 changed files with 18 additions and 8 deletions

View File

@@ -33,7 +33,7 @@ if test "x$GCC" = "xyes"; then
esac esac
case " $CXXFLAGS " in case " $CXXFLAGS " in
*[\ \ ]-fPIC\ -Wall[\ \ ]*) ;; *[\ \ ]-fPIC\ -Wall[\ \ ]*) ;;
*) CXXFLAGS="$CXXFLAGS -fPIC -Wall" ;; *) CXXFLAGS="$CXXFLAGS -fPIC -Wall -Woverloaded-virtual" ;;
esac esac
fi fi
changequote([,])dnl changequote([,])dnl

View File

@@ -31,9 +31,9 @@ AudioCurve::~AudioCurve()
} }
float float
AudioCurve::process(const double *R__ mag, size_t increment) AudioCurve::processDouble(const double *R__ mag, size_t increment)
{ {
cerr << "WARNING: Using inefficient AudioCurve::process(double)" << endl; cerr << "AudioCurve::processDouble: WARNING: Using inefficient and lossy conversion for AudioCurve::process(float)" << endl;
float *tmp = new float[m_windowSize]; float *tmp = new float[m_windowSize];
for (int i = 0; i < int(m_windowSize); ++i) tmp[i] = float(mag[i]); for (int i = 0; i < int(m_windowSize); ++i) tmp[i] = float(mag[i]);
float df = process(tmp, increment); float df = process(tmp, increment);

View File

@@ -31,7 +31,7 @@ public:
virtual void setWindowSize(size_t newSize) = 0; virtual void setWindowSize(size_t newSize) = 0;
virtual float process(const float *R__ mag, size_t increment) = 0; virtual float process(const float *R__ mag, size_t increment) = 0;
virtual float process(const double *R__ mag, size_t increment); virtual float processDouble(const double *R__ mag, size_t increment);
virtual void reset() = 0; virtual void reset() = 0;
protected: protected:

View File

@@ -281,6 +281,16 @@ RubberBandStretcher::Impl::ChannelData::reset()
if (resampler) resampler->reset(); if (resampler) resampler->reset();
size_t size = inbuf->getSize();
for (size_t i = 0; i < size; ++i) {
accumulator[i] = 0.f;
windowAccumulator[i] = 0.f;
}
// Avoid dividing opening sample (which will be discarded anyway) by zero
windowAccumulator[0] = 1.f;
accumulatorFill = 0; accumulatorFill = 0;
prevIncrement = 0; prevIncrement = 0;
chunkCount = 0; chunkCount = 0;

View File

@@ -447,8 +447,8 @@ RubberBandStretcher::Impl::calculateIncrements(size_t &phaseIncrementRtn,
if (m_channels == 1) { if (m_channels == 1) {
df = m_phaseResetAudioCurve->process(cd.mag, m_increment); df = m_phaseResetAudioCurve->processDouble(cd.mag, m_increment);
silent = (m_silentAudioCurve->process(cd.mag, m_increment) > 0.f); silent = (m_silentAudioCurve->processDouble(cd.mag, m_increment) > 0.f);
} else { } else {
@@ -463,8 +463,8 @@ RubberBandStretcher::Impl::calculateIncrements(size_t &phaseIncrementRtn,
} }
} }
df = m_phaseResetAudioCurve->process(tmp, m_increment); df = m_phaseResetAudioCurve->processDouble(tmp, m_increment);
silent = (m_silentAudioCurve->process(tmp, m_increment) > 0.f); silent = (m_silentAudioCurve->processDouble(tmp, m_increment) > 0.f);
} }
int incr = m_stretchCalculator->calculateSingle int incr = m_stretchCalculator->calculateSingle