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.Framework.Audio;
|
|
|
|
using osu.Framework.Audio.Sample;
|
|
|
|
using osu.Game.Audio;
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
|
|
|
|
|
|
|
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
|
|
|
|
2017-12-26 13:18:23 +08:00
|
|
|
public DrumSampleMapping(ControlPointInfo controlPoints, AudioManager audio)
|
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
|
|
|
{
|
2017-12-27 12:03:46 +08:00
|
|
|
mappings[s.Time] = new DrumSample
|
2017-12-26 13:18:23 +08:00
|
|
|
{
|
2017-12-26 18:55:56 +08:00
|
|
|
Centre = s.GetSampleInfo().GetChannel(audio.Sample, "Taiko"),
|
|
|
|
Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample, "Taiko")
|
2017-12-26 13:18:23 +08:00
|
|
|
};
|
|
|
|
}
|
2017-12-25 15:47:29 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2017-12-26 13:18:23 +08:00
|
|
|
public SampleChannel Centre;
|
|
|
|
public SampleChannel Rim;
|
2017-12-25 15:47:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|