Commit 4219ed77 authored by henryjandrew's avatar henryjandrew

updated sampleBuffer cyclic_read to allow any source offset -positive or negative

parent ed7c0bf9
......@@ -256,17 +256,19 @@ void ITASampleBuffer::cyclic_read( float* pfDest, int iCount, int iSrcOffset ) c
{
assert( pfDest != NULL );
assert( iCount >= 0 );
assert( ( iSrcOffset >= 0 ) && ( iSrcOffset < m_iLength ) );
//assert( ( iSrcOffset >= 0 ) && ( iSrcOffset < m_iLength ) ); //This limits wrap around of the buffer to "clockwise" only
int n = 0; // Anzahl kopierter Samples
int p = ( ( iSrcOffset % m_iLength ) + m_iLength ) % m_iLength; // Leseposition
//int p = ( ( iSrcOffset % m_iLength ) + m_iLength ) % m_iLength; // Leseposition
//int p = (iSrcOffset + (int)ceil(fabs(iSrcOffset/ (float)m_iLength))*m_iLength ) % m_iLength; //work out the read cursor for any source offset (+ or -)
int p = (iSrcOffset + (abs(iSrcOffset / m_iLength) + 1)*m_iLength) % m_iLength;
while( n < iCount ) {
// Verbleibende Samples berechnen
int r = std::min( iCount - n, m_iLength - p );
read( pfDest + n, r, p );
int r = std::min( iCount - n, m_iLength - p ); //read until a wrap around is needed, r = n0 samples to read on this iteration
read( pfDest + n, r, p ); //read(dest, count, offset)
p = ( p + r ) % m_iLength;
n += r;
n += r; //n = total samples read
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment