示例#1
0
        public void Add(CorrectionProfilePoint point)
        {
            CorrectionProfilePoint p = GetPredecessor(point.Frequency);

            if (p != null)
            {
                ProfilePoints.AddAfter(ProfilePoints.Find(p), point);
            }
            else
            {
                ProfilePoints.AddLast(point);
            }
        }
示例#2
0
        public CorrectionProfilePoint GetSuccessor(long freq)
        {
            CorrectionProfilePoint last = null;

            foreach (CorrectionProfilePoint point in ProfilePoints)
            {
                last = point;

                if (last.Frequency >= freq)
                {
                    /* we are now beyond the point that was looked for */
                    return(last);
                }
            }

            /* else return the last one found */
            return(last);
        }
示例#3
0
        public CorrectionProfilePoint GetPredecessor(long freq)
        {
            CorrectionProfilePoint pred = null;

            foreach (CorrectionProfilePoint point in ProfilePoints)
            {
                /* this is the first entry */
                if (point.Frequency >= freq)
                {
                    /* we are already beyond the point that was looked for */
                    return(pred);
                }

                pred = point;
            }

            return(pred);
        }
示例#4
0
        public double GetCorrectionValue(long freq)
        {
            CorrectionProfilePoint p1 = GetPredecessor(freq);
            CorrectionProfilePoint p2 = GetSuccessor(freq);

            /* no correction values found */
            if (p1 == null && p2 == null)
            {
                return(0.0f);
            }

            /* freq is lower than lowest found correction point */
            if (p1 != null && p2 == null)
            {
                return(p1.CorrectionOffset);
            }

            /* freq is beyond last correction point */
            if (p1 == null && p2 != null)
            {
                return(p2.CorrectionOffset);
            }

            /* freq must be between p1 and p2 freq */
            double diff1 = p2.Frequency - p1.Frequency;
            double diff2 = p2.Frequency - freq;

            /* reached end of list */
            if (diff1 < 1)
            {
                return(p1.CorrectionOffset);
            }

            double corr1 = diff2 / diff1;
            double corr2 = 1 - diff2 / diff1;

            return(p1.CorrectionOffset * corr1 + p2.CorrectionOffset * corr2);
        }