From b219a371a93d82c3638df3b47f51e85d20f1fb94 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 6 Nov 2023 18:29:51 +0900 Subject: [PATCH] Move sample playback logic local to avoid edge case with no bonus ticks Can't see a better way of doing this. --- .../Objects/Drawables/DrawableSpinner.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index aa43532f65..e159d06a02 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -45,6 +45,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private const float spinning_sample_initial_frequency = 1.0f; private const float spinning_sample_modulated_base_frequency = 0.5f; + private SkinnableSound maxBonusSample; + /// /// The amount of bonus score gained from spinning after the required number of spins, for display purposes. /// @@ -109,6 +111,10 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME, Looping = true, Frequency = { Value = spinning_sample_initial_frequency } + }, + maxBonusSample = new SkinnableSound + { + MinimumSampleVolume = MINIMUM_SAMPLE_VOLUME, } }); @@ -128,6 +134,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables base.OnFree(); spinningSample.ClearSamples(); + maxBonusSample.ClearSamples(); } protected override void LoadSamples() @@ -136,6 +143,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables spinningSample.Samples = HitObject.CreateSpinningSamples().Cast().ToArray(); spinningSample.Frequency.Value = spinning_sample_initial_frequency; + + maxBonusSample.Samples = new ISampleInfo[] { HitObject.CreateHitSampleInfo("spinnerbonus") }; } private void updateSpinningSample(ValueChangedEvent tracking) @@ -157,6 +166,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { base.StopAllSamples(); spinningSample?.Stop(); + maxBonusSample?.Stop(); } protected override void AddNestedHitObject(DrawableHitObject hitObject) @@ -303,8 +313,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private static readonly int score_per_tick = new SpinnerBonusTick.OsuSpinnerBonusTickJudgement().MaxNumericResult; - private int lastMaxSamplePlayback; - private void updateBonusScore() { if (ticks.Count == 0) @@ -327,9 +335,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (tick == null) { // we still want to play a sound. this will probably be a new sound in the future, but for now let's continue playing the bonus sound. - // round robin to avoid hitting playback concurrency. - tick = ticks.OfType().Skip(lastMaxSamplePlayback++ % HitObject.MaximumBonusSpins).First(); - tick.PlaySamples(); + // TODO: this doesn't concurrency. i can't figure out how to make it concurrency. samples are bad and need a refactor. + maxBonusSample.Play(); } else tick.TriggerResult(true);