diff --git a/src/Resampler.cpp b/src/Resampler.cpp index 26633e2..69cde65 100644 --- a/src/Resampler.cpp +++ b/src/Resampler.cpp @@ -92,7 +92,11 @@ D_SRC::D_SRC(Resampler::Quality quality, int channels, int maxBufferSize, SRC_SINC_FASTEST, channels, &err); - //!!! check err, throw + if (err) { + std::cerr << "Resampler::Resampler: failed to create libsamplerate resampler: " + << src_strerror(err) << std::endl; + throw Resampler::ImplementationError; //!!! of course, need to catch this! + } if (maxBufferSize > 0 && m_channels > 1) { //!!! alignment? @@ -153,7 +157,11 @@ D_SRC::resample(const float *const R__ *const R__ in, int err = src_process(m_src, &data); - //!!! check err, respond appropriately + if (err) { + std::cerr << "Resampler::process: libsamplerate error: " + << src_strerror(err) << std::endl; + throw Resampler::ImplementationError; //!!! of course, need to catch this! + } if (m_channels > 1) { for (int i = 0; i < data.output_frames_gen; ++i) { diff --git a/src/Resampler.h b/src/Resampler.h index 40aad5f..3c4af40 100644 --- a/src/Resampler.h +++ b/src/Resampler.h @@ -27,6 +27,7 @@ class Resampler { public: enum Quality { Best, FastestTolerable, Fastest }; + enum Exception { ImplementationError }; /** * Construct a resampler with the given quality level and channel diff --git a/src/StretcherImpl.cpp b/src/StretcherImpl.cpp index cca8c32..04820bf 100644 --- a/src/StretcherImpl.cpp +++ b/src/StretcherImpl.cpp @@ -982,7 +982,7 @@ RubberBandStretcher::Impl::process(const float *const *input, size_t samples, bo bool allConsumed = false; - map consumed; + size_t *consumed = (size_t *)alloca(m_channels * sizeof(size_t)); for (size_t c = 0; c < m_channels; ++c) { consumed[c] = 0; } diff --git a/src/StretcherProcess.cpp b/src/StretcherProcess.cpp index c848376..de1a51d 100644 --- a/src/StretcherProcess.cpp +++ b/src/StretcherProcess.cpp @@ -839,16 +839,21 @@ RubberBandStretcher::Impl::formantShiftChunk(size_t channel) const int sz = m_windowSize; const int hs = m_windowSize/2; + const double denom = sz; - cd.fft->inverseCepstral(mag, dblbuf); - double denom = sz; + cd.fft->inverseCepstral(mag, dblbuf); + for (int i = 0; i < sz; ++i) { dblbuf[i] /= denom; } //!!! calculate this value -- the divisor should be the highest fundamental frequency we expect to find, plus a bit const int cutoff = m_sampleRate / 700; +// const int cutoff = 1000; +// const int cutoff = 20; + +// cerr <<"cutoff = "<< cutoff << ", m_sampleRate/cutoff = " << m_sampleRate/cutoff << ", m_sampleRate/700 = " << m_sampleRate/700 << endl; dblbuf[0] /= 2; dblbuf[cutoff-1] /= 2; @@ -859,6 +864,7 @@ RubberBandStretcher::Impl::formantShiftChunk(size_t channel) cd.fft->forward(dblbuf, envelope, 0); + for (int i = 0; i <= hs; ++i) { envelope[i] = exp(envelope[i]); } @@ -887,6 +893,7 @@ RubberBandStretcher::Impl::formantShiftChunk(size_t channel) for (int i = 0; i <= hs; ++i) { mag[i] *= envelope[i]; +// mag[i] = envelope[i]; } cd.unchanged = false;