Don't do this after we begin; correct ratio

This commit is contained in:
Chris Cannam
2024-05-10 13:09:58 +01:00
parent c6e8d079d9
commit 2119c43287

View File

@@ -182,9 +182,13 @@ void
R3LiveShifter::setPitchScale(double scale) R3LiveShifter::setPitchScale(double scale)
{ {
m_log.log(2, "R3LiveShifter::setPitchScale", scale); m_log.log(2, "R3LiveShifter::setPitchScale", scale);
if (scale == m_pitchScale) return; if (scale == m_pitchScale) return;
m_pitchScale = scale; m_pitchScale = scale;
measureResamplerDelay();
if (m_firstProcess) {
measureResamplerDelay();
}
} }
void void
@@ -242,8 +246,19 @@ R3LiveShifter::measureResamplerDelay()
std::vector<float> inbuf(bs * m_parameters.channels, 0.f); std::vector<float> inbuf(bs * m_parameters.channels, 0.f);
auto outbuf = inbuf; auto outbuf = inbuf;
double inRatio = 1.0;
if (m_expandThenContract) {
if (m_pitchScale < 1.0) {
inRatio = 1.0 / m_pitchScale;
}
} else {
if (m_pitchScale > 1.0) {
inRatio = 1.0 / m_pitchScale;
}
}
int outcount = m_inResampler->resampleInterleaved int outcount = m_inResampler->resampleInterleaved
(outbuf.data(), bs, inbuf.data(), bs, m_pitchScale, false); (outbuf.data(), bs, inbuf.data(), bs, inRatio, false);
m_inResampler->reset(); m_inResampler->reset();