-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix most common BPM sometimes displaying to be less or more than the map's BPM range #35827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…length smaller or larger than the actual limits Closes ppy#35807. The reason this closes the aforementioned issue is as follows: Taking https://osu.ppy.sh/beatmapsets/1236180#osu/4650477 as the example, we have: ``` minBeatLength = 342.857142857143 maxBeatLength = 419.58041958042003 mostCommonBeatLength = 342.85700000000003 ``` Note that `mostCommonBeatLength < minBeatLength` here. Taking the inverse of that to compute BPM, we get ``` minBpm = 174.99999999999991 maxBpm = 142.99999999999986 mostCommonBpm = 175.00007291669704 ``` which without DT present doesn't do anything bad, but when DT is engaged (and thus BPM is multiplied by 1.5), midpoint rounding causes the min BPM to become 262, and the most common BPM to become 263.
| double minBeatLength = ControlPointInfo.TimingPoints.Min(t => t.BeatLength); | ||
| double maxBeatLength = ControlPointInfo.TimingPoints.Max(t => t.BeatLength); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be safe, I'd do .Select(t => t.BeatLength).DefaultIfEmpty(0).Min/Max() otherwise these throw exceptions on empty arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The theory here was that these cannot throw because the preceding mostCommon.beatLength == 0 guard would catch that scenario.
Closes #35807.
The reason this closes the aforementioned issue is as follows:
Taking https://osu.ppy.sh/beatmapsets/1236180#osu/4650477 as the example, we have:
Note that
mostCommonBeatLength < minBeatLengthhere.Taking the inverse of that to compute BPM, we get
which without DT present doesn't do anything bad, but when DT is engaged (and thus BPM is multiplied by 1.5), midpoint rounding causes the min BPM to become 262, and the most common BPM to become 263.