UNPKG

@tonaljs/range

Version:

Create (musical) note ranges

28 lines 749 B
// index.ts import { compact, range } from "@tonaljs/collection"; import { midiToNoteName, toMidi } from "@tonaljs/midi"; function numeric(notes) { const midi = compact( notes.map((note) => typeof note === "number" ? note : toMidi(note)) ); if (!notes.length || midi.length !== notes.length) { return []; } return midi.reduce( (result, note) => { const last = result[result.length - 1]; return result.concat(range(last, note).slice(1)); }, [midi[0]] ); } function chromatic(notes, options) { return numeric(notes).map((midi) => midiToNoteName(midi, options)); } var index_default = { numeric, chromatic }; export { chromatic, index_default as default, numeric }; //# sourceMappingURL=index.mjs.map