e90d8a37403b — Chris Cannam 10 days ago
Remove the alternate pitch method. It isn't as reliable in avoiding artifacts and it's quite a bit of overhead to test.
M ladspa-lv2/RubberBandLivePitchShifter.cpp +0 -1
@@ 266,7 266,6 @@ RubberBandLivePitchShifter::RubberBandLi
     m_currentFormant(false),
     m_shifter(new RubberBandLiveShifter
               (sampleRate, channels,
-               RubberBandLiveShifter::OptionPitchMethodStandard |
                RubberBandLiveShifter::OptionChannelsTogether)),
     m_sampleRate(sampleRate),
     m_channels(channels),

          
M rubberband/RubberBandLiveShifter.h +0 -3
@@ 102,9 102,6 @@ public:
         OptionFormantShifted       = 0x00000000,
         OptionFormantPreserved     = 0x01000000,
 
-        OptionPitchMethodStandard  = 0x00000000,
-        OptionPitchMethodAlternate = 0x02000000,
-
         OptionChannelsApart        = 0x00000000,
         OptionChannelsTogether     = 0x10000000,
 

          
M src/finer/R3LiveShifter.cpp +14 -58
@@ 45,7 45,6 @@ R3LiveShifter::R3LiveShifter(Parameters 
     m_useReadahead(false),
     m_prevInhop(m_limits.maxInhopWithReadahead / 2),
     m_prevOuthop(m_prevInhop),
-    m_expandThenContract(false),
     m_firstProcess(true),
     m_unityCount(0)
 {

          
@@ 71,11 70,6 @@ R3LiveShifter::initialise()
         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;
     if (maxClassifierFrequency > m_parameters.sampleRate/2) {
         maxClassifierFrequency = m_parameters.sampleRate/2;

          
@@ 247,14 241,8 @@ R3LiveShifter::measureResamplerDelay()
     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;
-        }
+    if (m_pitchScale > 1.0) {
+        inRatio = 1.0 / m_pitchScale;
     }
 
     int outcount = m_inResampler->resampleInterleaved

          
@@ 290,18 278,10 @@ R3LiveShifter::getStartDelay() const
 {
     int fixed = getWindowSourceSize() / 2 + m_resamplerDelay * 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));
-        }
+    if (m_pitchScale < 1.0) {
+        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));
-        }
+        return size_t(fixed + ceil(variable * m_pitchScale));
     }
 }
 

          
@@ 353,13 333,9 @@ R3LiveShifter::shift(const float *const 
 
     int pad = 0;
     if (m_firstProcess) {
-        if (m_expandThenContract) {
-            pad = getWindowSourceSize() / 2;
-        } else {
-            pad = getWindowSourceSize();
-            if (m_pitchScale > 1.0) {
-                pad = int(ceil(pad * m_pitchScale));
-            }
+        pad = getWindowSourceSize();
+        if (m_pitchScale > 1.0) {
+            pad = int(ceil(pad * m_pitchScale));
         }
         m_log.log(2, "R3LiveShifter::shift: extending input with pre-pad", incount, pad);
         for (int c = 0; c < m_parameters.channels; ++c) {

          
@@ 371,14 347,8 @@ R3LiveShifter::shift(const float *const 
 
     double outRatio = 1.0;
 
-    if (m_expandThenContract) {
-        if (m_pitchScale > 1.0) {
-            outRatio = 1.0 / m_pitchScale;
-        }
-    } else {
-        if (m_pitchScale < 1.0) {
-            outRatio = 1.0 / m_pitchScale;
-        }
+    if (m_pitchScale < 1.0) {
+        outRatio = 1.0 / m_pitchScale;
     }
     
     int requiredInOutbuf = int(ceil(incount / outRatio));

          
@@ 440,15 410,8 @@ R3LiveShifter::readIn(const float *const
     }
     
     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;
-        }
+    if (m_pitchScale > 1.0) {
+        inRatio = 1.0 / m_pitchScale;
     }
 
     m_log.log(2, "R3LiveShifter::readIn: ratio", inRatio);

          
@@ 639,15 602,8 @@ int
 R3LiveShifter::readOut(float *const *output, int outcount)
 {
     double outRatio = 1.0;
-
-    if (m_expandThenContract) {
-        if (m_pitchScale > 1.0) {
-            outRatio = 1.0 / m_pitchScale;
-        }
-    } else {
-        if (m_pitchScale < 1.0) {
-            outRatio = 1.0 / m_pitchScale;
-        }
+    if (m_pitchScale < 1.0) {
+        outRatio = 1.0 / m_pitchScale;
     }
     
     m_log.log(2, "R3LiveShifter::readOut: outcount and ratio", outcount, outRatio);

          
M src/finer/R3LiveShifter.h +0 -1
@@ 315,7 315,6 @@ protected:
     bool m_useReadahead;
     int m_prevInhop;
     int m_prevOuthop;
-    bool m_expandThenContract; // otherwise contract then expand
     bool m_firstProcess;
     uint32_t m_unityCount;
 

          
M src/test/TestLiveShifter.cpp +6 -22
@@ 230,34 230,18 @@ static void check_sinusoid_shifted(int n
     }
 }
 
-BOOST_AUTO_TEST_CASE(sinusoid_unchanged_mode_a)
+BOOST_AUTO_TEST_CASE(sinusoid_unchanged)
 {
-    RubberBandLiveShifter::Options options =
-        RubberBandLiveShifter::OptionPitchMethodStandard;
     int n = 20000;
-
-    check_sinusoid_unchanged(n, 44100, 440.f, options, false);
-    check_sinusoid_unchanged(n, 48000, 260.f, options, false);
+    check_sinusoid_unchanged(n, 44100, 440.f, 0, false);
+    check_sinusoid_unchanged(n, 48000, 260.f, 0, false);
 }
 
-BOOST_AUTO_TEST_CASE(sinusoid_unchanged_mode_b)
+BOOST_AUTO_TEST_CASE(sinusoid_down_octave)
 {
-    RubberBandLiveShifter::Options options =
-        RubberBandLiveShifter::OptionPitchMethodAlternate;
     int n = 20000;
-
-    check_sinusoid_unchanged(n, 44100, 440.f, options, 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);
+    check_sinusoid_shifted(n, 44100, 440.f, 0.5f, 0, true);
+//    check_sinusoid_shifted(n, 48000, 260.f, 0.5f, 0, false);
 }
 
 BOOST_AUTO_TEST_SUITE_END()