Skip to content

Commit

Permalink
Adjust default offsets based on bass operational mode
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Dec 27, 2023
1 parent d5a939e commit ce4fb65
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion osu.Game/Beatmaps/FramedBeatmapClock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
using System.Diagnostics;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Timing;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Screens.Play;
using Vulkan.Xlib;

Check failure on line 15 in osu.Game/Beatmaps/FramedBeatmapClock.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary.

Check failure on line 15 in osu.Game/Beatmaps/FramedBeatmapClock.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary.

namespace osu.Game.Beatmaps
{
Expand Down Expand Up @@ -44,6 +46,8 @@ public partial class FramedBeatmapClock : Component, IFrameBasedClock, IAdjustab

private readonly DecouplingFramedClock decoupledTrack;

private IBindable<bool>? usingGlobalMixer;

[Resolved]
private OsuConfigManager config { get; set; } = null!;

Expand All @@ -69,7 +73,7 @@ public FramedBeatmapClock(bool applyOffsets, bool requireDecoupling, IClock? sou
{
// Audio timings in general with newer BASS versions don't match stable.
// This only seems to be required on windows. We need to eventually figure out why, with a bit of luck.
platformOffsetClock = new OffsetCorrectionClock(interpolatedTrack, ExternalPauseFrequencyAdjust) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 15 : 0 };
platformOffsetClock = new OffsetCorrectionClock(interpolatedTrack, ExternalPauseFrequencyAdjust);

// User global offset (set in settings) should also be applied.
userGlobalOffsetClock = new OffsetCorrectionClock(platformOffsetClock, ExternalPauseFrequencyAdjust);
Expand All @@ -83,6 +87,23 @@ public FramedBeatmapClock(bool applyOffsets, bool requireDecoupling, IClock? sou
}
}

[BackgroundDependencyLoader]
private void load(AudioManager audioManager)
{
if (platformOffsetClock != null)
{
if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows)
{
usingGlobalMixer = audioManager.UsingGlobalMixer.GetBoundCopy();
usingGlobalMixer.BindValueChanged(usingMixer =>
{
// known "good" values, aka defaults which work for the majority of users.
platformOffsetClock.Offset = usingMixer.NewValue ? -35 : 15;
});
}
}
}

protected override void LoadComplete()
{
base.LoadComplete();
Expand Down

0 comments on commit ce4fb65

Please sign in to comment.