1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 05:02:55 +08:00

Merge pull request #18744 from nekodex/new-metronome-sfx

New audio feedback for metronome
This commit is contained in:
Dean Herbert 2022-06-21 17:16:41 +09:00 committed by GitHub
commit b7b7de115f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 19 deletions

View File

@ -51,7 +51,7 @@
<Reference Include="Java.Interop" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.616.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.618.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.615.0" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">

View File

@ -37,10 +37,12 @@ namespace osu.Game.Screens.Edit.Timing
private IAdjustableClock metronomeClock;
private Sample clunk;
private Sample sampleTick;
private Sample sampleTickDownbeat;
private Sample sampleLatch;
[CanBeNull]
private ScheduledDelegate clunkDelegate;
private ScheduledDelegate tickPlaybackDelegate;
[Resolved]
private OverlayColourProvider overlayColourProvider { get; set; }
@ -55,7 +57,9 @@ namespace osu.Game.Screens.Edit.Timing
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
clunk = audio.Samples.Get(@"Multiplayer/countdown-tick");
sampleTick = audio.Samples.Get(@"UI/metronome-tick");
sampleTickDownbeat = audio.Samples.Get(@"UI/metronome-tick-downbeat");
sampleLatch = audio.Samples.Get(@"UI/metronome-latch");
const float taper = 25;
const float swing_vertical_offset = -23;
@ -227,6 +231,8 @@ namespace osu.Game.Screens.Edit.Timing
private readonly BindableInt interpolatedBpm = new BindableInt();
private ScheduledDelegate latchDelegate;
protected override void LoadComplete()
{
base.LoadComplete();
@ -261,16 +267,27 @@ namespace osu.Game.Screens.Edit.Timing
{
swing.ClearTransforms(true);
using (swing.BeginDelayedSequence(350))
isSwinging = false;
tickPlaybackDelegate?.Cancel();
tickPlaybackDelegate = null;
// instantly latch if pendulum arm is close enough to center (to prevent awkward delayed playback of latch sound)
if (Precision.AlmostEquals(swing.Rotation, 0, 1))
{
swing.RotateTo(0, 60, Easing.OutQuint);
sampleLatch?.Play();
return;
}
using (BeginDelayedSequence(350))
{
swing.RotateTo(0, 1000, Easing.OutQuint);
stick.FadeColour(overlayColourProvider.Colour2, 1000, Easing.OutQuint);
using (BeginDelayedSequence(380))
latchDelegate = Schedule(() => sampleLatch?.Play());
}
isSwinging = false;
clunkDelegate?.Cancel();
clunkDelegate = null;
}
}
@ -285,6 +302,9 @@ namespace osu.Game.Screens.Edit.Timing
isSwinging = true;
latchDelegate?.Cancel();
latchDelegate = null;
float currentAngle = swing.Rotation;
float targetAngle = currentAngle > 0 ? -angle : angle;
@ -296,18 +316,18 @@ namespace osu.Game.Screens.Edit.Timing
{
stick.FlashColour(overlayColourProvider.Content1, beatLength, Easing.OutQuint);
clunkDelegate = Schedule(() =>
tickPlaybackDelegate = Schedule(() =>
{
if (!EnableClicking)
return;
var channel = clunk?.GetChannel();
var channel = beatIndex % timingPoint.TimeSignature.Numerator == 0 ? sampleTickDownbeat?.GetChannel() : sampleTick?.GetChannel();
if (channel != null)
{
channel.Frequency.Value = RNG.NextDouble(0.98f, 1.02f);
channel.Play();
}
if (channel == null)
return;
channel.Frequency.Value = RNG.NextDouble(0.98f, 1.02f);
channel.Play();
});
}
}

View File

@ -37,7 +37,7 @@
</PackageReference>
<PackageReference Include="Realm" Version="10.14.0" />
<PackageReference Include="ppy.osu.Framework" Version="2022.615.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.616.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.618.0" />
<PackageReference Include="Sentry" Version="3.17.1" />
<PackageReference Include="SharpCompress" Version="0.31.0" />
<PackageReference Include="NUnit" Version="3.13.3" />

View File

@ -62,7 +62,7 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.615.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.616.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.618.0" />
</ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
<PropertyGroup>