// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing.Reading { public class EffectiveBPMPreprocessor { private readonly IList noteObjects; private readonly double globalSliderVelocity; public EffectiveBPMPreprocessor(IBeatmap beatmap, List noteObjects) { this.noteObjects = noteObjects; globalSliderVelocity = beatmap.Difficulty.SliderMultiplier; } /// /// Calculates and sets the effective BPM and slider velocity for each note object, considering clock rate and scroll speed. /// public void ProcessEffectiveBPM(ControlPointInfo controlPointInfo, double clockRate) { foreach (var currentNoteObject in noteObjects) { double startTime = currentNoteObject.StartTime * clockRate; // Retrieve the timing point at the note's start time TimingControlPoint currentControlPoint = controlPointInfo.TimingPointAt(startTime); // Calculate the slider velocity at the note's start time. double currentSliderVelocity = calculateSliderVelocity(controlPointInfo, startTime, clockRate); currentNoteObject.CurrentSliderVelocity = currentSliderVelocity; currentNoteObject.EffectiveBPM = currentControlPoint.BPM * currentSliderVelocity; } } /// /// Calculates the slider velocity based on control point info and clock rate. /// private double calculateSliderVelocity(ControlPointInfo controlPointInfo, double startTime, double clockRate) { var activeEffectControlPoint = controlPointInfo.EffectPointAt(startTime); return globalSliderVelocity * (activeEffectControlPoint.ScrollSpeed) * clockRate; } } }