コード例 #1
0
ファイル: TimingSection.cs プロジェクト: vebin/Coosu
        public TimingPoint GetLine(double offset)
        {
            var lines = TimingList.Where(t => t.Offset <= offset + 1 /*tolerance*/).ToArray();

            if (lines.Length == 0)
            {
                return(TimingList.First());
            }
            var         timing             = lines.Max(t => t.Offset);
            var         samePositionPoints = TimingList.Where(t => Math.Abs(t.Offset - timing) < 1).ToArray();
            TimingPoint point;

            if (samePositionPoints.Length > 1)
            {
                var greens = samePositionPoints.Where(k => k.Inherit);
                point = greens.LastOrDefault() ?? samePositionPoints.Last();
                // there might be possibility that two red lines at same time
            }
            else
            {
                point = samePositionPoints[0];
            }

            return(point);
        }
コード例 #2
0
        public double[] GetTimings(double multiple)
        {
            var array = TimingList.Where(t => !t.Inherit).OrderBy(t => t.Offset).ToArray();
            var list  = new List <double>();

            for (int i = 0; i < array.Length; i++)
            {
                decimal nextTime = Convert.ToDecimal(i == array.Length - 1 ? MaxTime : array[i + 1].Offset);
                var     t        = array[i];
                decimal decBpm   = Convert.ToDecimal(t.Bpm);
                decimal decMult  = Convert.ToDecimal(multiple);
                decimal interval = 60000 / decBpm * decMult;
                decimal current  = Convert.ToDecimal(t.Offset);
                while (current < nextTime)
                {
                    list.Add(Convert.ToDouble(current));
                    current += interval;
                }
            }

            return(list.ToArray());
        }
コード例 #3
0
ファイル: TimingPoints.cs プロジェクト: MikiraSora/OsuLib
        public RawTimingPoint GetLine(double offset)
        {
            var lines = TimingList.Where(t => t.Offset <= offset + 1 /*tolerance*/).ToArray();

            if (lines.Length == 0)
            {
                return(TimingList.First());
            }
            double timing = lines.Max(t => t.Offset);

            RawTimingPoint[] points = TimingList.Where(t => Math.Abs(t.Offset - timing) < 1).ToArray();
            RawTimingPoint   point;

            if (points.Length > 1)
            {
                if (points.Length == 2)
                {
                    if (points[0].Inherit != points[1].Inherit)
                    {
                        point = points.First(t => t.Inherit);
                    }
                    else
                    {
                        throw new MultiTimingSectionException("存在同一时刻两条相同类型的Timing Section。");
                    }
                }
                else
                {
                    throw new MultiTimingSectionException("存在同一时刻多条Timing Section。");
                }
            }
            else
            {
                point = points[0];
            }

            return(point);
        }
コード例 #4
0
        public TimingPoint GetLine(double offset)
        {
            var lines = TimingList.Where(t => t.Offset <= offset + 1 /*tolerance*/).ToArray();

            if (lines.Length == 0)
            {
                return(TimingList.First());
            }
            double timing = lines.Max(t => t.Offset);

            TimingPoint[] points = TimingList.Where(t => Math.Abs(t.Offset - timing) < 1).ToArray();
            TimingPoint   point;

            if (points.Length > 1)
            {
                var greens = points.Where(k => k.Inherit);
                point = greens.Last();
                //if (points.Length == 2)
                //{
                //    if (points[0].Inherit != points[1].Inherit)
                //    {
                //        point = points.First(t => t.Inherit);
                //    }
                //    else
                //        throw new RepeatTimingSectionException("存在同一时刻两条相同类型的Timing Section。");
                //}
                //else
                //    throw new RepeatTimingSectionException("存在同一时刻多条Timing Section。");
            }
            else
            {
                point = points[0];
            }

            return(point);
        }
コード例 #5
0
 public TimingPoint GetRedLine(double offset)
 {
     TimingPoint[] points = TimingList.Where(t => !t.Inherit).Where(t => Math.Abs(t.Offset - offset) < 1).ToArray();
     return(points.Length == 0 ? TimingList.First(t => !t.Inherit) : points.Last());
 }
コード例 #6
0
 /// <summary>
 /// 获取当前bpm的节奏的间隔
 /// </summary>
 /// <param name="multiple">multiple: 1, 0.5, 1/3d, etc.</param>
 /// <returns></returns>
 public Dictionary <double, double> GetInterval(double multiple)
 {
     return(TimingList.Where(t => !t.Inherit).OrderBy(t => t.Offset)
            .ToDictionary(k => k.Offset, v => 60000 / v.Bpm * multiple));
 }