Constrain to +/- 2 octaves (+ semitones) as it's less demanding of block size; minor tidying
This commit is contained in:
@@ -112,7 +112,7 @@ RubberBandPitchShifter::hintsMono[PortCountMono] =
|
||||
LADSPA_HINT_BOUNDED_BELOW |
|
||||
LADSPA_HINT_BOUNDED_ABOVE |
|
||||
LADSPA_HINT_INTEGER,
|
||||
-3.0, 3.0 },
|
||||
-2.0, 2.0 },
|
||||
{ LADSPA_HINT_DEFAULT_MAXIMUM | // crispness
|
||||
LADSPA_HINT_BOUNDED_BELOW |
|
||||
LADSPA_HINT_BOUNDED_ABOVE |
|
||||
@@ -148,7 +148,7 @@ RubberBandPitchShifter::hintsStereo[PortCountStereo] =
|
||||
LADSPA_HINT_BOUNDED_BELOW |
|
||||
LADSPA_HINT_BOUNDED_ABOVE |
|
||||
LADSPA_HINT_INTEGER,
|
||||
-3.0, 3.0 },
|
||||
-2.0, 2.0 },
|
||||
{ LADSPA_HINT_DEFAULT_MAXIMUM | // crispness
|
||||
LADSPA_HINT_BOUNDED_BELOW |
|
||||
LADSPA_HINT_BOUNDED_ABOVE |
|
||||
@@ -241,7 +241,8 @@ RubberBandPitchShifter::RubberBandPitchShifter(int sampleRate, size_t channels)
|
||||
m_currentCrispness(-1),
|
||||
m_currentFormant(false),
|
||||
m_blockSize(1024),
|
||||
m_reserve(1024),
|
||||
m_reserve(8192),
|
||||
m_bufsize(0),
|
||||
m_minfill(0),
|
||||
m_stretcher(new RubberBandStretcher
|
||||
(sampleRate, channels,
|
||||
@@ -257,18 +258,20 @@ RubberBandPitchShifter::RubberBandPitchShifter(int sampleRate, size_t channels)
|
||||
m_delayMixBuffer = new RingBuffer<float> *[m_channels];
|
||||
m_scratch = new float *[m_channels];
|
||||
|
||||
m_bufsize = m_blockSize + m_reserve + 8192;
|
||||
|
||||
for (size_t c = 0; c < m_channels; ++c) {
|
||||
|
||||
m_input[c] = 0;
|
||||
m_output[c] = 0;
|
||||
|
||||
int bufsize = m_blockSize + m_reserve + 8192;
|
||||
m_outputBuffer[c] = new RingBuffer<float>(m_bufsize);
|
||||
m_delayMixBuffer[c] = new RingBuffer<float>(m_bufsize);
|
||||
|
||||
m_outputBuffer[c] = new RingBuffer<float>(bufsize);
|
||||
m_delayMixBuffer[c] = new RingBuffer<float>(bufsize);
|
||||
|
||||
m_scratch[c] = new float[bufsize];
|
||||
for (int i = 0; i < bufsize; ++i) m_scratch[c][i] = 0.f;
|
||||
m_scratch[c] = new float[m_bufsize];
|
||||
for (int i = 0; i < m_bufsize; ++i) {
|
||||
m_scratch[c][i] = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
activateImpl();
|
||||
@@ -367,6 +370,12 @@ RubberBandPitchShifter::activateImpl()
|
||||
m_delayMixBuffer[c]->reset();
|
||||
m_delayMixBuffer[c]->zero(getLatency());
|
||||
}
|
||||
|
||||
for (size_t c = 0; c < m_channels; ++c) {
|
||||
for (int i = 0; i < m_bufsize; ++i) {
|
||||
m_scratch[c][i] = 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
m_minfill = 0;
|
||||
|
||||
@@ -496,7 +505,7 @@ RubberBandPitchShifter::runImpl(unsigned long insamples, unsigned long offset)
|
||||
m_stretcher->setPitchScale(m_ratio);
|
||||
m_prevRatio = m_ratio;
|
||||
}
|
||||
/*
|
||||
|
||||
if (m_latency) {
|
||||
float latencyWas = *m_latency;
|
||||
*m_latency = getLatency();
|
||||
@@ -506,7 +515,7 @@ RubberBandPitchShifter::runImpl(unsigned long insamples, unsigned long offset)
|
||||
<< " to " << *m_latency << endl;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
updateCrispness();
|
||||
updateFormant();
|
||||
|
||||
@@ -535,7 +544,7 @@ RubberBandPitchShifter::runImpl(unsigned long insamples, unsigned long offset)
|
||||
|
||||
int outchunk = avail;
|
||||
if (outchunk > writable) {
|
||||
cerr << "RubberBandPitchShifter::runImpl: buffer is not large enough: chunk = " << outchunk << ", space = " << writable << endl;
|
||||
cerr << "RubberBandPitchShifter::runImpl: buffer is not large enough: size = " << m_outputBuffer[0]->getSize() << ", chunk = " << outchunk << ", space = " << writable << " (buffer contains " << m_outputBuffer[0]->getReadSpace() << " unread)" << endl;
|
||||
outchunk = writable;
|
||||
}
|
||||
|
||||
@@ -556,8 +565,12 @@ RubberBandPitchShifter::runImpl(unsigned long insamples, unsigned long offset)
|
||||
m_outputBuffer[c]->read(&(m_output[c][offset]), chunk);
|
||||
}
|
||||
|
||||
if (m_minfill == 0) {
|
||||
m_minfill = m_outputBuffer[0]->getReadSpace();
|
||||
int fill = m_outputBuffer[0]->getReadSpace();
|
||||
|
||||
// cerr << "fill = " << fill << endl;
|
||||
|
||||
if (fill < m_minfill || m_minfill == 0) {
|
||||
m_minfill = fill;
|
||||
cerr << "minfill = " << m_minfill << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ protected:
|
||||
|
||||
size_t m_blockSize;
|
||||
size_t m_reserve;
|
||||
size_t m_bufsize;
|
||||
size_t m_minfill;
|
||||
|
||||
RubberBand::RubberBandStretcher *m_stretcher;
|
||||
|
||||
@@ -64,7 +64,7 @@ const size_t
|
||||
RubberBandStretcher::Impl::m_defaultFftSize = 2048;
|
||||
|
||||
int
|
||||
RubberBandStretcher::Impl::m_defaultDebugLevel = 0;
|
||||
RubberBandStretcher::Impl::m_defaultDebugLevel = 2;
|
||||
|
||||
static bool _initialised = false;
|
||||
|
||||
@@ -544,8 +544,8 @@ RubberBandStretcher::Impl::calculateSizes()
|
||||
// ratio) for any chunk.
|
||||
|
||||
if (m_debugLevel > 0) {
|
||||
cerr << "configure: time ratio = " << m_timeRatio << ", pitch scale = " << m_pitchScale << ", effective ratio = " << getEffectiveRatio() << endl;
|
||||
cerr << "configure: analysis window size = " << m_aWindowSize << ", synthesis window size = " << m_sWindowSize << ", fft size = " << m_fftSize << ", increment = " << m_increment << " (approx output increment = " << int(lrint(m_increment * getEffectiveRatio())) << ")" << endl;
|
||||
cerr << "calculateSizes: time ratio = " << m_timeRatio << ", pitch scale = " << m_pitchScale << ", effective ratio = " << getEffectiveRatio() << endl;
|
||||
cerr << "calculateSizes: analysis window size = " << m_aWindowSize << ", synthesis window size = " << m_sWindowSize << ", fft size = " << m_fftSize << ", increment = " << m_increment << " (approx output increment = " << int(lrint(m_increment * getEffectiveRatio())) << ")" << endl;
|
||||
}
|
||||
|
||||
if (std::max(m_aWindowSize, m_sWindowSize) > m_maxProcessSize) {
|
||||
@@ -575,15 +575,17 @@ RubberBandStretcher::Impl::calculateSizes()
|
||||
}
|
||||
|
||||
if (m_debugLevel > 0) {
|
||||
cerr << "configure: outbuf size = " << m_outbufSize << endl;
|
||||
cerr << "calculateSizes: outbuf size = " << m_outbufSize << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RubberBandStretcher::Impl::configure()
|
||||
{
|
||||
// std::cerr << "configure[" << this << "]: realtime = " << m_realtime << ", pitch scale = "
|
||||
// << m_pitchScale << ", channels = " << m_channels << std::endl;
|
||||
if (m_debugLevel > 0) {
|
||||
std::cerr << "configure[" << this << "]: realtime = " << m_realtime << ", pitch scale = "
|
||||
<< m_pitchScale << ", channels = " << m_channels << std::endl;
|
||||
}
|
||||
|
||||
size_t prevFftSize = m_fftSize;
|
||||
size_t prevAWindowSize = m_aWindowSize;
|
||||
@@ -745,7 +747,7 @@ RubberBandStretcher::Impl::configure()
|
||||
|
||||
// if (!m_realtime) {
|
||||
if (m_debugLevel > 1) {
|
||||
cerr << "Not real time mode: prefilling" << endl;
|
||||
cerr << "Not real time mode: prefilling with " << m_aWindowSize/2 << " samples" << endl;
|
||||
}
|
||||
for (size_t c = 0; c < m_channels; ++c) {
|
||||
m_channelData[c]->reset();
|
||||
@@ -1373,12 +1375,12 @@ RubberBandStretcher::Impl::process(const float *const *input, size_t samples, bo
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_debugLevel > 2) {
|
||||
if (m_debugLevel > 1) {
|
||||
if (!allConsumed) cerr << "process looping" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_debugLevel > 2) {
|
||||
if (m_debugLevel > 1) {
|
||||
cerr << "process returning" << endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ RubberBandStretcher::Impl::processChunks(size_t c, bool &any, bool &last)
|
||||
while (!last) {
|
||||
|
||||
if (!testInbufReadSpace(c)) {
|
||||
if (m_debugLevel > 2) {
|
||||
if (m_debugLevel > 1) {
|
||||
cerr << "processChunks: out of input" << endl;
|
||||
}
|
||||
break;
|
||||
@@ -349,7 +349,7 @@ RubberBandStretcher::Impl::processOneChunk()
|
||||
|
||||
for (size_t c = 0; c < m_channels; ++c) {
|
||||
if (!testInbufReadSpace(c)) {
|
||||
if (m_debugLevel > 2) {
|
||||
if (m_debugLevel > 1) {
|
||||
cerr << "processOneChunk: out of input" << endl;
|
||||
}
|
||||
return false;
|
||||
@@ -404,7 +404,7 @@ RubberBandStretcher::Impl::testInbufReadSpace(size_t c)
|
||||
if (!m_threaded) {
|
||||
#endif
|
||||
if (m_debugLevel > 1) {
|
||||
cerr << "WARNING: RubberBandStretcher: read space < chunk size ("
|
||||
cerr << "Note: RubberBandStretcher: read space < chunk size ("
|
||||
<< inbuf.getReadSpace() << " < " << m_aWindowSize
|
||||
<< ") when not all input written, on processChunks for channel " << c << endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user