@@ -113,7 +113,7 @@ class InterpolatingCircularBufferTestPatch : public TestPatch {
113113 FloatArray delay = FloatArray::create (20 );
114114 input.ramp (0 , 20 );
115115 buffer->delay (input, delay, input.getSize (), 0.5 ); // delay by half a sample
116- for (int i=1 ; i<input.getSize (); ++i){
116+ for (size_t i=1 ; i<input.getSize (); ++i){
117117 CHECK_CLOSE (delay[i], (input[i-1 ] + input[i])/2 , DEFAULT_TOLERANCE);
118118 }
119119 LinearFloatBuffer::destroy (buffer);
@@ -131,6 +131,24 @@ class InterpolatingCircularBufferTestPatch : public TestPatch {
131131 LinearFloatBuffer::destroy (buffer);
132132 FloatArray::destroy (input);
133133 }
134+ {
135+ TEST (" fractional rate read" );
136+ LinearFloatBuffer* buffer = LinearFloatBuffer::create (5 );
137+ FloatArray input = FloatArray::create (5 );
138+ FloatArray output = FloatArray::create (10 );
139+ input.ramp (0 , 5 );
140+ buffer->write (input, input.getSize ());
141+ buffer->read (output, output.getSize (), 0 .5f );
142+ for (size_t j=0 ; j<9 ; ++j) // not checking last value in loop
143+ CHECK_CLOSE (output[j], j*0 .5f , DEFAULT_TOLERANCE);
144+ CHECK_CLOSE (output[9 ], 2 .0f , DEFAULT_TOLERANCE); // interpolated between 4 and 0 (wrapping)
145+ CHECK_EQUAL ((int )buffer->getWriteCapacity (), 5 );
146+ CHECK_EQUAL ((int )buffer->getReadCapacity (), 0 );
147+ CHECK (buffer->isEmpty ());
148+ CHECK (!buffer->isFull ());
149+ LinearFloatBuffer::destroy (buffer);
150+ FloatArray::destroy (input);
151+ }
134152 }
135153};
136154
0 commit comments