ResampleCopyFrom() public method

Performs a resampled copy from an array to the GATData instance it is called on. The resampling algorithm performs naive linear interpolation.
public ResampleCopyFrom ( float sourceArray, double trueInterpolatedIndex, int targetLength, int targetOffset, double resamplingFactor ) : double
sourceArray float
trueInterpolatedIndex double
targetLength int
targetOffset int
resamplingFactor double
return double
Example #1
0
        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);
            }
        }
Example #2
0
 /// <summary>
 /// Performs a resampled
 /// copy to another GATData
 /// instance.
 /// The resampling algorithm
 /// performs naive linear interpolation.
 /// </summary>
 /// <returns>
 /// The next interpolated index.
 /// </returns>
 public double ResampleCopyTo(double trueInterpolatedIndex, GATData destinationSample, int targetLength, double resamplingFactor)
 {
     return(destinationSample.ResampleCopyFrom(_parentArray, trueInterpolatedIndex, targetLength, 0, resamplingFactor));
 }
Example #3
0
 /// <summary>
 /// Performs a resampled
 /// copy to another
 /// GATData instance
 /// The resampling algorithm
 /// performs naive linear interpolation.
 /// Warning: for resampling in chunks, use
 /// the method of the same name which returns
 /// a double interpolated index.
 /// </summary>
 public void ResampleCopyTo(int sourceIndex, GATData destinationSample, int targetLength, double resamplingFactor)
 {
     sourceIndex += _offset;
     destinationSample.ResampleCopyFrom(_parentArray, ( double )sourceIndex, targetLength, 0, resamplingFactor);
 }
Example #4
0
 /// <summary>
 /// Performs a resampled
 /// copy to another GATData
 /// instance.
 /// The resampling algorithm
 /// performs naive linear interpolation.
 /// </summary>
 /// <returns>
 /// The next interpolated index.
 /// </returns>
 public double ResampleCopyTo( double trueInterpolatedIndex, GATData destinationSample, int targetLength, double resamplingFactor )
 {
     return destinationSample.ResampleCopyFrom( _parentArray, trueInterpolatedIndex, targetLength, 0, resamplingFactor );
 }
Example #5
0
 /// <summary>
 /// Performs a resampled
 /// copy to another 
 /// GATData instance
 /// The resampling algorithm
 /// performs naive linear interpolation.
 /// Warning: for resampling in chunks, use
 /// the method of the same name which returns
 /// a double interpolated index.
 /// </summary>
 public void ResampleCopyTo( int sourceIndex, GATData destinationSample, int targetLength, double resamplingFactor )
 {
     sourceIndex += _offset;
     destinationSample.ResampleCopyFrom( _parentArray, ( double )sourceIndex, targetLength, 0, resamplingFactor );
 }