osu! goals: real play counts from my most-played list (weekly), BPM range from the .osu timing points
All checks were successful
Deploy production / deploy (push) Successful in 1m14s
All checks were successful
Deploy production / deploy (push) Successful in 1m14s
This commit is contained in:
@@ -22,6 +22,21 @@ export const FAST_BPM = 200;
|
||||
* Streams in a .osu file: consecutive circles at most a 1/4 beat apart (5% slack) form a run.
|
||||
* Returns the longest run and the number of circles in runs of 5 or more.
|
||||
*/
|
||||
/** BPM range from the uninherited timing points of an .osu file (null when there are none). */
|
||||
export function bpmRange(osu: string): { min: number; max: number } | null {
|
||||
const start = osu.indexOf('[TimingPoints]');
|
||||
if (start < 0) return null;
|
||||
const rest = osu.slice(start + 14);
|
||||
const end = rest.search(/^\[/m);
|
||||
const bpms = (end < 0 ? rest : rest.slice(0, end))
|
||||
.split(/\r?\n/)
|
||||
.map((l) => l.trim().split(','))
|
||||
.filter((p) => p.length >= 2 && Number(p[1]) > 0 && (p.length < 7 || p[6] !== '0'))
|
||||
.map((p) => Math.round((60000 / Number(p[1])) * 10) / 10)
|
||||
.filter((b) => Number.isFinite(b) && b > 0);
|
||||
return bpms.length ? { min: Math.min(...bpms), max: Math.max(...bpms) } : null;
|
||||
}
|
||||
|
||||
export function streamStats(osu: string): { longest: number; notes: number } {
|
||||
const section = (name: string) => {
|
||||
const start = osu.indexOf(`[${name}]`);
|
||||
|
||||
Reference in New Issue
Block a user