// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Bindables; using osu.Game.Audio; namespace osu.Game.Beatmaps.ControlPoints { public class SampleControlPoint : ControlPoint { public const string DEFAULT_BANK = "normal"; /// /// The default sample bank at this control point. /// public readonly Bindable SampleBankBindable = new Bindable(DEFAULT_BANK) { Default = DEFAULT_BANK }; /// /// The speed multiplier at this control point. /// public string SampleBank { get => SampleBankBindable.Value; set => SampleBankBindable.Value = value; } /// /// The default sample bank at this control point. /// public readonly BindableInt SampleVolumeBindable = new BindableInt(100) { MinValue = 0, MaxValue = 100, Default = 100 }; /// /// The default sample volume at this control point. /// public int SampleVolume { get => SampleVolumeBindable.Value; set => SampleVolumeBindable.Value = value; } /// /// Create a SampleInfo based on the sample settings in this control point. /// /// The name of the same. /// A populated . public HitSampleInfo GetSampleInfo(string sampleName = HitSampleInfo.HIT_NORMAL) => new HitSampleInfo { Bank = SampleBank, Name = sampleName, Volume = SampleVolume, }; /// /// Applies and to a if necessary, returning the modified . /// /// The . This will not be modified. /// The modified . This does not share a reference with . public virtual HitSampleInfo ApplyTo(HitSampleInfo hitSampleInfo) { var newSampleInfo = hitSampleInfo.Clone(); newSampleInfo.Bank = hitSampleInfo.Bank ?? SampleBank; newSampleInfo.Volume = hitSampleInfo.Volume > 0 ? hitSampleInfo.Volume : SampleVolume; return newSampleInfo; } public override bool IsRedundant(ControlPoint existing) => existing is SampleControlPoint existingSample && SampleBank == existingSample.SampleBank && SampleVolume == existingSample.SampleVolume; } }