Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 61x 18x 18x 17x 17x 1x 17x 18x | import { resolveChart, resolveChartMainBPM } from '@be-music/chart-model';
import type { BeMusicJSON } from '@be-music/chart-source';
const mainBPMByChart = new WeakMap<BeMusicJSON, number | null>();
/**
* A chart's main BPM for a screen that shows it before the play (beatoraja's select and decide screens, number 92): the
* BPM the most judged notes sit at, by the rule the play takes its main BPM by (`resolveChartMainBPM`), on the chart
* resolved as the play resolves it (`5x` / `6x` long notes without `#LNTYPE` read as `#LNTYPE 1`; `chartPath` names a
* `.pms` chart's 9 KEY). `undefined` for a chart without notes or one that does not resolve, so a per-frame read never
* throws. Cached per chart object, since song select asks again on every frame.
*/
export function resolveShownChartMainBPM(chart: BeMusicJSON, chartPath?: string): number | undefined {
const cached = mainBPMByChart.get(chart);
if (cached !== undefined) return cached ?? undefined;
let mainBPM: number | undefined;
try {
mainBPM = resolveChartMainBPM(
resolveChart(chart, { inferBmsLNTypeWhenMissing: false, ...(chartPath !== undefined ? { chartPath } : {}) }),
);
} catch {
mainBPM = undefined;
}
mainBPMByChart.set(chart, mainBPM ?? null);
return mainBPM;
}
|