Ejemplo n.º 1
0
        public override void Match(string line)
        {
            if (TimingList == null)
            {
                TimingList = new List <TimingPoint>();
            }

            string[] param           = line.Split(',');
            double   offset          = double.Parse(param[0]);
            double   factor          = double.Parse(param[1]);
            int      rhythm          = int.Parse(param[2]);
            var      timingSampleset = param.Length > 3
                ? (TimingSamplesetType)(int.Parse(param[3]) - 1)
                : TimingSamplesetType.None;
            var track    = param.Length > 4 ? int.Parse(param[4]) : 0;
            var volume   = param.Length > 5 ? int.Parse(param[5]) : 0;
            var inherit  = param.Length > 6 && !Convert.ToBoolean(int.Parse(param[6]));
            var kiai     = param.Length > 7 && Convert.ToBoolean(int.Parse(param[7]));
            var positive = factor >= 0;

            TimingList.Add(new TimingPoint
            {
                Offset          = offset,
                Factor          = factor,
                Rhythm          = rhythm,
                TimingSampleset = timingSampleset,
                Track           = track,
                Volume          = volume,
                Inherit         = inherit,
                Kiai            = kiai,
                Positive        = positive
            });
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private AlermTiming CheckedListToTiming()
        {
            AlermTiming timing = 0;

            for (int i = 0; i < 7; i++)
            {
                timing |= TimingList.GetItemChecked(i) ? (AlermTiming)(1 << i) : 0;
            }

            return(timing);
        }
Ejemplo n.º 4
0
    public static void BeginTiming(string s)
    {
        if (!s_stopwatch.IsRunning)
        {
            s_stopwatch.Start();
        }

        //mark the start time for this call
        TimingList l = GetTimingList(s);

        l.Add(s_stopwatch.ElapsedMilliseconds);
    }
Ejemplo n.º 5
0
    private static TimingList GetTimingList(string s)
    {
        TimingDictionary dictionary = GetTimingDictionary();
        TimingList       list       = null;

        dictionary.TryGetValue(s, out list);
        if (list == null)
        {
            list          = new TimingList();
            dictionary[s] = list;
        }
        return(list);
    }
Ejemplo n.º 6
0
    public static void EndTimingAndReport(string s)
    {
        //TODO should we use ticks instead of ms?
        long       timeNow = s_stopwatch.ElapsedMilliseconds;
        TimingList l       = GetTimingList(s);

        if (l.Count == 0)
        {
            UnityEngine.Debug.LogError("Mismatched profiler timing for: " + s);
            return;
        }
        long lastTimingStart = l[l.Count - 1];

        l.RemoveAt(l.Count - 1);
        long        diff = timeNow - lastTimingStart;
        TimingCount t    = AddTotalTiming(s, diff);

        UnityEngine.Debug.Log(string.Format("[{0}] took [{1}ms ({2}s)] time for [{3}] calls (Avg [{4}])", s, t.totalTime, (float)t.totalTime / 1000, t.calls, t.totalTime / t.calls));
    }
Ejemplo n.º 7
0
    public static void EndTiming(string s)
    {
        long       timeNow = s_stopwatch.ElapsedMilliseconds;
        TimingList l       = GetTimingList(s);

        if (l.Count == 0)
        {
            UnityEngine.Debug.LogError("Mismatched profiler timing for: " + s);
            return;
        }

        //pop off start time of the most recent start tracking of s
        //calc the difference from then till now and record it
        long lastTimingStart = l[l.Count - 1];

        l.RemoveAt(l.Count - 1);
        long diff = timeNow - lastTimingStart;

        AddTotalTiming(s, diff);
    }
Ejemplo n.º 8
0
        public void Match(string line)
        {
            if (TimingList == null)
            {
                TimingList = new List <RawTimingPoint>();
            }

            string[] param = line.Split(',');
            TimingList.Add(new RawTimingPoint
            {
                Offset        = double.Parse(param[0]),
                Factor        = double.Parse(param[1]),
                Rhythm        = int.Parse(param[2]),
                SamplesetEnum = (SamplesetEnum)(int.Parse(param[3]) - 1),
                Track         = int.Parse(param[4]),
                Volume        = int.Parse(param[5]),
                Inherit       = !Convert.ToBoolean(int.Parse(param[6])),
                Kiai          = Convert.ToBoolean(int.Parse(param[7])),
                Positive      = double.Parse(param[1]) >= 0
            });
        }
Ejemplo n.º 9
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());
        }
Ejemplo n.º 10
0
        public FormAlermSetting(IEnumerable <string> playlists, AlermSettings.AlermData alerm) : this()
        {
            alerm = alerm ?? new AlermSettings.AlermData();

            checkBox1.Checked     = alerm.IsEnabled;
            dateTimePicker1.Value = alerm.Time;

            for (int i = 0; i < 7; i++)
            {
                TimingList.SetItemChecked(i, ((int)alerm.Timing & (1 << i)) != 0);
            }

            Playlist.Items.AddRange(playlists.ToArray());
            foreach (var name in alerm.PlaylistNames)
            {
                var index = Playlist.Items.IndexOf(name);
                if (index != -1)
                {
                    Playlist.SetItemChecked(index, true);
                }
            }
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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());
 }
Ejemplo n.º 14
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));
 }