2017-02-07 12:59:30 +08:00
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-08-31 11:33:01 +08:00
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2017-01-30 15:03:45 +08:00
|
|
|
using System.Linq;
|
2016-10-11 01:00:16 +08:00
|
|
|
using OpenTK.Graphics;
|
2016-08-31 12:51:00 +08:00
|
|
|
using osu.Game.Beatmaps.Timing;
|
2016-10-19 01:35:01 +08:00
|
|
|
using osu.Game.Database;
|
2016-11-14 17:03:20 +08:00
|
|
|
using osu.Game.Modes.Objects;
|
2016-08-31 11:33:01 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
{
|
|
|
|
public class Beatmap
|
|
|
|
{
|
2016-10-19 01:35:01 +08:00
|
|
|
public BeatmapInfo BeatmapInfo { get; set; }
|
2016-10-28 13:13:52 +08:00
|
|
|
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
|
2016-10-08 01:50:34 +08:00
|
|
|
public List<HitObject> HitObjects { get; set; }
|
|
|
|
public List<ControlPoint> ControlPoints { get; set; }
|
2016-10-11 01:00:16 +08:00
|
|
|
public List<Color4> ComboColors { get; set; }
|
2017-01-30 15:03:45 +08:00
|
|
|
public double BPMMaximum => 60000 / ControlPoints.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).First().BeatLength;
|
|
|
|
public double BPMMinimum => 60000 / ControlPoints.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).First().BeatLength;
|
|
|
|
public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time);
|
2016-11-28 14:31:54 +08:00
|
|
|
|
2016-12-18 02:57:58 +08:00
|
|
|
public double BPMAt(double time)
|
|
|
|
{
|
|
|
|
return 60000 / BeatLengthAt(time);
|
|
|
|
}
|
|
|
|
|
2016-11-28 14:31:54 +08:00
|
|
|
public double BeatLengthAt(double time, bool applyMultipliers = false)
|
|
|
|
{
|
|
|
|
int point = 0;
|
|
|
|
int samplePoint = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < ControlPoints.Count; i++)
|
|
|
|
if (ControlPoints[i].Time <= time)
|
|
|
|
{
|
|
|
|
if (ControlPoints[i].TimingChange)
|
|
|
|
point = i;
|
|
|
|
else
|
|
|
|
samplePoint = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
double mult = 1;
|
|
|
|
|
2016-12-03 21:52:51 +08:00
|
|
|
if (applyMultipliers && samplePoint > point)
|
2016-11-28 14:31:54 +08:00
|
|
|
mult = ControlPoints[samplePoint].VelocityAdjustment;
|
|
|
|
|
|
|
|
return ControlPoints[point].BeatLength * mult;
|
|
|
|
}
|
2016-08-31 11:33:01 +08:00
|
|
|
}
|
2016-10-19 22:31:10 +08:00
|
|
|
}
|