M ladspa-lv2/RubberBandLivePitchShifter.cpp +1 -2
@@ 266,8 266,7 @@ RubberBandLivePitchShifter::RubberBandLi
m_currentFormant(false),
m_shifter(new RubberBandLiveShifter
(sampleRate, channels,
- RubberBandLiveShifter::OptionWindowLong |
- RubberBandLiveShifter::OptionPitchModeA |
+ RubberBandLiveShifter::OptionPitchMethodStandard |
RubberBandLiveShifter::OptionChannelsTogether)),
m_sampleRate(sampleRate),
m_channels(channels),
M ladspa-lv2/RubberBandPitchShifter.cpp +0 -2
@@ 642,7 642,6 @@ RubberBandPitchShifter::runImpl(uint32_t
const int samples = insamples;
int processed = 0;
- size_t outTotal = 0;
while (processed < samples) {
@@ 671,7 670,6 @@ RubberBandPitchShifter::runImpl(uint32_t
}
size_t actual = m_stretcher->retrieve(m_scratch, outchunk);
- outTotal += actual;
for (size_t c = 0; c < m_channels; ++c) {
m_outputBuffer[c]->write(m_scratch[c], actual);
M ladspa-lv2/RubberBandR3PitchShifter.cpp +0 -2
@@ 593,7 593,6 @@ RubberBandR3PitchShifter::runImpl(uint32
const int samples = insamples;
int processed = 0;
- size_t outTotal = 0;
while (processed < samples) {
@@ 622,7 621,6 @@ RubberBandR3PitchShifter::runImpl(uint32
}
size_t actual = m_stretcher->retrieve(m_scratch, outchunk);
- outTotal += actual;
for (size_t c = 0; c < m_channels; ++c) {
m_outputBuffer[c]->write(m_scratch[c], actual);
M rubberband/RubberBandLiveShifter.h +2 -4
@@ 98,14 98,12 @@ public:
enum Option {
OptionWindowShort = 0x00000000,
OptionWindowMedium = 0x00100000,
- OptionWindowLong = 0x00200000,
OptionFormantShifted = 0x00000000,
OptionFormantPreserved = 0x01000000,
- //!!! Rename and document
- OptionPitchModeA = 0x00000000,
- OptionPitchModeB = 0x02000000,
+ OptionPitchMethodStandard = 0x00000000,
+ OptionPitchMethodAlternate = 0x02000000,
OptionChannelsApart = 0x00000000,
OptionChannelsTogether = 0x10000000,
M src/finer/R3LiveShifter.cpp +25 -28
@@ 37,8 37,7 @@ R3LiveShifter::R3LiveShifter(Parameters
m_pitchScale(1.0),
m_formantScale(0.0),
m_guide(Guide::Parameters
- (m_parameters.sampleRate,
- !(m_parameters.options & RubberBandLiveShifter::OptionWindowLong)),
+ (m_parameters.sampleRate, true),
m_log),
m_guideConfiguration(m_guide.getConfiguration()),
m_channelAssembly(m_parameters.channels),
@@ 46,7 45,7 @@ R3LiveShifter::R3LiveShifter(Parameters
m_useReadahead(false),
m_prevInhop(m_limits.maxInhopWithReadahead / 2),
m_prevOuthop(m_prevInhop),
- m_contractThenExpand(false),
+ m_expandThenContract(false),
m_firstProcess(true),
m_unityCount(0)
{
@@ 67,15 66,14 @@ R3LiveShifter::initialise()
m_log.log(1, "R3LiveShifter::R3LiveShifter: multi window enabled");
}
- if ((m_parameters.options & RubberBandLiveShifter::OptionWindowMedium) ||
- (m_parameters.options & RubberBandLiveShifter::OptionWindowLong)) {
+ if (m_parameters.options & RubberBandLiveShifter::OptionWindowMedium) {
m_log.log(1, "R3LiveShifter::R3LiveShifter: readahead enabled");
m_useReadahead = true;
}
- if ((m_parameters.options & RubberBandLiveShifter::OptionPitchModeB)) {
- m_log.log(1, "R3LiveShifter::R3LiveShifter: contract-then-expand enabled");
- m_contractThenExpand = true;
+ if ((m_parameters.options & RubberBandLiveShifter::OptionPitchMethodAlternate)) {
+ m_log.log(1, "R3LiveShifter::R3LiveShifter: expand-then-contract enabled");
+ m_expandThenContract = true;
}
double maxClassifierFrequency = 16000.0;
@@ 276,18 274,18 @@ R3LiveShifter::getStartDelay() const
{
int fixed = getWindowSourceSize() / 2 + m_resamplerDelay * 2;
int variable = getWindowSourceSize() / 2;
- if (m_contractThenExpand) {
+ 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) {
return size_t(fixed + ceil(variable / m_pitchScale));
} else {
return size_t(fixed + ceil(variable * m_pitchScale));
}
- } else {
- if (m_pitchScale < 1.0) {
- return size_t(fixed + ceil(variable * m_pitchScale));
- } else {
- return size_t(fixed + ceil(variable / m_pitchScale));
- }
}
}
@@ 339,13 337,13 @@ R3LiveShifter::shift(const float *const
int pad = 0;
if (m_firstProcess) {
- if (m_contractThenExpand) {
+ if (m_expandThenContract) {
+ pad = getWindowSourceSize() / 2;
+ } else {
pad = getWindowSourceSize();
if (m_pitchScale > 1.0) {
pad = int(ceil(pad * m_pitchScale));
}
- } else {
- pad = getWindowSourceSize() / 2;
}
m_log.log(2, "R3LiveShifter::shift: extending input with pre-pad", incount, pad);
for (int c = 0; c < m_parameters.channels; ++c) {
@@ 357,12 355,12 @@ R3LiveShifter::shift(const float *const
double outRatio = 1.0;
- if (m_contractThenExpand) {
- if (m_pitchScale < 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;
}
}
@@ 427,12 425,12 @@ R3LiveShifter::readIn(const float *const
double inRatio = 1.0;
- if (m_contractThenExpand) {
- if (m_pitchScale > 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;
}
}
@@ 484,7 482,6 @@ R3LiveShifter::generate(int requiredInOu
int toGenerate = requiredInOutbuf - alreadyGenerated;
-// int longest = m_guideConfiguration.longestFftSize;
int channels = m_parameters.channels;
int ws = getWindowSourceSize();
@@ 627,12 624,12 @@ R3LiveShifter::readOut(float *const *out
{
double outRatio = 1.0;
- if (m_contractThenExpand) {
- if (m_pitchScale < 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;
}
}
M src/finer/R3LiveShifter.h +8 -15
@@ 94,20 94,14 @@ protected:
int minInhop;
int maxInhopWithReadahead;
int maxInhop;
- Limits(RubberBandLiveShifter::Options options, double rate) :
+ Limits(RubberBandLiveShifter::Options, double rate) :
// commented values are results when rate = 44100 or 48000
- minPreferredOuthop(roundUpDiv(rate, 512)), // 128
- maxPreferredOuthop(roundUpDiv(rate, 128)), // 512
- minInhop(1),
- maxInhopWithReadahead(roundUpDiv(rate, 64)), // 1024
- maxInhop(roundUpDiv(rate, 32)) // 2048
+ minInhop(1)
{
- if (!(options & RubberBandLiveShifter::OptionWindowLong)) {
- minPreferredOuthop = roundUpDiv(rate, 256); // 256
- maxPreferredOuthop = (roundUpDiv(rate, 128) * 5) / 4; // 640
- maxInhopWithReadahead = roundUpDiv(rate, 128); // 512
- maxInhop = (roundUpDiv(rate, 64) * 3) / 2; // 1536
- }
+ minPreferredOuthop = roundUpDiv(rate, 256); // 256
+ maxPreferredOuthop = (roundUpDiv(rate, 128) * 5) / 4; // 640
+ maxInhopWithReadahead = roundUpDiv(rate, 128); // 512
+ maxInhop = (roundUpDiv(rate, 64) * 3) / 2; // 1536
}
};
@@ 321,7 315,7 @@ protected:
bool m_useReadahead;
int m_prevInhop;
int m_prevOuthop;
- bool m_contractThenExpand; // otherwise expand then contract
+ bool m_expandThenContract; // otherwise contract then expand
bool m_firstProcess;
uint32_t m_unityCount;
@@ 391,8 385,7 @@ protected:
}
bool isSingleWindowed() const {
- return !(m_parameters.options &
- RubberBandLiveShifter::OptionWindowLong);
+ return true;
}
int getWindowSourceSize() const {
M src/test/TestLiveShifter.cpp +2 -2
@@ 117,7 117,7 @@ static void check_sinusoid_unchanged(int
BOOST_AUTO_TEST_CASE(sinusoid_unchanged_mode_a)
{
RubberBandLiveShifter::Options options =
- RubberBandLiveShifter::OptionPitchModeA;
+ RubberBandLiveShifter::OptionPitchMethodStandard;
int n = 100000;
check_sinusoid_unchanged(n, 44100, 440.f, options, false);
@@ 127,7 127,7 @@ BOOST_AUTO_TEST_CASE(sinusoid_unchanged_
BOOST_AUTO_TEST_CASE(sinusoid_unchanged_mode_b)
{
RubberBandLiveShifter::Options options =
- RubberBandLiveShifter::OptionPitchModeB;
+ RubberBandLiveShifter::OptionPitchMethodAlternate;
int n = 100000;
check_sinusoid_unchanged(n, 44100, 440.f, options, false);