2018-01-05 11:21:19 +00:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-12-25 07:47:29 +00:00
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
2017-12-26 05:18:23 +00:00
|
|
|
using System.Collections.Generic;
|
2017-12-25 07:47:29 +00:00
|
|
|
using osu.Game.Audio;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-02-23 11:34:08 +00:00
|
|
|
using osu.Game.Skinning;
|
2017-12-25 07:47:29 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Audio
|
|
|
|
{
|
2017-12-26 05:18:23 +00:00
|
|
|
public class DrumSampleMapping
|
2017-12-25 07:47:29 +00:00
|
|
|
{
|
2017-12-26 05:18:23 +00:00
|
|
|
private readonly ControlPointInfo controlPoints;
|
2017-12-27 04:03:46 +00:00
|
|
|
private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>();
|
2017-12-25 07:47:29 +00:00
|
|
|
|
2018-02-24 14:07:02 +00:00
|
|
|
public readonly List<SkinnableSound> Sounds = new List<SkinnableSound>();
|
2018-02-23 11:34:08 +00:00
|
|
|
|
|
|
|
public DrumSampleMapping(ControlPointInfo controlPoints)
|
2017-12-25 07:47:29 +00:00
|
|
|
{
|
2017-12-26 05:18:23 +00:00
|
|
|
this.controlPoints = controlPoints;
|
2017-12-25 07:47:29 +00:00
|
|
|
|
2017-12-26 05:18:23 +00: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 04:03:46 +00:00
|
|
|
foreach (var s in samplePoints)
|
2017-12-26 05:18:23 +00:00
|
|
|
{
|
2018-02-23 11:34:08 +00: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 04:03:46 +00:00
|
|
|
mappings[s.Time] = new DrumSample
|
2017-12-26 05:18:23 +00:00
|
|
|
{
|
2018-02-24 14:07:02 +00:00
|
|
|
Centre = addSound(centre),
|
|
|
|
Rim = addSound(rim)
|
2017-12-26 05:18:23 +00:00
|
|
|
};
|
|
|
|
}
|
2017-12-25 07:47:29 +00:00
|
|
|
}
|
|
|
|
|
2018-02-24 14:07:02 +00:00
|
|
|
private SkinnableSound addSound(SampleInfo sampleInfo)
|
2018-02-23 11:34:08 +00:00
|
|
|
{
|
2018-02-24 14:07:02 +00:00
|
|
|
var drawable = new SkinnableSound(sampleInfo);
|
|
|
|
Sounds.Add(drawable);
|
2018-02-23 11:34:08 +00:00
|
|
|
return drawable;
|
|
|
|
}
|
|
|
|
|
2017-12-27 04:03:46 +00:00
|
|
|
public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time).Time];
|
2017-12-26 05:18:23 +00:00
|
|
|
|
|
|
|
public class DrumSample
|
2017-12-25 07:47:29 +00:00
|
|
|
{
|
2018-02-23 11:34:08 +00:00
|
|
|
public SkinnableSound Centre;
|
|
|
|
public SkinnableSound Rim;
|
2017-12-25 07:47:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|