// Layout constants and small pure helpers for the piano roll canvas. export const PITCH_MIN = 21; // A0 export const PITCH_MAX = 108; // C8 export const KEY_H = 12; // px per semitone row export const RULER_H = 26; export const KEYS_W = 56; export const VEL_H = 72; export function isBlackKey(pitch: number): boolean { const pc = ((pitch % 12) + 12) % 12; return pc === 1 || pc === 3 || pc === 6 || pc === 8 || pc === 10; } export function snapValue(tick: number, grid: number, mode: 'round' | 'floor' | 'ceil'): number { if (grid <= 0) return Math.round(tick); const q = tick / grid; const k = mode === 'round' ? Math.round(q) : mode === 'floor' ? Math.floor(q) : Math.ceil(q); return k * grid; }