2023-06-30 07:03:11 +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.
|
|
|
|
|
2023-06-30 07:17:45 +00:00
|
|
|
using System.Collections.Generic;
|
2023-06-30 09:43:37 +00:00
|
|
|
using System.Linq;
|
2023-06-30 07:17:45 +00:00
|
|
|
using osu.Framework.Allocation;
|
2023-06-30 07:03:11 +00:00
|
|
|
using osu.Game.Audio;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
using osu.Game.Rulesets.Taiko.UI;
|
|
|
|
using osu.Game.Rulesets.UI;
|
2023-06-30 07:17:45 +00:00
|
|
|
using osu.Game.Skinning;
|
2023-06-30 07:03:11 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Skinning.Argon
|
|
|
|
{
|
2023-06-30 08:02:08 +00:00
|
|
|
internal partial class ArgonDrumSamplePlayer : DrumSamplePlayer
|
2023-06-30 07:03:11 +00:00
|
|
|
{
|
2023-06-30 07:14:52 +00:00
|
|
|
protected override DrumSampleTriggerSource CreateTriggerSource(HitObjectContainer hitObjectContainer, SampleBalance balance) =>
|
|
|
|
new ArgonDrumSampleTriggerSource(hitObjectContainer, balance);
|
2023-06-30 07:03:11 +00:00
|
|
|
|
|
|
|
public partial class ArgonDrumSampleTriggerSource : DrumSampleTriggerSource
|
|
|
|
{
|
2023-06-30 09:43:37 +00:00
|
|
|
private readonly HitObjectContainer hitObjectContainer;
|
|
|
|
|
2023-06-30 07:17:45 +00:00
|
|
|
[Resolved]
|
|
|
|
private ISkinSource skinSource { get; set; } = null!;
|
|
|
|
|
2023-06-30 09:43:37 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The minimum time to leave between flourishes that are added to strong rim hits.
|
|
|
|
/// </summary>
|
|
|
|
private const double time_between_flourishes = 2000;
|
|
|
|
|
2023-06-30 07:14:52 +00:00
|
|
|
public ArgonDrumSampleTriggerSource(HitObjectContainer hitObjectContainer, SampleBalance balance)
|
|
|
|
: base(hitObjectContainer, balance)
|
2023-06-30 07:03:11 +00:00
|
|
|
{
|
2023-06-30 09:43:37 +00:00
|
|
|
this.hitObjectContainer = hitObjectContainer;
|
2023-06-30 07:17:45 +00:00
|
|
|
// TODO: pool flourish sample
|
2023-06-30 07:03:11 +00:00
|
|
|
}
|
|
|
|
|
2023-06-30 08:50:32 +00:00
|
|
|
public override void Play(HitType hitType, bool strong)
|
2023-06-30 07:03:11 +00:00
|
|
|
{
|
|
|
|
TaikoHitObject? hitObject = GetMostValidObject() as TaikoHitObject;
|
|
|
|
|
|
|
|
if (hitObject == null)
|
|
|
|
return;
|
|
|
|
|
2023-06-30 09:09:50 +00:00
|
|
|
var originalSample = hitObject.CreateHitSampleInfo(hitType == HitType.Rim ? HitSampleInfo.HIT_CLAP : HitSampleInfo.HIT_NORMAL);
|
2023-06-30 07:17:45 +00:00
|
|
|
|
|
|
|
// If the sample is provided by a legacy skin, we should not try and do anything special.
|
2023-06-30 09:09:50 +00:00
|
|
|
if (skinSource.FindProvider(s => s.GetSample(originalSample) != null) is LegacySkinTransformer)
|
2023-06-30 07:17:45 +00:00
|
|
|
{
|
2023-06-30 08:50:32 +00:00
|
|
|
base.Play(hitType, strong);
|
2023-06-30 07:17:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// let the magic begin...
|
2023-06-30 09:43:37 +00:00
|
|
|
var samplesToPlay = new List<ISampleInfo> { new VolumeAwareHitSampleInfo(originalSample, strong) };
|
2023-06-30 07:03:11 +00:00
|
|
|
|
2023-06-30 09:43:37 +00:00
|
|
|
if (strong && hitType == HitType.Rim && canPlayFlourish(hitObject))
|
|
|
|
samplesToPlay.Add(new VolumeAwareHitSampleInfo(hitObject.CreateHitSampleInfo(HitSampleInfo.HIT_FLOURISH), true));
|
|
|
|
|
|
|
|
PlaySamples(samplesToPlay.ToArray());
|
|
|
|
}
|
|
|
|
|
|
|
|
private bool canPlayFlourish(TaikoHitObject hitObject)
|
|
|
|
{
|
|
|
|
double? lastFlourish = null;
|
|
|
|
|
|
|
|
// TODO: check on nested strong hits. we're not accounting for them here yet.
|
|
|
|
|
|
|
|
var hitObjects = hitObjectContainer.AliveObjects
|
|
|
|
.Reverse()
|
|
|
|
.Select(d => d.HitObject)
|
|
|
|
.OfType<Hit>()
|
|
|
|
.Where(h => h.IsStrong && h.Type == HitType.Rim);
|
|
|
|
|
|
|
|
// Add an additional 'flourish' sample to strong rim hits (that are at least `time_between_flourishes` apart).
|
|
|
|
// This is applied to hitobjects in reverse order, as to sound more musically coherent by biasing towards to
|
|
|
|
// end of groups/combos of strong rim hits instead of the start.
|
|
|
|
foreach (var h in hitObjects)
|
2023-06-30 07:03:11 +00:00
|
|
|
{
|
2023-06-30 09:43:37 +00:00
|
|
|
bool canFlourish = lastFlourish == null || lastFlourish - h.StartTime >= time_between_flourishes;
|
|
|
|
|
|
|
|
if (canFlourish)
|
|
|
|
lastFlourish = h.StartTime;
|
|
|
|
|
|
|
|
if (h == hitObject)
|
|
|
|
return canFlourish;
|
2023-06-30 07:17:45 +00:00
|
|
|
}
|
2023-06-30 09:43:37 +00:00
|
|
|
|
|
|
|
return false;
|
2023-06-30 07:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private class VolumeAwareHitSampleInfo : HitSampleInfo
|
|
|
|
{
|
|
|
|
public const int SAMPLE_VOLUME_THRESHOLD_HARD = 90;
|
|
|
|
public const int SAMPLE_VOLUME_THRESHOLD_MEDIUM = 60;
|
|
|
|
|
|
|
|
public VolumeAwareHitSampleInfo(HitSampleInfo sampleInfo, bool isStrong = false)
|
|
|
|
: base(sampleInfo.Name, isStrong ? BANK_STRONG : getBank(sampleInfo.Bank, sampleInfo.Name, sampleInfo.Volume), sampleInfo.Suffix, sampleInfo.Volume)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public override IEnumerable<string> LookupNames
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
foreach (string name in base.LookupNames)
|
|
|
|
yield return name.Insert(name.LastIndexOf('/') + 1, "Argon/taiko-");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static string getBank(string originalBank, string sampleName, int volume)
|
|
|
|
{
|
|
|
|
// So basically we're overwriting mapper's bank intentions here.
|
|
|
|
// The rationale is that most taiko beatmaps only use a single bank, but regularly adjust volume.
|
|
|
|
|
|
|
|
switch (sampleName)
|
|
|
|
{
|
|
|
|
case HIT_NORMAL:
|
|
|
|
case HIT_CLAP:
|
|
|
|
{
|
|
|
|
if (volume >= SAMPLE_VOLUME_THRESHOLD_HARD)
|
|
|
|
return BANK_DRUM;
|
|
|
|
|
|
|
|
if (volume >= SAMPLE_VOLUME_THRESHOLD_MEDIUM)
|
|
|
|
return BANK_NORMAL;
|
|
|
|
|
|
|
|
return BANK_SOFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return originalBank;
|
|
|
|
}
|
2023-06-30 07:03:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|