import type { Role } from "../core/types.ts"; import type { RefTrack } from "./smf.ts"; // Best-effort role for a reference MIDI track; null = unmapped (excluded from scoring until the user maps it). export function guessRole(t: RefTrack): Role | null { if (t.isDrums) return "drums"; const n = t.name.trim().toLowerCase(); if (/vocal|voice|vox|sing/.test(n)) return "vocals"; if (/bass/.test(n)) return "bass"; if (/guitar|delay/.test(n)) return "guitar"; if (/piano|key|synth|organ/.test(n)) return "keys"; const p = t.program; if (p >= 32 && p <= 39) return "bass"; if (p >= 24 && p <= 31) return "guitar"; if ((p >= 0 && p <= 7) || (p >= 16 && p <= 23) || (p >= 88 && p <= 95)) return "keys"; return null; }