UNPKG

@tonaljs/progression

Version:

Build musical chord progressions

52 lines (51 loc) 2.13 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // index.ts var progression_exports = {}; __export(progression_exports, { default: () => progression_default, fromRomanNumerals: () => fromRomanNumerals, toRomanNumerals: () => toRomanNumerals }); module.exports = __toCommonJS(progression_exports); var import_chord = require("@tonaljs/chord"); var import_pitch_distance = require("@tonaljs/pitch-distance"); var import_pitch_interval = require("@tonaljs/pitch-interval"); var import_roman_numeral = require("@tonaljs/roman-numeral"); function fromRomanNumerals(tonic, chords) { const romanNumerals = chords.map(import_roman_numeral.get); return romanNumerals.map( (rn) => (0, import_pitch_distance.transpose)(tonic, (0, import_pitch_interval.interval)(rn)) + rn.chordType ); } function toRomanNumerals(tonic, chords) { return chords.map((chord) => { const [note, chordType] = (0, import_chord.tokenize)(chord); const intervalName = (0, import_pitch_distance.distance)(tonic, note); const roman = (0, import_roman_numeral.get)((0, import_pitch_interval.interval)(intervalName)); return roman.name + chordType; }); } var progression_default = { fromRomanNumerals, toRomanNumerals }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { fromRomanNumerals, toRomanNumerals }); //# sourceMappingURL=index.js.map