1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 15:32:56 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Audio/DrumSampleMapping.cs

53 lines
1.7 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
using System.Collections.Generic;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko.Audio
{
public class DrumSampleMapping
{
private readonly ControlPointInfo controlPoints;
private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>();
public readonly List<SkinnableSound> Sounds = new List<SkinnableSound>();
public DrumSampleMapping(ControlPointInfo controlPoints)
{
this.controlPoints = controlPoints;
2019-10-25 18:48:01 +08:00
IEnumerable<SampleControlPoint> samplePoints = controlPoints.SamplePoints.Count == 0 ? new[] { controlPoints.SamplePointAt(double.MinValue) } : controlPoints.SamplePoints;
2018-04-13 17:19:50 +08:00
foreach (var s in samplePoints)
{
var centre = s.GetSampleInfo();
2019-06-30 20:58:30 +08:00
var rim = s.GetSampleInfo(HitSampleInfo.HIT_CLAP);
2018-04-13 17:19:50 +08:00
mappings[s.Time] = new DrumSample
{
Centre = addSound(centre),
Rim = addSound(rim)
};
}
}
2019-06-30 20:58:30 +08:00
private SkinnableSound addSound(HitSampleInfo hitSampleInfo)
2018-04-13 17:19:50 +08:00
{
2019-06-30 20:58:30 +08:00
var drawable = new SkinnableSound(hitSampleInfo);
2018-04-13 17:19:50 +08:00
Sounds.Add(drawable);
return drawable;
}
public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time).Time];
public class DrumSample
{
public SkinnableSound Centre;
public SkinnableSound Rim;
}
}
}