Remove the alternate pitch method. It isn't as reliable in avoiding artifacts and it's quite a bit of overhead to test.
This commit is contained in:
@@ -266,7 +266,6 @@ RubberBandLivePitchShifter::RubberBandLivePitchShifter(int sampleRate, size_t ch
|
|||||||
m_currentFormant(false),
|
m_currentFormant(false),
|
||||||
m_shifter(new RubberBandLiveShifter
|
m_shifter(new RubberBandLiveShifter
|
||||||
(sampleRate, channels,
|
(sampleRate, channels,
|
||||||
RubberBandLiveShifter::OptionPitchMethodStandard |
|
|
||||||
RubberBandLiveShifter::OptionChannelsTogether)),
|
RubberBandLiveShifter::OptionChannelsTogether)),
|
||||||
m_sampleRate(sampleRate),
|
m_sampleRate(sampleRate),
|
||||||
m_channels(channels),
|
m_channels(channels),
|
||||||
|
|||||||
@@ -102,9 +102,6 @@ public:
|
|||||||
OptionFormantShifted = 0x00000000,
|
OptionFormantShifted = 0x00000000,
|
||||||
OptionFormantPreserved = 0x01000000,
|
OptionFormantPreserved = 0x01000000,
|
||||||
|
|
||||||
OptionPitchMethodStandard = 0x00000000,
|
|
||||||
OptionPitchMethodAlternate = 0x02000000,
|
|
||||||
|
|
||||||
OptionChannelsApart = 0x00000000,
|
OptionChannelsApart = 0x00000000,
|
||||||
OptionChannelsTogether = 0x10000000,
|
OptionChannelsTogether = 0x10000000,
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ R3LiveShifter::R3LiveShifter(Parameters parameters, Log log) :
|
|||||||
m_useReadahead(false),
|
m_useReadahead(false),
|
||||||
m_prevInhop(m_limits.maxInhopWithReadahead / 2),
|
m_prevInhop(m_limits.maxInhopWithReadahead / 2),
|
||||||
m_prevOuthop(m_prevInhop),
|
m_prevOuthop(m_prevInhop),
|
||||||
m_expandThenContract(false),
|
|
||||||
m_firstProcess(true),
|
m_firstProcess(true),
|
||||||
m_unityCount(0)
|
m_unityCount(0)
|
||||||
{
|
{
|
||||||
@@ -71,11 +70,6 @@ R3LiveShifter::initialise()
|
|||||||
m_useReadahead = true;
|
m_useReadahead = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_parameters.options & RubberBandLiveShifter::OptionPitchMethodAlternate)) {
|
|
||||||
m_log.log(1, "R3LiveShifter::R3LiveShifter: expand-then-contract enabled");
|
|
||||||
m_expandThenContract = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
double maxClassifierFrequency = 16000.0;
|
double maxClassifierFrequency = 16000.0;
|
||||||
if (maxClassifierFrequency > m_parameters.sampleRate/2) {
|
if (maxClassifierFrequency > m_parameters.sampleRate/2) {
|
||||||
maxClassifierFrequency = m_parameters.sampleRate/2;
|
maxClassifierFrequency = m_parameters.sampleRate/2;
|
||||||
@@ -247,15 +241,9 @@ R3LiveShifter::measureResamplerDelay()
|
|||||||
auto outbuf = inbuf;
|
auto outbuf = inbuf;
|
||||||
|
|
||||||
double inRatio = 1.0;
|
double inRatio = 1.0;
|
||||||
if (m_expandThenContract) {
|
|
||||||
if (m_pitchScale < 1.0) {
|
|
||||||
inRatio = 1.0 / m_pitchScale;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (m_pitchScale > 1.0) {
|
if (m_pitchScale > 1.0) {
|
||||||
inRatio = 1.0 / m_pitchScale;
|
inRatio = 1.0 / m_pitchScale;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int outcount = m_inResampler->resampleInterleaved
|
int outcount = m_inResampler->resampleInterleaved
|
||||||
(outbuf.data(), bs, inbuf.data(), bs, inRatio, false);
|
(outbuf.data(), bs, inbuf.data(), bs, inRatio, false);
|
||||||
@@ -290,20 +278,12 @@ R3LiveShifter::getStartDelay() const
|
|||||||
{
|
{
|
||||||
int fixed = getWindowSourceSize() / 2 + m_resamplerDelay * 2;
|
int fixed = getWindowSourceSize() / 2 + m_resamplerDelay * 2;
|
||||||
int variable = getWindowSourceSize() / 2;
|
int variable = getWindowSourceSize() / 2;
|
||||||
if (m_expandThenContract) {
|
|
||||||
if (m_pitchScale < 1.0) {
|
|
||||||
return size_t(fixed + ceil(variable * m_pitchScale));
|
|
||||||
} else {
|
|
||||||
return size_t(fixed + ceil(variable / m_pitchScale));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (m_pitchScale < 1.0) {
|
if (m_pitchScale < 1.0) {
|
||||||
return size_t(fixed + ceil(variable / m_pitchScale));
|
return size_t(fixed + ceil(variable / m_pitchScale));
|
||||||
} else {
|
} else {
|
||||||
return size_t(fixed + ceil(variable * m_pitchScale));
|
return size_t(fixed + ceil(variable * m_pitchScale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
R3LiveShifter::getChannelCount() const
|
R3LiveShifter::getChannelCount() const
|
||||||
@@ -353,14 +333,10 @@ R3LiveShifter::shift(const float *const *input, float *const *output)
|
|||||||
|
|
||||||
int pad = 0;
|
int pad = 0;
|
||||||
if (m_firstProcess) {
|
if (m_firstProcess) {
|
||||||
if (m_expandThenContract) {
|
|
||||||
pad = getWindowSourceSize() / 2;
|
|
||||||
} else {
|
|
||||||
pad = getWindowSourceSize();
|
pad = getWindowSourceSize();
|
||||||
if (m_pitchScale > 1.0) {
|
if (m_pitchScale > 1.0) {
|
||||||
pad = int(ceil(pad * m_pitchScale));
|
pad = int(ceil(pad * m_pitchScale));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
m_log.log(2, "R3LiveShifter::shift: extending input with pre-pad", incount, pad);
|
m_log.log(2, "R3LiveShifter::shift: extending input with pre-pad", incount, pad);
|
||||||
for (int c = 0; c < m_parameters.channels; ++c) {
|
for (int c = 0; c < m_parameters.channels; ++c) {
|
||||||
m_channelData[c]->inbuf->zero(pad);
|
m_channelData[c]->inbuf->zero(pad);
|
||||||
@@ -371,15 +347,9 @@ R3LiveShifter::shift(const float *const *input, float *const *output)
|
|||||||
|
|
||||||
double outRatio = 1.0;
|
double outRatio = 1.0;
|
||||||
|
|
||||||
if (m_expandThenContract) {
|
|
||||||
if (m_pitchScale > 1.0) {
|
|
||||||
outRatio = 1.0 / m_pitchScale;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (m_pitchScale < 1.0) {
|
if (m_pitchScale < 1.0) {
|
||||||
outRatio = 1.0 / m_pitchScale;
|
outRatio = 1.0 / m_pitchScale;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int requiredInOutbuf = int(ceil(incount / outRatio));
|
int requiredInOutbuf = int(ceil(incount / outRatio));
|
||||||
generate(requiredInOutbuf);
|
generate(requiredInOutbuf);
|
||||||
@@ -440,16 +410,9 @@ R3LiveShifter::readIn(const float *const *input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
double inRatio = 1.0;
|
double inRatio = 1.0;
|
||||||
|
|
||||||
if (m_expandThenContract) {
|
|
||||||
if (m_pitchScale < 1.0) {
|
|
||||||
inRatio = 1.0 / m_pitchScale;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (m_pitchScale > 1.0) {
|
if (m_pitchScale > 1.0) {
|
||||||
inRatio = 1.0 / m_pitchScale;
|
inRatio = 1.0 / m_pitchScale;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_log.log(2, "R3LiveShifter::readIn: ratio", inRatio);
|
m_log.log(2, "R3LiveShifter::readIn: ratio", inRatio);
|
||||||
|
|
||||||
@@ -639,16 +602,9 @@ int
|
|||||||
R3LiveShifter::readOut(float *const *output, int outcount)
|
R3LiveShifter::readOut(float *const *output, int outcount)
|
||||||
{
|
{
|
||||||
double outRatio = 1.0;
|
double outRatio = 1.0;
|
||||||
|
|
||||||
if (m_expandThenContract) {
|
|
||||||
if (m_pitchScale > 1.0) {
|
|
||||||
outRatio = 1.0 / m_pitchScale;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (m_pitchScale < 1.0) {
|
if (m_pitchScale < 1.0) {
|
||||||
outRatio = 1.0 / m_pitchScale;
|
outRatio = 1.0 / m_pitchScale;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_log.log(2, "R3LiveShifter::readOut: outcount and ratio", outcount, outRatio);
|
m_log.log(2, "R3LiveShifter::readOut: outcount and ratio", outcount, outRatio);
|
||||||
|
|
||||||
|
|||||||
@@ -315,7 +315,6 @@ protected:
|
|||||||
bool m_useReadahead;
|
bool m_useReadahead;
|
||||||
int m_prevInhop;
|
int m_prevInhop;
|
||||||
int m_prevOuthop;
|
int m_prevOuthop;
|
||||||
bool m_expandThenContract; // otherwise contract then expand
|
|
||||||
bool m_firstProcess;
|
bool m_firstProcess;
|
||||||
uint32_t m_unityCount;
|
uint32_t m_unityCount;
|
||||||
|
|
||||||
|
|||||||
@@ -230,34 +230,18 @@ static void check_sinusoid_shifted(int n, int rate, float freq, float shift,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(sinusoid_unchanged_mode_a)
|
BOOST_AUTO_TEST_CASE(sinusoid_unchanged)
|
||||||
{
|
{
|
||||||
RubberBandLiveShifter::Options options =
|
|
||||||
RubberBandLiveShifter::OptionPitchMethodStandard;
|
|
||||||
int n = 20000;
|
int n = 20000;
|
||||||
|
check_sinusoid_unchanged(n, 44100, 440.f, 0, false);
|
||||||
check_sinusoid_unchanged(n, 44100, 440.f, options, false);
|
check_sinusoid_unchanged(n, 48000, 260.f, 0, false);
|
||||||
check_sinusoid_unchanged(n, 48000, 260.f, options, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(sinusoid_unchanged_mode_b)
|
BOOST_AUTO_TEST_CASE(sinusoid_down_octave)
|
||||||
{
|
{
|
||||||
RubberBandLiveShifter::Options options =
|
|
||||||
RubberBandLiveShifter::OptionPitchMethodAlternate;
|
|
||||||
int n = 20000;
|
int n = 20000;
|
||||||
|
check_sinusoid_shifted(n, 44100, 440.f, 0.5f, 0, true);
|
||||||
check_sinusoid_unchanged(n, 44100, 440.f, options, false);
|
// check_sinusoid_shifted(n, 48000, 260.f, 0.5f, 0, false);
|
||||||
check_sinusoid_unchanged(n, 48000, 260.f, options, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(sinusoid_down_octave_mode_a)
|
|
||||||
{
|
|
||||||
RubberBandLiveShifter::Options options =
|
|
||||||
RubberBandLiveShifter::OptionPitchMethodStandard;
|
|
||||||
int n = 20000;
|
|
||||||
|
|
||||||
check_sinusoid_shifted(n, 44100, 440.f, 0.5f, options, true);
|
|
||||||
// check_sinusoid_shifted(n, 48000, 260.f, 0.5f, options, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|||||||
Reference in New Issue
Block a user