File tree 1 file changed +33
-1
lines changed
1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,39 @@ func (q *Qua) CommonBPM() float32 {
77
77
return 0
78
78
}
79
79
80
- return q .TimingPoints [0 ].BPM
80
+ if len (q .TimingPoints ) == 1 {
81
+ return q .TimingPoints [0 ].BPM
82
+ }
83
+
84
+ var durations = map [float32 ]float32 {}
85
+ lastTime := float32 (q .MapLength ())
86
+
87
+ for i := len (q .TimingPoints ) - 1 ; i >= 0 ; i -- {
88
+ point := q .TimingPoints [i ]
89
+
90
+ if point .StartTime > lastTime {
91
+ continue
92
+ }
93
+
94
+ duration := lastTime - point .StartTime
95
+ durations [point .BPM ] += duration
96
+
97
+ lastTime = point .StartTime
98
+ }
99
+
100
+ var maxBpm float32
101
+ var maxDuration float32
102
+ firstIter := true
103
+
104
+ for bpm , duration := range durations {
105
+ if firstIter || duration > maxDuration {
106
+ maxBpm = bpm
107
+ maxDuration = duration
108
+ firstIter = false
109
+ }
110
+ }
111
+
112
+ return maxBpm
81
113
}
82
114
83
115
// CountHitObjectNormal Returns the count of normal hit objects in the map
You can’t perform that action at this time.
0 commit comments