@@ -838,30 +838,31 @@ TEST_F (TimeStretchProcessorTests, ChangeParametersDuringProcessing)
838838// ==============================================================================
839839TEST_F (TimeStretchProcessorTests, DifferentTimeRatios)
840840{
841- const double ratios[] = { 0.5 , 0.75 , 1.0 , 1.5 , 2.0 , 3.0 };
841+ TimeStretchProcessor processor;
842+ ASSERT_TRUE (processor.prepare (spec).wasOk ());
842843
843- for (auto ratio : ratios)
844+ // Set input provider once
845+ auto provider = [&] (int64 beginFrame, int numFrames, float * const * destChannels, int channelStride, int & muteHead, int & muteTail)
844846 {
845- TimeStretchProcessor processor;
846- ASSERT_TRUE (processor.prepare (spec).wasOk ());
847-
848- // Set input provider
849- auto provider = [&] (int64 beginFrame, int numFrames, float * const * destChannels, int channelStride, int & muteHead, int & muteTail)
847+ muteHead = 0 ;
848+ muteTail = 0 ;
849+ for (int ch = 0 ; ch < numChannels; ++ch)
850850 {
851- muteHead = 0 ;
852- muteTail = 0 ;
853- for (int ch = 0 ; ch < numChannels; ++ch)
851+ for (int i = 0 ; i < numFrames; ++i)
854852 {
855- for (int i = 0 ; i < numFrames; ++i)
856- {
857- const int srcIndex = static_cast <int > ((beginFrame + i) % maximumBlockSize);
858- destChannels[ch][i] = inputBuffer.getReadPointer (ch)[srcIndex];
859- }
853+ const int srcIndex = static_cast <int > ((beginFrame + i) % maximumBlockSize);
854+ destChannels[ch][i] = inputBuffer.getReadPointer (ch)[srcIndex];
860855 }
861- };
862- processor.setInputProvider (provider);
856+ }
857+ };
858+ processor.setInputProvider (provider);
863859
860+ const double ratios[] = { 0.5 , 0.75 , 1.0 , 1.5 , 2.0 , 3.0 };
861+
862+ for (auto ratio : ratios)
863+ {
864864 processor.setTimeRatio (ratio);
865+ processor.setInputPosition (0 );
865866
866867 auto result = processor.process (inputBuffer.getArrayOfReadPointers (),
867868 inputBuffer.getNumSamples (),
@@ -874,30 +875,31 @@ TEST_F (TimeStretchProcessorTests, DifferentTimeRatios)
874875
875876TEST_F (TimeStretchProcessorTests, DifferentPitchRatios)
876877{
877- const double ratios[] = { 0.5 , 0.75 , 1.0 , 1.5 , 2.0 };
878+ TimeStretchProcessor processor;
879+ ASSERT_TRUE (processor.prepare (spec).wasOk ());
878880
879- for (auto ratio : ratios)
881+ // Set input provider once
882+ auto provider = [&] (int64 beginFrame, int numFrames, float * const * destChannels, int channelStride, int & muteHead, int & muteTail)
880883 {
881- TimeStretchProcessor processor;
882- ASSERT_TRUE (processor.prepare (spec).wasOk ());
883-
884- // Set input provider
885- auto provider = [&] (int64 beginFrame, int numFrames, float * const * destChannels, int channelStride, int & muteHead, int & muteTail)
884+ muteHead = 0 ;
885+ muteTail = 0 ;
886+ for (int ch = 0 ; ch < numChannels; ++ch)
886887 {
887- muteHead = 0 ;
888- muteTail = 0 ;
889- for (int ch = 0 ; ch < numChannels; ++ch)
888+ for (int i = 0 ; i < numFrames; ++i)
890889 {
891- for (int i = 0 ; i < numFrames; ++i)
892- {
893- const int srcIndex = static_cast <int > ((beginFrame + i) % maximumBlockSize);
894- destChannels[ch][i] = inputBuffer.getReadPointer (ch)[srcIndex];
895- }
890+ const int srcIndex = static_cast <int > ((beginFrame + i) % maximumBlockSize);
891+ destChannels[ch][i] = inputBuffer.getReadPointer (ch)[srcIndex];
896892 }
897- };
898- processor.setInputProvider (provider);
893+ }
894+ };
895+ processor.setInputProvider (provider);
899896
897+ const double ratios[] = { 0.5 , 0.75 , 1.0 , 1.5 , 2.0 };
898+
899+ for (auto ratio : ratios)
900+ {
900901 processor.setPitchRatio (ratio);
902+ processor.setInputPosition (0 );
901903
902904 auto result = processor.process (inputBuffer.getArrayOfReadPointers (),
903905 inputBuffer.getNumSamples (),
0 commit comments