mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 22:33:05 +08:00
Merge pull request #25316 from peppy/metronome-always-play-tick
Decouple metronome tick playback from pendulum movement
This commit is contained in:
commit
850866e7f4
@ -34,16 +34,18 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
private IAdjustableClock metronomeClock = null!;
|
private IAdjustableClock metronomeClock = null!;
|
||||||
|
|
||||||
private Sample? sampleTick;
|
|
||||||
private Sample? sampleTickDownbeat;
|
|
||||||
private Sample? sampleLatch;
|
private Sample? sampleLatch;
|
||||||
|
|
||||||
private ScheduledDelegate? tickPlaybackDelegate;
|
private readonly MetronomeTick metronomeTick = new MetronomeTick();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider overlayColourProvider { get; set; } = null!;
|
private OverlayColourProvider overlayColourProvider { get; set; } = null!;
|
||||||
|
|
||||||
public bool EnableClicking { get; set; } = true;
|
public bool EnableClicking
|
||||||
|
{
|
||||||
|
get => metronomeTick.EnableClicking;
|
||||||
|
set => metronomeTick.EnableClicking = value;
|
||||||
|
}
|
||||||
|
|
||||||
public MetronomeDisplay()
|
public MetronomeDisplay()
|
||||||
{
|
{
|
||||||
@ -53,8 +55,6 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audio)
|
private void load(AudioManager audio)
|
||||||
{
|
{
|
||||||
sampleTick = audio.Samples.Get(@"UI/metronome-tick");
|
|
||||||
sampleTickDownbeat = audio.Samples.Get(@"UI/metronome-tick-downbeat");
|
|
||||||
sampleLatch = audio.Samples.Get(@"UI/metronome-latch");
|
sampleLatch = audio.Samples.Get(@"UI/metronome-latch");
|
||||||
|
|
||||||
const float taper = 25;
|
const float taper = 25;
|
||||||
@ -67,8 +67,11 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
metronomeTick.Ticked = onTickPlayed;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
|
metronomeTick,
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
Name = @"Taper adjust",
|
Name = @"Taper adjust",
|
||||||
@ -265,9 +268,6 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
isSwinging = false;
|
isSwinging = false;
|
||||||
|
|
||||||
tickPlaybackDelegate?.Cancel();
|
|
||||||
tickPlaybackDelegate = null;
|
|
||||||
|
|
||||||
// instantly latch if pendulum arm is close enough to center (to prevent awkward delayed playback of latch sound)
|
// 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))
|
if (Precision.AlmostEquals(swing.Rotation, 0, 1))
|
||||||
{
|
{
|
||||||
@ -306,16 +306,42 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
float targetAngle = currentAngle > 0 ? -angle : angle;
|
float targetAngle = currentAngle > 0 ? -angle : angle;
|
||||||
|
|
||||||
swing.RotateTo(targetAngle, beatLength, Easing.InOutQuad);
|
swing.RotateTo(targetAngle, beatLength, Easing.InOutQuad);
|
||||||
|
}
|
||||||
|
|
||||||
if (currentAngle != 0 && Math.Abs(currentAngle - targetAngle) > angle * 1.8f && isSwinging)
|
private void onTickPlayed()
|
||||||
{
|
|
||||||
using (BeginDelayedSequence(beatLength / 2))
|
|
||||||
{
|
{
|
||||||
|
// Originally, this flash only occurred when the pendulum correctly passess the centre.
|
||||||
|
// Mappers weren't happy with the metronome tick not playing immediately after starting playback
|
||||||
|
// so now this matches the actual tick sample.
|
||||||
stick.FlashColour(overlayColourProvider.Content1, beatLength, Easing.OutQuint);
|
stick.FlashColour(overlayColourProvider.Content1, beatLength, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
tickPlaybackDelegate = Schedule(() =>
|
private partial class MetronomeTick : BeatSyncedContainer
|
||||||
{
|
{
|
||||||
if (!EnableClicking)
|
public bool EnableClicking;
|
||||||
|
|
||||||
|
private Sample? sampleTick;
|
||||||
|
private Sample? sampleTickDownbeat;
|
||||||
|
|
||||||
|
public Action? Ticked;
|
||||||
|
|
||||||
|
public MetronomeTick()
|
||||||
|
{
|
||||||
|
AllowMistimedEventFiring = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(AudioManager audio)
|
||||||
|
{
|
||||||
|
sampleTick = audio.Samples.Get(@"UI/metronome-tick");
|
||||||
|
sampleTickDownbeat = audio.Samples.Get(@"UI/metronome-tick-downbeat");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||||
|
{
|
||||||
|
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||||
|
|
||||||
|
if (!IsBeatSyncedWithTrack || !EnableClicking)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var channel = beatIndex % timingPoint.TimeSignature.Numerator == 0 ? sampleTickDownbeat?.GetChannel() : sampleTick?.GetChannel();
|
var channel = beatIndex % timingPoint.TimeSignature.Numerator == 0 ? sampleTickDownbeat?.GetChannel() : sampleTick?.GetChannel();
|
||||||
@ -325,8 +351,8 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
channel.Frequency.Value = RNG.NextDouble(0.98f, 1.02f);
|
channel.Frequency.Value = RNG.NextDouble(0.98f, 1.02f);
|
||||||
channel.Play();
|
channel.Play();
|
||||||
});
|
|
||||||
}
|
Ticked?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user