public int GetResampledData(GATData target, int targetLength, int offsetInTarget, double pitch)
{
double dLastIndex = _nextIndex + pitch * (targetLength - 1);
int iLastIndex = ( int )dLastIndex;;
int sign = System.Math.Sign(pitch);
if (dLastIndex - ( double )iLastIndex > 0d)
{
iLastIndex += sign;
}
if (iLastIndex >= _data.Count - 1)
{
targetLength = ( int )((( double )(_data.Count - 1) - _nextIndex) / pitch);
target.ResampleCopyFrom(_data.ParentArray, _nextIndex + ( double )_data.MemOffset, targetLength, offsetInTarget, pitch);
return(targetLength);
}
else if (iLastIndex < 0)
{
targetLength = -( int )((_nextIndex - 1d) / pitch) + 1;
target.ResampleCopyFrom(_data.ParentArray, _nextIndex + ( double )_data.MemOffset, targetLength, offsetInTarget, pitch);
return(targetLength);
}
else
{
target.ResampleCopyFrom(_data.ParentArray, _nextIndex + ( double )_data.MemOffset, targetLength, offsetInTarget, pitch);
_nextIndex = dLastIndex + pitch;
return(targetLength);
}
}