diff --git a/ladspa-lv2/RubberBandLivePitchShifter.cpp b/ladspa-lv2/RubberBandLivePitchShifter.cpp index 273700a..b3ac3ea 100644 --- a/ladspa-lv2/RubberBandLivePitchShifter.cpp +++ b/ladspa-lv2/RubberBandLivePitchShifter.cpp @@ -267,7 +267,7 @@ RubberBandLivePitchShifter::RubberBandLivePitchShifter(int sampleRate, size_t ch m_shifter(new RubberBandLiveShifter (sampleRate, channels, RubberBandLiveShifter::OptionWindowLong | - RubberBandLiveShifter::OptionPitchModeB | + RubberBandLiveShifter::OptionPitchModeA | RubberBandLiveShifter::OptionChannelsTogether)), m_sampleRate(sampleRate), m_channels(channels), diff --git a/src/common/BQResampler.cpp b/src/common/BQResampler.cpp index 153f9cc..ab216f3 100644 --- a/src/common/BQResampler.cpp +++ b/src/common/BQResampler.cpp @@ -201,6 +201,13 @@ BQResampler::resampleInterleaved(float *const out, } } + if (i < incount_samples) { + std::cerr << "only used " << i << " of " << incount_samples + << " samples to generate output count " << o + << " (outspace_samples was " << outspace_samples << ")" + << std::endl; + } + int fbufsize = m_fade->buffer.size(); int fi = 0, fo = 0; while (fo < o && m_fade_count > 0) { diff --git a/src/finer/Guide.h b/src/finer/Guide.h index cf4f686..93f7e40 100644 --- a/src/finer/Guide.h +++ b/src/finer/Guide.h @@ -552,11 +552,12 @@ protected: if (guidance.phaseReset.f0 < 100.0) { guidance.phaseReset.f0 = 0.0; } - -// if (guidance.phaseReset.f0 > 0.0) { -// std::cout << unityCount << ": f0 = " << guidance.phaseReset.f0 -// << ", f1 = " << guidance.phaseReset.f1 << std::endl; -// } +/* + if (guidance.phaseReset.f0 > 0.0) { + std::cout << "unity: f0 = " << guidance.phaseReset.f0 + << ", f1 = " << guidance.phaseReset.f1 << std::endl; + } +*/ } bool checkPotentialKick(const process_t *const magnitudes, diff --git a/src/finer/R3LiveShifter.cpp b/src/finer/R3LiveShifter.cpp index cd203c6..565a7a8 100644 --- a/src/finer/R3LiveShifter.cpp +++ b/src/finer/R3LiveShifter.cpp @@ -341,7 +341,7 @@ R3LiveShifter::shift(const float *const *input, float *const *output) } } - int requiredInOutbuf = int(ceil(incount / outRatio)); + int requiredInOutbuf = 1 + int(ceil(incount / outRatio)); generate(requiredInOutbuf); int got = readOut(output, incount, 0); @@ -615,6 +615,8 @@ R3LiveShifter::readOut(float *const *output, int outcount, int origin) int fromOutbuf = int(floor(outcount / outRatio)); + m_log.log(2, "R3LiveShifter::readOut: origin and fromOutbuf", origin, fromOutbuf); + if (fromOutbuf == 0) { fromOutbuf = 1; } @@ -630,9 +632,6 @@ R3LiveShifter::readOut(float *const *output, int outcount, int origin) } got = std::min(got, std::max(gotHere, 0)); } - - m_channelAssembly.resampled[c] = cd->resampled.data(); - m_channelAssembly.mixdown[c] = output[c] + origin; } m_log.log(2, "R3LiveShifter::readOut: requested and got from outbufs", fromOutbuf, got); @@ -641,6 +640,13 @@ R3LiveShifter::readOut(float *const *output, int outcount, int origin) int resampledCount = 0; if (got > 0) { + + for (int c = 0; c < m_parameters.channels; ++c) { + auto &cd = m_channelData.at(c); + m_channelAssembly.resampled[c] = cd->resampled.data(); + m_channelAssembly.mixdown[c] = output[c] + origin; + } + resampledCount = m_outResampler->resample (m_channelAssembly.mixdown.data(), outcount, @@ -648,6 +654,17 @@ R3LiveShifter::readOut(float *const *output, int outcount, int origin) got, outRatio, false); + + if (useMidSide()) { + for (int i = 0; i < resampledCount; ++i) { + float m = output[0][origin + i]; + float s = output[1][origin + i]; + float l = m + s; + float r = m - s; + output[0][origin + i] = l; + output[1][origin + i] = r; + } + } } m_log.log(2, "R3LiveShifter::readOut: resampled to", resampledCount); @@ -665,26 +682,18 @@ R3LiveShifter::readOut(float *const *output, int outcount, int origin) m_log.log(2, "R3LiveShifter::readOut: resampler left us short on first process, pre-padding output: expected and obtained", outcount, resampledCount); int prepad = outcount - resampledCount; for (int c = 0; c < m_parameters.channels; ++c) { - v_move(m_channelAssembly.mixdown.data()[c] + prepad, - m_channelAssembly.mixdown.data()[c], resampledCount); - v_zero(m_channelAssembly.mixdown.data()[c], prepad); + v_move(output[c] + origin + prepad, + output[c] + origin, + resampledCount); + v_zero(output[c] + origin, prepad); } resampledCount = outcount; } else { m_log.log(0, "R3LiveShifter::readOut: WARNING: Failed to obtain enough samples from resampler", resampledCount, outcount); } } - - if (useMidSide()) { - for (int i = 0; i < resampledCount; ++i) { - float m = output[0][i]; - float s = output[1][i]; - float l = m + s; - float r = m - s; - output[0][i] = l; - output[1][i] = r; - } - } + + m_log.log(2, "R3LiveShifter::readOut: returning", resampledCount); return resampledCount; } diff --git a/src/test/TestLiveShifter.cpp b/src/test/TestLiveShifter.cpp index 1e5843c..7e1cd23 100644 --- a/src/test/TestLiveShifter.cpp +++ b/src/test/TestLiveShifter.cpp @@ -52,6 +52,8 @@ static void check_sinusoid_unchanged(int n, int rate, float freq, RubberBandLiveShifter shifter(rate, 1, options); + shifter.setPitchScale(2.66968); + int blocksize = shifter.getBlockSize(); BOOST_TEST(blocksize == 512); @@ -118,7 +120,7 @@ BOOST_AUTO_TEST_CASE(sinusoid_unchanged_mode_a) RubberBandLiveShifter::OptionPitchModeA; int n = 100000; - check_sinusoid_unchanged(n, 44100, 440.f, options, false); + check_sinusoid_unchanged(n, 44100, 440.f, options, true); check_sinusoid_unchanged(n, 48000, 260.f, options, false); } @@ -128,7 +130,7 @@ BOOST_AUTO_TEST_CASE(sinusoid_unchanged_mode_b) RubberBandLiveShifter::OptionPitchModeB; int n = 100000; - check_sinusoid_unchanged(n, 44100, 440.f, options, true); + check_sinusoid_unchanged(n, 44100, 440.f, options, false); check_sinusoid_unchanged(n, 48000, 260.f, options, false); }