From 66a02374dae305eefddbb04b9864482457246622 Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Thu, 22 Dec 2022 01:23:24 +0300 Subject: [PATCH 1/9] Clear cached waveform on track change in editor --- osu.Game/Beatmaps/WorkingBeatmap.cs | 8 +++++++- osu.Game/Screens/Edit/Setup/ResourcesSection.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 393c4ba892..f454f08e87 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -48,7 +48,7 @@ namespace osu.Game.Beatmaps private readonly object beatmapFetchLock = new object(); - private readonly Lazy waveform; + private Lazy waveform; private readonly Lazy storyboard; private readonly Lazy skin; private Track track; // track is not Lazy as we allow transferring and loading multiple times. @@ -329,6 +329,12 @@ namespace osu.Game.Beatmaps #endregion + public void InvalidateWaveform() + { + if (waveform.IsValueCreated) + waveform = new Lazy(GetWaveform); + } + public override string ToString() => BeatmapInfo.ToString(); public abstract Stream GetStream(string storagePath); diff --git a/osu.Game/Screens/Edit/Setup/ResourcesSection.cs b/osu.Game/Screens/Edit/Setup/ResourcesSection.cs index ca0f50cd34..01217021fd 100644 --- a/osu.Game/Screens/Edit/Setup/ResourcesSection.cs +++ b/osu.Game/Screens/Edit/Setup/ResourcesSection.cs @@ -118,7 +118,7 @@ namespace osu.Game.Screens.Edit.Setup } working.Value.Metadata.AudioFile = destination.Name; - + working.Value.InvalidateWaveform(); editorBeatmap.SaveState(); music.ReloadCurrentTrack(); From 7089bb6c2399ccb6c511acb6465b8ce3053b54c5 Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Thu, 22 Dec 2022 01:23:59 +0300 Subject: [PATCH 2/9] Listen for track reload in timeline --- .../Compose/Components/Timeline/Timeline.cs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs index 45f902d0de..d135d108de 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs @@ -15,6 +15,7 @@ using osu.Framework.Input.Events; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics; +using osu.Game.Overlays; using osu.Game.Rulesets.Edit; using osuTK; using osuTK.Input; @@ -35,14 +36,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline public readonly Bindable TicksVisible = new Bindable(); - public readonly IBindable Beatmap = new Bindable(); - [Resolved] private EditorClock editorClock { get; set; } [Resolved] private EditorBeatmap editorBeatmap { get; set; } + [Resolved] + private MusicController musicController { get; set; } + /// /// The timeline's scroll position in the last frame. /// @@ -139,11 +141,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline waveformOpacity = config.GetBindable(OsuSetting.EditorWaveformOpacity); - Beatmap.BindTo(beatmap); - Beatmap.BindValueChanged(b => - { - waveform.Waveform = b.NewValue.Waveform; - }, true); + musicController.TrackChanged += onTrackReload; + waveform.Waveform = beatmap.Value.Waveform; Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom); } @@ -181,6 +180,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private void updateWaveformOpacity() => waveform.FadeTo(WaveformVisible.Value ? waveformOpacity.Value : 0, 200, Easing.OutQuint); + private void onTrackReload(WorkingBeatmap beatmap, TrackChangeDirection tcd) + { + waveform.Waveform = beatmap.Waveform; + } + protected override void Update() { base.Update(); @@ -321,5 +325,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline double time = TimeAtPosition(Content.ToLocalSpace(screenSpacePosition).X); return new SnapResult(screenSpacePosition, beatSnapProvider.SnapTime(time)); } + + protected override void Dispose(bool isDisposing) + { + musicController.TrackChanged -= onTrackReload; + base.Dispose(isDisposing); + } } } From a18ece8610acee982222a611212345971b45632d Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Thu, 22 Dec 2022 01:24:23 +0300 Subject: [PATCH 3/9] Listen for track reload in timing screen --- .../Screens/Edit/Timing/TapTimingControl.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs index 09b3851333..10db426416 100644 --- a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs +++ b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; +using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; @@ -29,9 +30,13 @@ namespace osu.Game.Screens.Edit.Timing [Resolved] private Bindable selectedGroup { get; set; } = null!; + [Resolved] + private MusicController musicController { get; set; } = null!; + private readonly BindableBool isHandlingTapping = new BindableBool(); private MetronomeDisplay metronome = null!; + private Container waveformContainer = null!; [BackgroundDependencyLoader] private void load(OverlayColourProvider colourProvider, OsuColour colours) @@ -88,7 +93,11 @@ namespace osu.Game.Screens.Edit.Timing Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }, - new WaveformComparisonDisplay(), + waveformContainer = new Container + { + RelativeSizeAxes = Axes.Both, + Child = new WaveformComparisonDisplay(), + } } }, } @@ -179,6 +188,13 @@ namespace osu.Game.Screens.Edit.Timing if (handling.NewValue) start(); }, true); + + musicController.TrackChanged += onTrackReload; + } + + private void onTrackReload(WorkingBeatmap beatmap, TrackChangeDirection tcd) + { + waveformContainer.Child = new WaveformComparisonDisplay(); } private void start() @@ -233,6 +249,12 @@ namespace osu.Game.Screens.Edit.Timing timing.BeatLength = 60000 / (timing.BPM + adjust); } + protected override void Dispose(bool isDisposing) + { + musicController.TrackChanged -= onTrackReload; + base.Dispose(isDisposing); + } + private partial class InlineButton : OsuButton { private readonly IconUsage icon; From f2e8776529176f7ec1ab03d12ea4eee6a5a44f18 Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Thu, 22 Dec 2022 15:35:53 +0300 Subject: [PATCH 4/9] Bind to clock instead of music controller --- .../Compose/Components/Timeline/Timeline.cs | 25 +++++++------------ .../Screens/Edit/Timing/TapTimingControl.cs | 21 ++++------------ 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs index d135d108de..918b5f8109 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs @@ -5,6 +5,7 @@ using System; using osu.Framework.Allocation; +using osu.Framework.Audio.Track; using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -15,7 +16,6 @@ using osu.Framework.Input.Events; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics; -using osu.Game.Overlays; using osu.Game.Rulesets.Edit; using osuTK; using osuTK.Input; @@ -42,9 +42,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline [Resolved] private EditorBeatmap editorBeatmap { get; set; } - [Resolved] - private MusicController musicController { get; set; } - /// /// The timeline's scroll position in the last frame. /// @@ -94,6 +91,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private double trackLengthForZoom; + private readonly IBindable track = new Bindable(); + [BackgroundDependencyLoader] private void load(IBindable beatmap, OsuColour colours, OsuConfigManager config) { @@ -141,7 +140,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline waveformOpacity = config.GetBindable(OsuSetting.EditorWaveformOpacity); - musicController.TrackChanged += onTrackReload; + track.BindTo(editorClock.Track); + track.BindValueChanged(_ => + { + waveform.Waveform = beatmap.Value.Waveform; + }, true); + waveform.Waveform = beatmap.Value.Waveform; Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom); @@ -180,11 +184,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private void updateWaveformOpacity() => waveform.FadeTo(WaveformVisible.Value ? waveformOpacity.Value : 0, 200, Easing.OutQuint); - private void onTrackReload(WorkingBeatmap beatmap, TrackChangeDirection tcd) - { - waveform.Waveform = beatmap.Waveform; - } - protected override void Update() { base.Update(); @@ -325,11 +324,5 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline double time = TimeAtPosition(Content.ToLocalSpace(screenSpacePosition).X); return new SnapResult(screenSpacePosition, beatSnapProvider.SnapTime(time)); } - - protected override void Dispose(bool isDisposing) - { - musicController.TrackChanged -= onTrackReload; - base.Dispose(isDisposing); - } } } diff --git a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs index 10db426416..36cd5f8b70 100644 --- a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs +++ b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs @@ -3,13 +3,13 @@ using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Audio.Track; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Input.Events; -using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; @@ -30,8 +30,7 @@ namespace osu.Game.Screens.Edit.Timing [Resolved] private Bindable selectedGroup { get; set; } = null!; - [Resolved] - private MusicController musicController { get; set; } = null!; + private readonly IBindable track = new Bindable(); private readonly BindableBool isHandlingTapping = new BindableBool(); @@ -39,7 +38,7 @@ namespace osu.Game.Screens.Edit.Timing private Container waveformContainer = null!; [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider, OsuColour colours) + private void load(OverlayColourProvider colourProvider, OsuColour colours, EditorClock clock) { const float padding = 10; @@ -189,12 +188,8 @@ namespace osu.Game.Screens.Edit.Timing start(); }, true); - musicController.TrackChanged += onTrackReload; - } - - private void onTrackReload(WorkingBeatmap beatmap, TrackChangeDirection tcd) - { - waveformContainer.Child = new WaveformComparisonDisplay(); + track.BindTo(clock.Track); + track.ValueChanged += _ => waveformContainer.Child = new WaveformComparisonDisplay(); } private void start() @@ -249,12 +244,6 @@ namespace osu.Game.Screens.Edit.Timing timing.BeatLength = 60000 / (timing.BPM + adjust); } - protected override void Dispose(bool isDisposing) - { - musicController.TrackChanged -= onTrackReload; - base.Dispose(isDisposing); - } - private partial class InlineButton : OsuButton { private readonly IconUsage icon; From d0645ce15173c32e45886bac43dfb5bd09df69df Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Thu, 22 Dec 2022 15:59:51 +0300 Subject: [PATCH 5/9] Rewrite waveform invalidation --- osu.Game/Beatmaps/WorkingBeatmap.cs | 23 +++++++++++-------- .../Screens/Edit/Setup/ResourcesSection.cs | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index f454f08e87..e61ec3f2a8 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -34,8 +34,6 @@ namespace osu.Game.Beatmaps // TODO: remove once the fallback lookup is not required (and access via `working.BeatmapInfo.Metadata` directly). public BeatmapMetadata Metadata => BeatmapInfo.Metadata; - public Waveform Waveform => waveform.Value; - public Storyboard Storyboard => storyboard.Value; public Texture Background => GetBackground(); // Texture uses ref counting, so we want to return a new instance every usage. @@ -48,7 +46,7 @@ namespace osu.Game.Beatmaps private readonly object beatmapFetchLock = new object(); - private Lazy waveform; + private Waveform waveform; private readonly Lazy storyboard; private readonly Lazy skin; private Track track; // track is not Lazy as we allow transferring and loading multiple times. @@ -60,7 +58,6 @@ namespace osu.Game.Beatmaps BeatmapInfo = beatmapInfo; BeatmapSetInfo = beatmapInfo.BeatmapSet ?? new BeatmapSetInfo(); - waveform = new Lazy(GetWaveform); storyboard = new Lazy(GetStoryboard); skin = new Lazy(GetSkin); } @@ -171,6 +168,18 @@ namespace osu.Game.Beatmaps #endregion + #region Waveform + + public Waveform Waveform => waveform ??= GetWaveform(); + + /// + /// Reloads waveform of beatmap's track even if one is already cached. + /// + /// Newly loaded waveform. + public Waveform LoadWaveform() => waveform = GetWaveform(); + + #endregion + #region Beatmap public virtual bool BeatmapLoaded => beatmapLoadTask?.IsCompleted ?? false; @@ -329,12 +338,6 @@ namespace osu.Game.Beatmaps #endregion - public void InvalidateWaveform() - { - if (waveform.IsValueCreated) - waveform = new Lazy(GetWaveform); - } - public override string ToString() => BeatmapInfo.ToString(); public abstract Stream GetStream(string storagePath); diff --git a/osu.Game/Screens/Edit/Setup/ResourcesSection.cs b/osu.Game/Screens/Edit/Setup/ResourcesSection.cs index 01217021fd..36ac9883ba 100644 --- a/osu.Game/Screens/Edit/Setup/ResourcesSection.cs +++ b/osu.Game/Screens/Edit/Setup/ResourcesSection.cs @@ -118,7 +118,7 @@ namespace osu.Game.Screens.Edit.Setup } working.Value.Metadata.AudioFile = destination.Name; - working.Value.InvalidateWaveform(); + working.Value.LoadWaveform(); editorBeatmap.SaveState(); music.ReloadCurrentTrack(); From 20370bd5ae4c9350697c357642102861dae7efc4 Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Thu, 22 Dec 2022 20:49:09 +0300 Subject: [PATCH 6/9] Invalidate waveform on track load --- osu.Game/Beatmaps/WorkingBeatmap.cs | 15 ++++++++------- osu.Game/Screens/Edit/Setup/ResourcesSection.cs | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index e61ec3f2a8..345220a3a3 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -105,7 +105,14 @@ namespace osu.Game.Beatmaps public virtual bool TrackLoaded => track != null; - public Track LoadTrack() => track = GetBeatmapTrack() ?? GetVirtualTrack(1000); + public Track LoadTrack() + { + // track could be changed, clearing waveform cache + waveform = null; + + track = GetBeatmapTrack() ?? GetVirtualTrack(1000); + return track; + } public void PrepareTrackForPreview(bool looping, double offsetFromPreviewPoint = 0) { @@ -172,12 +179,6 @@ namespace osu.Game.Beatmaps public Waveform Waveform => waveform ??= GetWaveform(); - /// - /// Reloads waveform of beatmap's track even if one is already cached. - /// - /// Newly loaded waveform. - public Waveform LoadWaveform() => waveform = GetWaveform(); - #endregion #region Beatmap diff --git a/osu.Game/Screens/Edit/Setup/ResourcesSection.cs b/osu.Game/Screens/Edit/Setup/ResourcesSection.cs index 36ac9883ba..ca0f50cd34 100644 --- a/osu.Game/Screens/Edit/Setup/ResourcesSection.cs +++ b/osu.Game/Screens/Edit/Setup/ResourcesSection.cs @@ -118,7 +118,7 @@ namespace osu.Game.Screens.Edit.Setup } working.Value.Metadata.AudioFile = destination.Name; - working.Value.LoadWaveform(); + editorBeatmap.SaveState(); music.ReloadCurrentTrack(); From 30de9ba795a94810411db4791403c03876b13393 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 23 Dec 2022 00:35:59 +0300 Subject: [PATCH 7/9] Dispose previous waveform on track reload --- osu.Game/Beatmaps/WorkingBeatmap.cs | 9 ++++++--- .../Screens/Edit/Compose/Components/Timeline/Timeline.cs | 7 +------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 345220a3a3..ab790617bb 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -46,10 +46,11 @@ namespace osu.Game.Beatmaps private readonly object beatmapFetchLock = new object(); - private Waveform waveform; private readonly Lazy storyboard; private readonly Lazy skin; + private Track track; // track is not Lazy as we allow transferring and loading multiple times. + private Waveform waveform; // waveform is also not Lazy as the track may change. protected WorkingBeatmap(BeatmapInfo beatmapInfo, AudioManager audioManager) { @@ -107,10 +108,12 @@ namespace osu.Game.Beatmaps public Track LoadTrack() { - // track could be changed, clearing waveform cache + track = GetBeatmapTrack() ?? GetVirtualTrack(1000); + + // the track may have changed, recycle the current waveform. + waveform?.Dispose(); waveform = null; - track = GetBeatmapTrack() ?? GetVirtualTrack(1000); return track; } diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs index 918b5f8109..75de15fe56 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/Timeline.cs @@ -141,12 +141,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline waveformOpacity = config.GetBindable(OsuSetting.EditorWaveformOpacity); track.BindTo(editorClock.Track); - track.BindValueChanged(_ => - { - waveform.Waveform = beatmap.Value.Waveform; - }, true); - - waveform.Waveform = beatmap.Value.Waveform; + track.BindValueChanged(_ => waveform.Waveform = beatmap.Value.Waveform, true); Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom); } From f25439e359b0fb67c66b1a1e85a19fa461029a23 Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Fri, 23 Dec 2022 01:54:49 +0300 Subject: [PATCH 8/9] Move track change subscription to LoadComplete --- osu.Game/Screens/Edit/Timing/TapTimingControl.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs index 36cd5f8b70..0d29b69d96 100644 --- a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs +++ b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs @@ -189,6 +189,10 @@ namespace osu.Game.Screens.Edit.Timing }, true); track.BindTo(clock.Track); + } + + protected override void LoadComplete() + { track.ValueChanged += _ => waveformContainer.Child = new WaveformComparisonDisplay(); } From c6e2104ec298647d6a0bb48b86846bbdf6ea7707 Mon Sep 17 00:00:00 2001 From: ansel <79257300125@ya.ru> Date: Fri, 6 Jan 2023 03:46:49 +0300 Subject: [PATCH 9/9] Refresh waveforms instead of recreating the whole component --- .../Screens/Edit/Timing/TapTimingControl.cs | 19 ++----------------- .../Edit/Timing/WaveformComparisonDisplay.cs | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs index 0d29b69d96..bb7a3b8be3 100644 --- a/osu.Game/Screens/Edit/Timing/TapTimingControl.cs +++ b/osu.Game/Screens/Edit/Timing/TapTimingControl.cs @@ -3,7 +3,6 @@ using System.Linq; using osu.Framework.Allocation; -using osu.Framework.Audio.Track; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; @@ -30,15 +29,12 @@ namespace osu.Game.Screens.Edit.Timing [Resolved] private Bindable selectedGroup { get; set; } = null!; - private readonly IBindable track = new Bindable(); - private readonly BindableBool isHandlingTapping = new BindableBool(); private MetronomeDisplay metronome = null!; - private Container waveformContainer = null!; [BackgroundDependencyLoader] - private void load(OverlayColourProvider colourProvider, OsuColour colours, EditorClock clock) + private void load(OverlayColourProvider colourProvider, OsuColour colours) { const float padding = 10; @@ -92,11 +88,7 @@ namespace osu.Game.Screens.Edit.Timing Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }, - waveformContainer = new Container - { - RelativeSizeAxes = Axes.Both, - Child = new WaveformComparisonDisplay(), - } + new WaveformComparisonDisplay() } }, } @@ -187,13 +179,6 @@ namespace osu.Game.Screens.Edit.Timing if (handling.NewValue) start(); }, true); - - track.BindTo(clock.Track); - } - - protected override void LoadComplete() - { - track.ValueChanged += _ => waveformContainer.Child = new WaveformComparisonDisplay(); } private void start() diff --git a/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs b/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs index 6c17aeed54..b5a1ab29d2 100644 --- a/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs +++ b/osu.Game/Screens/Edit/Timing/WaveformComparisonDisplay.cs @@ -4,6 +4,7 @@ using System; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Audio.Track; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Audio; @@ -294,13 +295,18 @@ namespace osu.Game.Screens.Edit.Timing [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; + [Resolved] + private IBindable beatmap { get; set; } = null!; + + private readonly IBindable track = new Bindable(); + public WaveformRow(bool isMainRow) { this.isMainRow = isMainRow; } [BackgroundDependencyLoader] - private void load(IBindable beatmap) + private void load(EditorClock clock) { InternalChildren = new Drawable[] { @@ -330,6 +336,13 @@ namespace osu.Game.Screens.Edit.Timing Colour = colourProvider.Content2 } }; + + track.BindTo(clock.Track); + } + + protected override void LoadComplete() + { + track.ValueChanged += _ => waveformGraph.Waveform = beatmap.Value.Waveform; } public int BeatIndex { set => beatIndexText.Text = value.ToString(); }