feat: improve chart navigation and show original measure numbers
Publish GitHub Pages output / publish (push) Successful in 49s
Publish GitHub Pages output / publish (push) Successful in 49s
This commit is contained in:
@@ -103,6 +103,8 @@ export function parseSusTimeline(text) {
|
||||
bpmEvents.sort((left, right) => left.beat - right.beat);
|
||||
const uniqueBpmEvents = bpmEvents.filter((event, index) => index === 0 || event.beat !== bpmEvents[index - 1].beat);
|
||||
function secondsAt(beat) {
|
||||
const waveOffset = Number(headers.get('WAVEOFFSET') ?? 0);
|
||||
if (beat < uniqueBpmEvents[0].beat) return beat * 60 / Number(headers.get('BASEBPM') ?? 120) + waveOffset;
|
||||
let seconds = 0;
|
||||
let previous = uniqueBpmEvents[0];
|
||||
if (previous.beat > 0) seconds += previous.beat * 60 / Number(headers.get('BASEBPM') ?? 120);
|
||||
@@ -112,7 +114,7 @@ export function parseSusTimeline(text) {
|
||||
previous = event;
|
||||
}
|
||||
seconds += (beat - previous.beat) * 60 / previous.bpm;
|
||||
return seconds + Number(headers.get('WAVEOFFSET') ?? 0);
|
||||
return seconds + waveOffset;
|
||||
}
|
||||
const key = (note) => `${note.beat}|${note.lane}`;
|
||||
const tapKeys = new Set(taps.filter((note) => note.kind === 1 || note.kind === 2).map(key));
|
||||
@@ -190,6 +192,12 @@ export function parseSusTimeline(text) {
|
||||
visualNotes.push(...visibleRelays.map(note => visualNote(note, 'relay')));
|
||||
const visualHolds = holds.map(hold => hold.filter((note, i) => i === 0 || i === hold.length - 1 || !attached.has(key(note)))
|
||||
.map(note => ({ ...point(note), ...(note.kind === 4 ? { control: true } : {}) })));
|
||||
const lastSourceMeasure = Math.max(0, ...lines.map(line => Number(line.match(/^#(\d{3})\w+:/)?.[1] ?? 0)));
|
||||
const measureCount = Number(headers.get('MEASURE_COUNT') ?? lastSourceMeasure + 1);
|
||||
if (!Number.isInteger(measureCount) || measureCount < 1 || measureCount >= starts.length) throw new Error('잘못된 SUS 마디 수입니다.');
|
||||
// Keep the SUS's zero-based numbers, including silent bars and the end boundary.
|
||||
const measures = Array.from({ length: measureCount + 1 }, (_, number) => ({ number, timeSeconds: secondsAt(starts[number]) }));
|
||||
if (measures.some((measure, index) => !Number.isFinite(measure.timeSeconds) || (index > 0 && measure.timeSeconds <= measures[index - 1].timeSeconds))) throw new Error('잘못된 SUS 마디 시각입니다.');
|
||||
return { songId: headers.get('MUSIC_ID'), notes, specialStartSeconds: specialStarts.sort((left, right) => left - right).map(secondsAt),
|
||||
visual: { laneCount: 12, notes: visualNotes.sort((a, b) => a.timeSeconds - b.timeSeconds), holds: visualHolds } };
|
||||
visual: { laneCount: 12, notes: visualNotes.sort((a, b) => a.timeSeconds - b.timeSeconds), holds: visualHolds, measures } };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user