import type { Note } from '../types.ts'; // Pure note-list operations used by the editor; kept free of DOM and state // so the node test harness can exercise them directly. export function quantizeNotes(notes: Note[], gridTicks: number, ids?: Set): Note[] { if (gridTicks <= 0) return notes; return notes.map((n) => { if (ids && !ids.has(n.id)) return n; const tick = Math.max(0, Math.round(n.tick / gridTicks) * gridTicks); return { ...n, tick }; }); } export function transposeNotes(notes: Note[], semitones: number, ids?: Set): Note[] { return notes.map((n) => { if (ids && !ids.has(n.id)) return n; const pitch = Math.max(0, Math.min(127, n.pitch + semitones)); return { ...n, pitch }; }); }