Skip to content

Commit

Permalink
Implement IAdjustableAudioComponent in MasterGameplayClockContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Sep 5, 2022
1 parent 6296c97 commit e33486a
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions osu.Game/Screens/Play/MasterGameplayClockContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace osu.Game.Screens.Play
/// <remarks>
/// This is intended to be used as a single controller for gameplay, or as a reference source for other <see cref="GameplayClockContainer"/>s.
/// </remarks>
public class MasterGameplayClockContainer : GameplayClockContainer, IBeatSyncProvider
public class MasterGameplayClockContainer : GameplayClockContainer, IBeatSyncProvider, IAdjustableAudioComponent
{
/// <summary>
/// Duration before gameplay start time required before skip button displays.
Expand All @@ -41,6 +41,8 @@ public class MasterGameplayClockContainer : GameplayClockContainer, IBeatSyncPro

private readonly WorkingBeatmap beatmap;

private readonly Track track;

private readonly double skipTargetTime;

private readonly List<Bindable<double>> nonGameplayAdjustments = new List<Bindable<double>>();
Expand All @@ -66,6 +68,7 @@ public class MasterGameplayClockContainer : GameplayClockContainer, IBeatSyncPro
public MasterGameplayClockContainer(WorkingBeatmap beatmap, double skipTargetTime)
: base(beatmap.Track, true)
{
track = beatmap.Track;
this.beatmap = beatmap;
this.skipTargetTime = skipTargetTime;

Expand Down Expand Up @@ -195,9 +198,6 @@ private void addSourceClockAdjustments()
if (speedAdjustmentsApplied)
return;

if (SourceClock is not Track track)
return;

track.AddAdjustment(AdjustableProperty.Frequency, GameplayClock.ExternalPauseFrequencyAdjust);
track.AddAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);

Expand All @@ -212,9 +212,6 @@ private void removeSourceClockAdjustments()
if (!speedAdjustmentsApplied)
return;

if (SourceClock is not Track track)
return;

track.RemoveAdjustment(AdjustableProperty.Frequency, GameplayClock.ExternalPauseFrequencyAdjust);
track.RemoveAdjustment(AdjustableProperty.Tempo, UserPlaybackRate);

Expand All @@ -234,5 +231,29 @@ protected override void Dispose(bool isDisposing)
IClock IBeatSyncProvider.Clock => this;

ChannelAmplitudes IHasAmplitudes.CurrentAmplitudes => beatmap.TrackLoaded ? beatmap.Track.CurrentAmplitudes : ChannelAmplitudes.Empty;

void IAdjustableAudioComponent.AddAdjustment(AdjustableProperty type, IBindable<double> adjustBindable) =>
track.AddAdjustment(type, adjustBindable);

void IAdjustableAudioComponent.RemoveAdjustment(AdjustableProperty type, IBindable<double> adjustBindable) =>
track.RemoveAdjustment(type, adjustBindable);

public void RemoveAllAdjustments(AdjustableProperty type)
{
throw new NotImplementedException();
}

public void BindAdjustments(IAggregateAudioAdjustment component) => throw new NotImplementedException();
public void UnbindAdjustments(IAggregateAudioAdjustment component) => throw new NotImplementedException();

public BindableNumber<double> Volume => throw new NotImplementedException();
public BindableNumber<double> Balance => throw new NotImplementedException();
public BindableNumber<double> Frequency => throw new NotImplementedException();
public BindableNumber<double> Tempo => throw new NotImplementedException();

public IBindable<double> AggregateVolume => throw new NotImplementedException();
public IBindable<double> AggregateBalance => throw new NotImplementedException();
public IBindable<double> AggregateFrequency => throw new NotImplementedException();
public IBindable<double> AggregateTempo => throw new NotImplementedException();
}
}

0 comments on commit e33486a

Please sign in to comment.