Example #1
0
        SuggestOffset(
            double t,
            out int closestIndex
            )
        {
            closestIndex = Math.Max(_samples.Locate(t), 0);
            int ret = Math.Min(
                Math.Max(
                    closestIndex - (_effectiveOrder - 1) / 2,
                    0
                    ),
                _samples.Count - _effectiveOrder
                );

            if (closestIndex < (_samples.Count - 1))
            {
                double dist1 = Math.Abs(t - _samples.GetT(closestIndex));
                double dist2 = Math.Abs(t - _samples.GetT(closestIndex + 1));

                if (dist1 > dist2)
                {
                    closestIndex++;
                }
            }

            return(ret);
        }
        private int SuggestOffset(double t, out int closestIndex)
        {
            closestIndex = Math.Max(samples.Locate(t), 0);
            int ret = Math.Min(Math.Max(closestIndex - (effectiveOrder - 1) / 2, 0), samples.Count - effectiveOrder);

            if (Math.Abs(t - samples.GetT(closestIndex)) > Math.Abs(t - samples.GetT(closestIndex + 1)))
            {
                closestIndex++;
            }
            return(ret);
        }