import { Course } from "tja-parser";
import { filterHitNotes } from "./util";

export type NoteFactor = [type: 0 | 1, bpm: number, scroll: number, delta: number]
export function factorize(course: Course) {
    const hitNotes = filterHitNotes(course);
    const factors: NoteFactor[] = [];
    for (let i = 0; i < hitNotes.length; i++) {
        const note = hitNotes[i];
        factors.push([
            (note.type === 1 || note.type === 3) ? 0 : 1,
            note.getBPM() / 100,
            note.getScroll() / 5,
            i === 0 ? 0 : (note.getTimingMS() - hitNotes[i - 1].getTimingMS()) / 1000
        ])
    }
    return factors;
}