2018-01-05 19:21:19 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-12-25 15:47:29 +08:00
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2017-12-26 13:18:23 +08:00
|
|
|
using System.Collections.Generic;
|
2017-12-25 15:47:29 +08:00
|
|
|
using osu.Game.Audio;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-02-23 19:34:08 +08:00
|
|
|
using osu.Game.Skinning;
|
2017-12-25 15:47:29 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Audio
|
|
|
|
{
|
2017-12-26 13:18:23 +08:00
|
|
|
public class DrumSampleMapping
|
2017-12-25 15:47:29 +08:00
|
|
|
{
|
2017-12-26 13:18:23 +08:00
|
|
|
private readonly ControlPointInfo controlPoints;
|
2017-12-27 12:03:46 +08:00
|
|
|
private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>();
|
2017-12-25 15:47:29 +08:00
|
|
|
|
2018-02-23 19:34:08 +08:00
|
|
|
public readonly List<SkinnableSound> Drawables = new List<SkinnableSound>();
|
|
|
|
|
|
|
|
public DrumSampleMapping(ControlPointInfo controlPoints)
|
2017-12-25 15:47:29 +08:00
|
|
|
{
|
2017-12-26 13:18:23 +08:00
|
|
|
this.controlPoints = controlPoints;
|
2017-12-25 15:47:29 +08:00
|
|
|
|
2017-12-26 13:18:23 +08:00
|
|
|
IEnumerable<SampleControlPoint> samplePoints;
|
|
|
|
if (controlPoints.SamplePoints.Count == 0)
|
|
|
|
// Get the default sample point
|
|
|
|
samplePoints = new[] { controlPoints.SamplePointAt(double.MinValue) };
|
|
|
|
else
|
|
|
|
samplePoints = controlPoints.SamplePoints;
|
|
|
|
|
2017-12-27 12:03:46 +08:00
|
|
|
foreach (var s in samplePoints)
|
2017-12-26 13:18:23 +08:00
|
|
|
{
|
2018-02-23 19:34:08 +08:00
|
|
|
var centre = s.GetSampleInfo();
|
|
|
|
var rim = s.GetSampleInfo(SampleInfo.HIT_CLAP);
|
|
|
|
|
|
|
|
// todo: this is ugly
|
|
|
|
centre.Namespace = "taiko";
|
|
|
|
rim.Namespace = "taiko";
|
|
|
|
|
2017-12-27 12:03:46 +08:00
|
|
|
mappings[s.Time] = new DrumSample
|
2017-12-26 13:18:23 +08:00
|
|
|
{
|
2018-02-23 19:34:08 +08:00
|
|
|
Centre = addDrawableSound(centre),
|
|
|
|
Rim = addDrawableSound(rim)
|
2017-12-26 13:18:23 +08:00
|
|
|
};
|
|
|
|
}
|
2017-12-25 15:47:29 +08:00
|
|
|
}
|
|
|
|
|
2018-02-23 19:34:08 +08:00
|
|
|
private SkinnableSound addDrawableSound(SampleInfo rim)
|
|
|
|
{
|
|
|
|
var drawable = new SkinnableSound(rim);
|
|
|
|
Drawables.Add(drawable);
|
|
|
|
return drawable;
|
|
|
|
}
|
|
|
|
|
2017-12-27 12:03:46 +08:00
|
|
|
public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time).Time];
|
2017-12-26 13:18:23 +08:00
|
|
|
|
|
|
|
public class DrumSample
|
2017-12-25 15:47:29 +08:00
|
|
|
{
|
2018-02-23 19:34:08 +08:00
|
|
|
public SkinnableSound Centre;
|
|
|
|
public SkinnableSound Rim;
|
2017-12-25 15:47:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|