1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00

Add balance adjust to base implementation of DrumSampleTriggerSource

This commit is contained in:
Dean Herbert 2023-06-30 16:14:52 +09:00
parent ae86fc736a
commit beed390031
4 changed files with 43 additions and 11 deletions

View File

@ -10,13 +10,13 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Argon
{ {
public partial class ArgonDrumSamplePlayer : DrumSamplePlayer public partial class ArgonDrumSamplePlayer : DrumSamplePlayer
{ {
protected override DrumSampleTriggerSource CreateTriggerSource(HitObjectContainer hitObjectContainer) => protected override DrumSampleTriggerSource CreateTriggerSource(HitObjectContainer hitObjectContainer, SampleBalance balance) =>
new ArgonDrumSampleTriggerSource(hitObjectContainer); new ArgonDrumSampleTriggerSource(hitObjectContainer, balance);
public partial class ArgonDrumSampleTriggerSource : DrumSampleTriggerSource public partial class ArgonDrumSampleTriggerSource : DrumSampleTriggerSource
{ {
public ArgonDrumSampleTriggerSource(HitObjectContainer hitObjectContainer) public ArgonDrumSampleTriggerSource(HitObjectContainer hitObjectContainer, SampleBalance balance)
: base(hitObjectContainer) : base(hitObjectContainer, balance)
{ {
} }

View File

@ -25,14 +25,14 @@ namespace osu.Game.Rulesets.Taiko.UI
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
leftRimSampleTriggerSource = CreateTriggerSource(hitObjectContainer), leftRimSampleTriggerSource = CreateTriggerSource(hitObjectContainer, SampleBalance.Left),
leftCentreSampleTriggerSource = CreateTriggerSource(hitObjectContainer), leftCentreSampleTriggerSource = CreateTriggerSource(hitObjectContainer, SampleBalance.Left),
rightCentreSampleTriggerSource = CreateTriggerSource(hitObjectContainer), rightCentreSampleTriggerSource = CreateTriggerSource(hitObjectContainer, SampleBalance.Right),
rightRimSampleTriggerSource = CreateTriggerSource(hitObjectContainer), rightRimSampleTriggerSource = CreateTriggerSource(hitObjectContainer, SampleBalance.Right),
}; };
} }
protected virtual DrumSampleTriggerSource CreateTriggerSource(HitObjectContainer hitObjectContainer) protected virtual DrumSampleTriggerSource CreateTriggerSource(HitObjectContainer hitObjectContainer, SampleBalance balance)
=> new DrumSampleTriggerSource(hitObjectContainer); => new DrumSampleTriggerSource(hitObjectContainer);
public bool OnPressed(KeyBindingPressEvent<TaikoAction> e) public bool OnPressed(KeyBindingPressEvent<TaikoAction> e)

View File

@ -2,17 +2,35 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using osu.Framework.Utils;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko.UI namespace osu.Game.Rulesets.Taiko.UI
{ {
public partial class DrumSampleTriggerSource : GameplaySampleTriggerSource public partial class DrumSampleTriggerSource : GameplaySampleTriggerSource
{ {
public DrumSampleTriggerSource(HitObjectContainer hitObjectContainer) private const double stereo_separation = 0.2;
public DrumSampleTriggerSource(HitObjectContainer hitObjectContainer, SampleBalance balance = SampleBalance.Centre)
: base(hitObjectContainer) : base(hitObjectContainer)
{ {
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;
}
} }
public virtual void Play(HitType hitType) public virtual void Play(HitType hitType)
@ -39,5 +57,19 @@ namespace osu.Game.Rulesets.Taiko.UI
} }
public override void Play() => throw new InvalidOperationException(@"Use override with HitType parameter instead"); public override void Play() => throw new InvalidOperationException(@"Use override with HitType parameter instead");
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
} }
} }

View File

@ -142,7 +142,7 @@ namespace osu.Game.Rulesets.UI
} }
} }
private SkinnableSound getNextSample() protected SkinnableSound GetNextSample()
{ {
SkinnableSound hitSound = hitSounds[nextHitSoundIndex]; SkinnableSound hitSound = hitSounds[nextHitSoundIndex];