* Various tweaks to improve performance at large ratios
This commit is contained in:
@@ -303,7 +303,8 @@ RubberBandStretcher::Impl::calculateSizes()
|
||||
inputIncrement /= 2;
|
||||
outputIncrement = lrint(ceil(inputIncrement * r));
|
||||
}
|
||||
blockSize = std::max(blockSize, roundUp(outputIncrement * 4.5));
|
||||
blockSize = std::max(blockSize, roundUp(outputIncrement * 6));
|
||||
if (r > 5) while (blockSize < 8192) blockSize *= 2;
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -327,6 +328,7 @@ RubberBandStretcher::Impl::calculateSizes()
|
||||
inputIncrement = int(outputIncrement / r);
|
||||
}
|
||||
blockSize = std::max(blockSize, roundUp(outputIncrement * 6));
|
||||
if (r > 5) while (blockSize < 8192) blockSize *= 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +393,7 @@ RubberBandStretcher::Impl::calculateSizes()
|
||||
//necessary. clearly something wrong in our calculations... or do
|
||||
//we just need to ensure client calls setMaxProcessBlockSize?
|
||||
if (!m_realtime && !m_threaded) {
|
||||
//!!! m_outbufSize = m_outbufSize * 2;
|
||||
m_outbufSize = m_outbufSize * 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -481,9 +481,27 @@ RubberBandStretcher::Impl::modifyChunk(size_t channel, size_t outputIncrement,
|
||||
|
||||
cd.freqPeak[0] = 0;
|
||||
|
||||
size_t limit0 = lrint((m_freq0 * m_blockSize) / rate);
|
||||
float freq0 = m_freq0;
|
||||
|
||||
// As the stretch ratio increases, so the frequency thresholds
|
||||
// for phase lamination should increase. Beyond a ratio of
|
||||
// about 1.5, the threshold should be about 1200Hz; beyond a
|
||||
// ratio of 2, we probably want no lamination to happen at all
|
||||
// by default. This calculation aims for that.
|
||||
|
||||
//!!! we should only do this if asked to -- and when not
|
||||
//setting f0,f1,f2 explicitly
|
||||
float r = getEffectiveRatio();
|
||||
if (r > 1) {
|
||||
float rf0 = 600 + (600 * ((r-1)*(r-1)*2));
|
||||
// std::cerr << "ratio = " << r << ", rf0 = " << rf0 << std::endl;
|
||||
freq0 = std::max(freq0, rf0);
|
||||
}
|
||||
|
||||
size_t limit0 = lrint((freq0 * m_blockSize) / rate);
|
||||
size_t limit1 = lrint((m_freq1 * m_blockSize) / rate);
|
||||
size_t limit2 = lrint((m_freq2 * m_blockSize) / rate);
|
||||
|
||||
size_t range = 0;
|
||||
|
||||
if (limit1 < limit0) limit1 = limit0;
|
||||
@@ -700,6 +718,11 @@ RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, boo
|
||||
cd.resamplebuf = new float[cd.resamplebufSize];
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
if (m_threaded) {
|
||||
m_resamplerMutex.lock();
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t outframes = cd.resampler->resample(&cd.accumulator,
|
||||
&cd.resamplebuf,
|
||||
@@ -707,6 +730,11 @@ RubberBandStretcher::Impl::writeChunk(size_t channel, size_t shiftIncrement, boo
|
||||
1.0 / m_pitchScale,
|
||||
last);
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
if (m_threaded) {
|
||||
m_resamplerMutex.unlock();
|
||||
}
|
||||
#endif
|
||||
|
||||
writeOutput(*cd.outbuf, cd.resamplebuf,
|
||||
outframes, cd.outCount, theoreticalOut);
|
||||
|
||||
@@ -183,12 +183,12 @@ RubberBandPitchShifter::RubberBandPitchShifter(int sampleRate, size_t channels)
|
||||
m_extraLatency(8192), //!!! this should be at least the maximum possible displacement from linear at input rates, divided by the pitch scale factor. It could be very large
|
||||
m_stretcher(new RubberBand::RubberBandStretcher
|
||||
(sampleRate, channels,
|
||||
RubberBand::RubberBandStretcher::OptionProcessRealTime |
|
||||
RubberBand::RubberBandStretcher::OptionStretchPrecise |
|
||||
RubberBand::RubberBandStretcher::OptionProcessRealTime)),// |
|
||||
// RubberBand::RubberBandStretcher::OptionStretchPrecise |
|
||||
// RubberBand::RubberBandStretcher::OptionTransientsSmooth |
|
||||
RubberBand::RubberBandStretcher::OptionTransientsCrisp |
|
||||
RubberBand::RubberBandStretcher::OptionPhasePeakLocked |
|
||||
RubberBand::RubberBandStretcher::OptionThreadingNone)),
|
||||
// RubberBand::RubberBandStretcher::OptionTransientsCrisp |
|
||||
// RubberBand::RubberBandStretcher::OptionPhasePeakLocked |
|
||||
// RubberBand::RubberBandStretcher::OptionThreadingNone)),
|
||||
m_sampleRate(sampleRate),
|
||||
m_channels(channels)
|
||||
{
|
||||
|
||||
@@ -376,7 +376,7 @@ int main(int argc, char **argv)
|
||||
float value = obf[c][i];
|
||||
if (fabsf(value) > outpeak) outpeak = fabsf(value);
|
||||
outsum += value * value;
|
||||
value *= 0.75;
|
||||
value *= 0.75;//!!!
|
||||
if (value > 1.f) value = 1.f;
|
||||
if (value < -1.f) value = -1.f;
|
||||
fobf[i * channels + c] = value;
|
||||
|
||||
Reference in New Issue
Block a user