2016-08-31 03:33:01 +00:00
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2017-01-30 07:03:45 +00:00
|
|
|
using System.Linq;
|
2016-10-10 17:00:16 +00:00
|
|
|
using OpenTK.Graphics;
|
2016-08-31 04:51:00 +00:00
|
|
|
using osu.Game.Beatmaps.Timing;
|
2016-10-18 17:35:01 +00:00
|
|
|
using osu.Game.Database;
|
2016-11-14 09:03:20 +00:00
|
|
|
using osu.Game.Modes.Objects;
|
2016-08-31 03:33:01 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
{
|
|
|
|
public class Beatmap
|
|
|
|
{
|
2016-10-18 17:35:01 +00:00
|
|
|
public BeatmapInfo BeatmapInfo { get; set; }
|
2016-10-28 05:13:52 +00:00
|
|
|
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
|
2016-10-07 17:50:34 +00:00
|
|
|
public List<HitObject> HitObjects { get; set; }
|
|
|
|
public List<ControlPoint> ControlPoints { get; set; }
|
2016-10-10 17:00:16 +00:00
|
|
|
public List<Color4> ComboColors { get; set; }
|
2017-01-30 07:03:45 +00: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 06:31:54 +00:00
|
|
|
|
2016-12-17 18:57:58 +00:00
|
|
|
public double BPMAt(double time)
|
|
|
|
{
|
|
|
|
return 60000 / BeatLengthAt(time);
|
|
|
|
}
|
|
|
|
|
2016-11-28 06:31:54 +00: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 13:52:51 +00:00
|
|
|
if (applyMultipliers && samplePoint > point)
|
2016-11-28 06:31:54 +00:00
|
|
|
mult = ControlPoints[samplePoint].VelocityAdjustment;
|
|
|
|
|
|
|
|
return ControlPoints[point].BeatLength * mult;
|
|
|
|
}
|
2016-08-31 03:33:01 +00:00
|
|
|
}
|
2016-10-19 14:31:10 +00:00
|
|
|
}
|