1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-25 12:30:17 +08:00

Update a few sample playback usages to use new helper method

This commit is contained in:
Dean Herbert
2026-03-07 23:39:17 +09:00
Unverified
parent 14ae2312ff
commit e3a0464e90
4 changed files with 9 additions and 27 deletions
@@ -10,7 +10,7 @@ using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osu.Game.Audio;
namespace osu.Game.Graphics.Containers
{
@@ -52,12 +52,8 @@ namespace osu.Game.Graphics.Containers
if (Time.Current - sampleLastPlaybackTime <= 35)
return;
var channel = sampleSwap?.GetChannel();
if (channel == null)
return;
SamplePlaybackHelper.PlayWithRandomPitch(sampleSwap, pitchVariation: 0.04);
channel.Frequency.Value = 0.96 + RNG.NextDouble(0.08);
channel.Play();
sampleLastPlaybackTime = Time.Current;
}
@@ -8,6 +8,7 @@ using osu.Framework.Audio.Sample;
using osu.Framework.Extensions;
using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Audio;
using osuTK.Input;
namespace osu.Game.Graphics.UserInterface
@@ -55,15 +56,7 @@ namespace osu.Game.Graphics.UserInterface
return base.OnClick(e);
}
public void PlayClickSample()
{
var channel = Enabled.Value ? sampleClick?.GetChannel() : sampleClickDisabled?.GetChannel();
if (channel != null)
{
channel.Frequency.Value = 0.99 + RNG.NextDouble(0.02);
channel.Play();
}
}
public void PlayClickSample() =>
SamplePlaybackHelper.PlayWithRandomPitch(Enabled.Value ? sampleClick : sampleClickDisabled, pitchVariation: 0.01);
}
}
@@ -9,7 +9,7 @@ using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Utils;
using osu.Game.Audio;
namespace osu.Game.Graphics.UserInterface
{
@@ -43,8 +43,7 @@ namespace osu.Game.Graphics.UserInterface
if (!Enabled.Value)
return;
sampleHover.Frequency.Value = 0.98 + RNG.NextDouble(0.04);
sampleHover.Play();
SamplePlaybackHelper.PlayWithRandomPitch(sampleHover, pitchVariation: 0.02);
}
}
}
@@ -15,6 +15,7 @@ using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Framework.Timing;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@@ -414,14 +415,7 @@ namespace osu.Game.Screens.Edit.Timing
if (!IsBeatSyncedWithTrack || !EnableClicking)
return;
var channel = beatIndex % timingPoint.TimeSignature.Numerator == 0 ? sampleTickDownbeat?.GetChannel() : sampleTick?.GetChannel();
if (channel == null)
return;
channel.Frequency.Value = RNG.NextDouble(0.98f, 1.02f);
channel.Play();
SamplePlaybackHelper.PlayWithRandomPitch(beatIndex % timingPoint.TimeSignature.Numerator == 0 ? sampleTickDownbeat : sampleTick, 0.02f);
Ticked?.Invoke();
}
}