UNPKG

@tonaljs/voice-leading

Version:

Voice leading logic for transitions between voicings

18 lines 519 B
// index.ts import Note from "@tonaljs/note"; var topNoteDiff = (voicings, lastVoicing) => { if (!lastVoicing || !lastVoicing.length) { return voicings[0]; } const topNoteMidi = (voicing) => Note.midi(voicing[voicing.length - 1]) || 0; const diff = (voicing) => Math.abs(topNoteMidi(lastVoicing) - topNoteMidi(voicing)); return voicings.sort((a, b) => diff(a) - diff(b))[0]; }; var index_default = { topNoteDiff }; export { index_default as default, topNoteDiff }; //# sourceMappingURL=index.mjs.map