Apply start skip. Still work to be done
This commit is contained in:
@@ -40,7 +40,7 @@ R3StretcherImpl::R3StretcherImpl(Parameters parameters,
|
|||||||
m_channelAssembly(m_parameters.channels),
|
m_channelAssembly(m_parameters.channels),
|
||||||
m_inhop(1),
|
m_inhop(1),
|
||||||
m_prevOuthop(1),
|
m_prevOuthop(1),
|
||||||
m_totalOutCount(0),
|
m_startSkip(0),
|
||||||
m_draining(false)
|
m_draining(false)
|
||||||
{
|
{
|
||||||
double maxClassifierFrequency = 16000.0;
|
double maxClassifierFrequency = 16000.0;
|
||||||
@@ -117,17 +117,18 @@ R3StretcherImpl::R3StretcherImpl(Parameters parameters,
|
|||||||
m_parameters.logger("WARNING: std::atomic<double> is not lock-free");
|
m_parameters.logger("WARNING: std::atomic<double> is not lock-free");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pre-fill to half of the longest frame. The centre of the first
|
// Pad to half of the longest frame. As with R2, in real-time mode
|
||||||
// processing frame should be the first sample of the audio. As
|
// we don't do this -- it's better to start with a swoosh than
|
||||||
// with R2, in real-time mode we don't do this -- it's better to
|
// introduce more latency, and we don't want gaps when the ratio
|
||||||
// start with a swoosh than introduce more latency, and we don't
|
// changes.
|
||||||
// want gaps when the ratio changes.
|
|
||||||
|
|
||||||
if (!(m_parameters.options & RubberBandStretcher::OptionProcessRealTime)) {
|
if (!(m_parameters.options & RubberBandStretcher::OptionProcessRealTime)) {
|
||||||
|
int pad = m_guideConfiguration.longestFftSize / 2;
|
||||||
for (int c = 0; c < m_parameters.channels; ++c) {
|
for (int c = 0; c < m_parameters.channels; ++c) {
|
||||||
m_channelData[c]->inbuf->zero
|
m_channelData[c]->inbuf->zero(pad);
|
||||||
(m_guideConfiguration.longestFftSize / 2);
|
|
||||||
}
|
}
|
||||||
|
// By the time we skip this later we will have resampled
|
||||||
|
m_startSkip = int(round(pad / m_pitchScale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,27 +462,12 @@ R3StretcherImpl::consume()
|
|||||||
|
|
||||||
// Emit
|
// Emit
|
||||||
|
|
||||||
// In non-RT mode, we don't want to write the first startSkip
|
|
||||||
// samples, because the first chunk is centred on the start of
|
|
||||||
// the output. In RT mode we didn't apply any pre-padding, so
|
|
||||||
// we don't want to remove any here.
|
|
||||||
|
|
||||||
int startSkip = 0;
|
|
||||||
if (!(m_parameters.options & RubberBandStretcher::OptionProcessRealTime)) {
|
|
||||||
double factor = m_pitchScale * 0.5;
|
|
||||||
startSkip = int(ceil(m_guideConfiguration.longestFftSize * factor));
|
|
||||||
}
|
|
||||||
|
|
||||||
//!!! now actually do the skipping
|
|
||||||
|
|
||||||
for (int c = 0; c < channels; ++c) {
|
for (int c = 0; c < channels; ++c) {
|
||||||
auto &cd = m_channelData.at(c);
|
auto &cd = m_channelData.at(c);
|
||||||
if (m_resampler) {
|
if (m_resampler) {
|
||||||
cd->outbuf->write(cd->resampled.data(), resampledCount);
|
cd->outbuf->write(cd->resampled.data(), resampledCount);
|
||||||
m_totalOutCount += resampledCount;
|
|
||||||
} else {
|
} else {
|
||||||
cd->outbuf->write(cd->mixdown.data(), outhop);
|
cd->outbuf->write(cd->mixdown.data(), outhop);
|
||||||
m_totalOutCount += outhop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int readSpace = cd->inbuf->getReadSpace();
|
int readSpace = cd->inbuf->getReadSpace();
|
||||||
@@ -493,6 +479,15 @@ R3StretcherImpl::consume()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_startSkip > 0) {
|
||||||
|
int toSkip = std::min
|
||||||
|
(m_startSkip, m_channelData.at(0)->outbuf->getReadSpace());
|
||||||
|
for (int c = 0; c < channels; ++c) {
|
||||||
|
m_channelData.at(c)->outbuf->skip(toSkip);
|
||||||
|
}
|
||||||
|
m_startSkip -= toSkip;
|
||||||
|
}
|
||||||
|
|
||||||
m_prevInhop = inhop;
|
m_prevInhop = inhop;
|
||||||
m_prevOuthop = outhop;
|
m_prevOuthop = outhop;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ protected:
|
|||||||
std::atomic<int> m_inhop;
|
std::atomic<int> m_inhop;
|
||||||
int m_prevInhop;
|
int m_prevInhop;
|
||||||
int m_prevOuthop;
|
int m_prevOuthop;
|
||||||
int64_t m_totalOutCount;
|
int m_startSkip;
|
||||||
bool m_draining;
|
bool m_draining;
|
||||||
|
|
||||||
void consume();
|
void consume();
|
||||||
|
|||||||
Reference in New Issue
Block a user