2021-08-26 08:19:46 +00:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
using System;
|
2023-06-30 07:14:52 +00:00
|
|
|
using osu.Framework.Utils;
|
2021-08-26 08:19:46 +00:00
|
|
|
using osu.Game.Audio;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
using osu.Game.Rulesets.UI;
|
2023-06-30 07:14:52 +00:00
|
|
|
using osu.Game.Skinning;
|
2021-08-26 08:19:46 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.UI
|
|
|
|
{
|
|
|
|
public partial class DrumSampleTriggerSource : GameplaySampleTriggerSource
|
|
|
|
{
|
2023-06-30 07:14:52 +00:00
|
|
|
private const double stereo_separation = 0.2;
|
|
|
|
|
|
|
|
public DrumSampleTriggerSource(HitObjectContainer hitObjectContainer, SampleBalance balance = SampleBalance.Centre)
|
2021-08-26 08:19:46 +00:00
|
|
|
: base(hitObjectContainer)
|
|
|
|
{
|
2023-06-30 07:14:52 +00:00
|
|
|
switch (balance)
|
|
|
|
{
|
|
|
|
case SampleBalance.Left:
|
|
|
|
AudioContainer.Balance.Value = -stereo_separation;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SampleBalance.Centre:
|
|
|
|
AudioContainer.Balance.Value = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SampleBalance.Right:
|
|
|
|
AudioContainer.Balance.Value = stereo_separation;
|
|
|
|
break;
|
|
|
|
}
|
2021-08-26 08:19:46 +00:00
|
|
|
}
|
|
|
|
|
2023-06-30 08:50:32 +00:00
|
|
|
public virtual void Play(HitType hitType, bool strong)
|
2021-08-26 08:19:46 +00:00
|
|
|
{
|
2023-06-30 06:06:32 +00:00
|
|
|
TaikoHitObject? hitObject = GetMostValidObject() as TaikoHitObject;
|
2021-08-26 08:19:46 +00:00
|
|
|
|
2023-06-30 06:06:32 +00:00
|
|
|
if (hitObject == null)
|
2021-08-26 08:19:46 +00:00
|
|
|
return;
|
|
|
|
|
2023-06-30 06:42:39 +00:00
|
|
|
var baseSample = hitObject.CreateHitSampleInfo(hitType == HitType.Rim ? HitSampleInfo.HIT_CLAP : HitSampleInfo.HIT_NORMAL);
|
2023-06-30 06:06:32 +00:00
|
|
|
|
2023-06-30 08:50:32 +00:00
|
|
|
if (strong)
|
2023-06-30 06:06:32 +00:00
|
|
|
{
|
2023-06-30 06:42:39 +00:00
|
|
|
PlaySamples(new ISampleInfo[]
|
|
|
|
{
|
2023-07-05 09:44:01 +00:00
|
|
|
baseSample,
|
|
|
|
hitObject.CreateHitSampleInfo(hitType == HitType.Rim ? HitSampleInfo.HIT_WHISTLE : HitSampleInfo.HIT_FINISH)
|
2023-06-30 06:42:39 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlaySamples(new ISampleInfo[] { baseSample });
|
2023-06-30 06:06:32 +00:00
|
|
|
}
|
2021-08-26 08:19:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void Play() => throw new InvalidOperationException(@"Use override with HitType parameter instead");
|
2023-06-30 07:14:52 +00:00
|
|
|
|
|
|
|
protected override void ApplySampleInfo(SkinnableSound hitSound, ISampleInfo[] samples)
|
|
|
|
{
|
|
|
|
base.ApplySampleInfo(hitSound, samples);
|
|
|
|
|
|
|
|
hitSound.Balance.Value = -0.05 + RNG.NextDouble(0.1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum SampleBalance
|
|
|
|
{
|
|
|
|
Left,
|
|
|
|
Centre,
|
|
|
|
Right
|
2021-08-26 08:19:46 +00:00
|
|
|
}
|
|
|
|
}
|