Comparing version 2.1.2 to 2.2.0
@@ -8,2 +8,3 @@ 'use strict'; | ||
var tonalDistance = require('tonal-distance'); | ||
var tonalRomanNumeral = require('tonal-roman-numeral'); | ||
@@ -20,3 +21,2 @@ var arguments$1 = arguments; | ||
var SEVENTHS = "Maj7 m7 m7 Maj7 7 m7 m7b5".split(" "); | ||
var DEGREES = "I II III IV V VI VII".split(" "); | ||
var FIFTHS = [0, 2, 4, -1, 1, 3, 5, 0, 3]; | ||
@@ -95,13 +95,13 @@ | ||
* | ||
* - name {String}: name | ||
* - tonic {String}: key tonic | ||
* - mode {String}: key mode | ||
* - name {string}: name | ||
* - tonic {string}: key tonic | ||
* - mode {string}: key mode | ||
* - modenum {Number}: mode number (0 major, 1 dorian, ...) | ||
* - intervals {Array}: the scale intervals | ||
* - scale {Array}: the scale notes | ||
* - acc {String}: accidentals of the key signature | ||
* - acc {string}: accidentals of the key signature | ||
* - alt {Number}: alteration number (a numeric representation of accidentals) | ||
* | ||
* @function | ||
* @param {String} name - the key name | ||
* @param {string} name - the key name | ||
* @return {Object} the key properties object or null if not a valid key | ||
@@ -118,3 +118,3 @@ * | ||
* @function | ||
* @param {String|Object} key | ||
* @param {string|Object} key | ||
* @return {Array} the key scale | ||
@@ -132,3 +132,3 @@ * | ||
* Get a list of key scale degrees | ||
* @param {String} keyName | ||
* @param {string} keyName | ||
* @return {Array} | ||
@@ -143,4 +143,3 @@ * @example | ||
return chords.map(function (chord, i) { | ||
var deg = DEGREES[i]; | ||
return chord[0] === "m" ? deg.toLowerCase() : deg; | ||
return tonalRomanNumeral.degree(i + 1, chord[0] !== "m"); | ||
}); | ||
@@ -154,3 +153,3 @@ }; | ||
* @function | ||
* @param {String} key - the key name | ||
* @param {string} key - the key name | ||
* @return {Array} | ||
@@ -187,4 +186,5 @@ * | ||
* | ||
* @param {Array<String>} symbols - an array of symbols in major scale order | ||
* @param {String} keyName - the name of the key you want the symbols for | ||
* @param {Array<string>} symbols - an array of symbols in major scale order | ||
* @param {string} keyName - the name of the key you want the symbols for | ||
* @param {Array<string>} [degrees] - the list of degrees. By default from 1 to 7 in ascending order | ||
* @return {function} | ||
@@ -197,20 +197,26 @@ * @see Key.chords | ||
* chords("D dorian") //=> ["Dm", "Em", "FM", "G7", "Am", "Bdim", "CM"] | ||
* chords("D dorian", ['ii', 'V']) //=> [Em", "G7"] | ||
*/ | ||
function leadsheetSymbols(symbols, keyName) { | ||
if (arguments.length === 1) { return function (name) { return leadsheetSymbols(symbols, name); }; } | ||
function leadsheetSymbols(symbols, keyName, degrees) { | ||
if (arguments.length === 1) { return function (n, d) { return leadsheetSymbols(symbols, n, d); }; } | ||
var p = props(keyName); | ||
if (!p.name) { return []; } | ||
var names = tonalArray.rotate(p.modenum, symbols); | ||
return p.scale.map(function (tonic, i) { return tonic + names[i]; }); | ||
var chords = p.scale.map(function (tonic, i) { return tonic + names[i]; }); | ||
if (!degrees) { return chords; } | ||
return degrees.map(tonalRomanNumeral.decimal).map(function (n) { return chords[n - 1]; }); | ||
} | ||
/** | ||
* Get key chords | ||
* Get key seventh chords | ||
* | ||
* @function | ||
* @param {String} name - the key name | ||
* @return {Array} | ||
* @param {string} name - the key name | ||
* @param {Array<number|string>} [degrees] - can be numbers or roman numerals | ||
* @return {Array<string>} seventh chord names | ||
* | ||
* @example | ||
* Key.chords("A major") // => ["AMaj7", "Bm7", "C#m7", "DMaj7", ..,] | ||
* Key.chords("A major", ['I', 'IV', 'V']) // => ["AMaj7", "DMaj7", "E7"] | ||
* Key.chords("A major", [5, 4, 1]) // => ["E7", "DMaj7", AMaj7"] | ||
*/ | ||
@@ -223,7 +229,10 @@ var chords = leadsheetSymbols(SEVENTHS); | ||
* @function | ||
* @param {String} name - the key name | ||
* @return {Array} | ||
* @param {string} name - the key name | ||
* @param {Array<string|number>} [degrees] | ||
* @return {Array<string>} triad names | ||
* | ||
* @example | ||
* Key.triads("A major") // => ["AM", "Bm", "C#m", "DM", "E7", "F#m", "G#mb5"] | ||
* Key.triads("A major", ['I', 'IV', 'V']) // => ["AMaj7", "DMaj7", "E7"] | ||
* Key.triads("A major", [1, 4, 5]) // => ["AMaj7", "DMaj7", "E7"] | ||
*/ | ||
@@ -236,3 +245,3 @@ var triads = leadsheetSymbols(TRIADS); | ||
* @function | ||
* @param {String} name - the key name | ||
* @param {string} name - the key name | ||
* @return {Array} | ||
@@ -257,4 +266,4 @@ * | ||
* @function | ||
* @param {String} mode - the relative destination | ||
* @param {String} key - the key source | ||
* @param {string} mode - the relative destination | ||
* @param {string} key - the key source | ||
* | ||
@@ -281,3 +290,3 @@ * @example | ||
* @function | ||
* @param {String} name | ||
* @param {string} name | ||
* @return {Array} an array in the form [tonic, key] | ||
@@ -284,0 +293,0 @@ * |
@@ -26,2 +26,3 @@ | ||
import { trFifths, fifths, interval, transpose } from "tonal-distance"; | ||
import { degree, decimal } from "tonal-roman-numeral"; | ||
@@ -36,3 +37,2 @@ var MODES = "major dorian phrygian lydian mixolydian minor locrian ionian aeolian".split( | ||
var SEVENTHS = "Maj7 m7 m7 Maj7 7 m7 m7b5".split(" "); | ||
var DEGREES = "I II III IV V VI VII".split(" "); | ||
var FIFTHS = [0, 2, 4, -1, 1, 3, 5, 0, 3]; | ||
@@ -111,13 +111,13 @@ | ||
* | ||
* - name {String}: name | ||
* - tonic {String}: key tonic | ||
* - mode {String}: key mode | ||
* - name {string}: name | ||
* - tonic {string}: key tonic | ||
* - mode {string}: key mode | ||
* - modenum {Number}: mode number (0 major, 1 dorian, ...) | ||
* - intervals {Array}: the scale intervals | ||
* - scale {Array}: the scale notes | ||
* - acc {String}: accidentals of the key signature | ||
* - acc {string}: accidentals of the key signature | ||
* - alt {Number}: alteration number (a numeric representation of accidentals) | ||
* | ||
* @function | ||
* @param {String} name - the key name | ||
* @param {string} name - the key name | ||
* @return {Object} the key properties object or null if not a valid key | ||
@@ -134,3 +134,3 @@ * | ||
* @function | ||
* @param {String|Object} key | ||
* @param {string|Object} key | ||
* @return {Array} the key scale | ||
@@ -148,3 +148,3 @@ * | ||
* Get a list of key scale degrees | ||
* @param {String} keyName | ||
* @param {string} keyName | ||
* @return {Array} | ||
@@ -159,4 +159,3 @@ * @example | ||
return chords.map(function (chord, i) { | ||
var deg = DEGREES[i]; | ||
return chord[0] === "m" ? deg.toLowerCase() : deg; | ||
return degree(i + 1, chord[0] !== "m"); | ||
}); | ||
@@ -170,3 +169,3 @@ }; | ||
* @function | ||
* @param {String} key - the key name | ||
* @param {string} key - the key name | ||
* @return {Array} | ||
@@ -203,4 +202,5 @@ * | ||
* | ||
* @param {Array<String>} symbols - an array of symbols in major scale order | ||
* @param {String} keyName - the name of the key you want the symbols for | ||
* @param {Array<string>} symbols - an array of symbols in major scale order | ||
* @param {string} keyName - the name of the key you want the symbols for | ||
* @param {Array<string>} [degrees] - the list of degrees. By default from 1 to 7 in ascending order | ||
* @return {function} | ||
@@ -213,20 +213,26 @@ * @see Key.chords | ||
* chords("D dorian") //=> ["Dm", "Em", "FM", "G7", "Am", "Bdim", "CM"] | ||
* chords("D dorian", ['ii', 'V']) //=> [Em", "G7"] | ||
*/ | ||
export function leadsheetSymbols(symbols, keyName) { | ||
if (arguments.length === 1) { return function (name) { return leadsheetSymbols(symbols, name); }; } | ||
export function leadsheetSymbols(symbols, keyName, degrees) { | ||
if (arguments.length === 1) { return function (n, d) { return leadsheetSymbols(symbols, n, d); }; } | ||
var p = props(keyName); | ||
if (!p.name) { return []; } | ||
var names = rotate(p.modenum, symbols); | ||
return p.scale.map(function (tonic, i) { return tonic + names[i]; }); | ||
var chords = p.scale.map(function (tonic, i) { return tonic + names[i]; }); | ||
if (!degrees) { return chords; } | ||
return degrees.map(decimal).map(function (n) { return chords[n - 1]; }); | ||
} | ||
/** | ||
* Get key chords | ||
* Get key seventh chords | ||
* | ||
* @function | ||
* @param {String} name - the key name | ||
* @return {Array} | ||
* @param {string} name - the key name | ||
* @param {Array<number|string>} [degrees] - can be numbers or roman numerals | ||
* @return {Array<string>} seventh chord names | ||
* | ||
* @example | ||
* Key.chords("A major") // => ["AMaj7", "Bm7", "C#m7", "DMaj7", ..,] | ||
* Key.chords("A major", ['I', 'IV', 'V']) // => ["AMaj7", "DMaj7", "E7"] | ||
* Key.chords("A major", [5, 4, 1]) // => ["E7", "DMaj7", AMaj7"] | ||
*/ | ||
@@ -239,7 +245,10 @@ export var chords = leadsheetSymbols(SEVENTHS); | ||
* @function | ||
* @param {String} name - the key name | ||
* @return {Array} | ||
* @param {string} name - the key name | ||
* @param {Array<string|number>} [degrees] | ||
* @return {Array<string>} triad names | ||
* | ||
* @example | ||
* Key.triads("A major") // => ["AM", "Bm", "C#m", "DM", "E7", "F#m", "G#mb5"] | ||
* Key.triads("A major", ['I', 'IV', 'V']) // => ["AMaj7", "DMaj7", "E7"] | ||
* Key.triads("A major", [1, 4, 5]) // => ["AMaj7", "DMaj7", "E7"] | ||
*/ | ||
@@ -252,3 +261,3 @@ export var triads = leadsheetSymbols(TRIADS); | ||
* @function | ||
* @param {String} name - the key name | ||
* @param {string} name - the key name | ||
* @return {Array} | ||
@@ -273,4 +282,4 @@ * | ||
* @function | ||
* @param {String} mode - the relative destination | ||
* @param {String} key - the key source | ||
* @param {string} mode - the relative destination | ||
* @param {string} key - the key source | ||
* | ||
@@ -297,3 +306,3 @@ * @example | ||
* @function | ||
* @param {String} name | ||
* @param {string} name | ||
* @return {Array} an array in the form [tonic, key] | ||
@@ -300,0 +309,0 @@ * |
@@ -1,2 +0,2 @@ | ||
{"/Users/dani/Code/Music/tonal/extensions/key/index.js": {"path":"/Users/dani/Code/Music/tonal/extensions/key/index.js","statementMap":{"0":{"start":{"line":25,"column":14},"end":{"line":27,"column":1}},"1":{"start":{"line":28,"column":13},"end":{"line":28,"column":40}},"2":{"start":{"line":29,"column":14},"end":{"line":29,"column":40}},"3":{"start":{"line":31,"column":15},"end":{"line":31,"column":49}},"4":{"start":{"line":32,"column":17},"end":{"line":32,"column":55}},"5":{"start":{"line":33,"column":16},"end":{"line":33,"column":49}},"6":{"start":{"line":34,"column":15},"end":{"line":34,"column":43}},"7":{"start":{"line":36,"column":16},"end":{"line":36,"column":49}},"8":{"start":{"line":36,"column":24},"end":{"line":36,"column":49}},"9":{"start":{"line":51,"column":25},"end":{"line":52,"column":54}},"10":{"start":{"line":52,"column":2},"end":{"line":52,"column":54}},"11":{"start":{"line":63,"column":25},"end":{"line":63,"column":57}},"12":{"start":{"line":63,"column":30},"end":{"line":63,"column":57}},"13":{"start":{"line":65,"column":21},"end":{"line":70,"column":1}},"14":{"start":{"line":66,"column":2},"end":{"line":66,"column":22}},"15":{"start":{"line":67,"column":17},"end":{"line":67,"column":19}},"16":{"start":{"line":68,"column":2},"end":{"line":68,"column":62}},"17":{"start":{"line":68,"column":36},"end":{"line":68,"column":62}},"18":{"start":{"line":69,"column":2},"end":{"line":69,"column":16}},"19":{"start":{"line":72,"column":15},"end":{"line":81,"column":2}},"20":{"start":{"line":83,"column":19},"end":{"line":95,"column":1}},"21":{"start":{"line":84,"column":12},"end":{"line":84,"column":26}},"22":{"start":{"line":85,"column":2},"end":{"line":85,"column":35}},"23":{"start":{"line":85,"column":21},"end":{"line":85,"column":35}},"24":{"start":{"line":86,"column":12},"end":{"line":86,"column":39}},"25":{"start":{"line":87,"column":2},"end":{"line":87,"column":34}},"26":{"start":{"line":88,"column":2},"end":{"line":88,"column":30}},"27":{"start":{"line":89,"column":13},"end":{"line":89,"column":37}},"28":{"start":{"line":90,"column":2},"end":{"line":90,"column":63}},"29":{"start":{"line":91,"column":2},"end":{"line":91,"column":26}},"30":{"start":{"line":92,"column":2},"end":{"line":92,"column":40}},"31":{"start":{"line":93,"column":2},"end":{"line":93,"column":48}},"32":{"start":{"line":94,"column":2},"end":{"line":94,"column":26}},"33":{"start":{"line":97,"column":13},"end":{"line":97,"column":76}},"34":{"start":{"line":97,"column":33},"end":{"line":97,"column":76}},"35":{"start":{"line":97,"column":40},"end":{"line":97,"column":76}},"36":{"start":{"line":118,"column":21},"end":{"line":118,"column":37}},"37":{"start":{"line":133,"column":21},"end":{"line":133,"column":44}},"38":{"start":{"line":133,"column":28},"end":{"line":133,"column":44}},"39":{"start":{"line":142,"column":23},"end":{"line":150,"column":1}},"40":{"start":{"line":143,"column":12},"end":{"line":143,"column":22}},"41":{"start":{"line":144,"column":2},"end":{"line":144,"column":33}},"42":{"start":{"line":144,"column":23},"end":{"line":144,"column":33}},"43":{"start":{"line":145,"column":17},"end":{"line":145,"column":44}},"44":{"start":{"line":146,"column":2},"end":{"line":149,"column":5}},"45":{"start":{"line":147,"column":16},"end":{"line":147,"column":26}},"46":{"start":{"line":148,"column":4},"end":{"line":148,"column":54}},"47":{"start":{"line":163,"column":28},"end":{"line":171,"column":1}},"48":{"start":{"line":164,"column":14},"end":{"line":164,"column":29}},"49":{"start":{"line":165,"column":2},"end":{"line":165,"column":32}},"50":{"start":{"line":165,"column":20},"end":{"line":165,"column":32}},"51":{"start":{"line":166,"column":2},"end":{"line":170,"column":42}},"52":{"start":{"line":200,"column":2},"end":{"line":200,"column":77}},"53":{"start":{"line":200,"column":30},"end":{"line":200,"column":77}},"54":{"start":{"line":200,"column":45},"end":{"line":200,"column":76}},"55":{"start":{"line":201,"column":12},"end":{"line":201,"column":26}},"56":{"start":{"line":202,"column":2},"end":{"line":202,"column":25}},"57":{"start":{"line":202,"column":15},"end":{"line":202,"column":25}},"58":{"start":{"line":203,"column":16},"end":{"line":203,"column":42}},"59":{"start":{"line":204,"column":2},"end":{"line":204,"column":53}},"60":{"start":{"line":204,"column":35},"end":{"line":204,"column":51}},"61":{"start":{"line":217,"column":22},"end":{"line":217,"column":48}},"62":{"start":{"line":229,"column":22},"end":{"line":229,"column":46}},"63":{"start":{"line":242,"column":28},"end":{"line":246,"column":1}},"64":{"start":{"line":243,"column":12},"end":{"line":243,"column":23}},"65":{"start":{"line":244,"column":2},"end":{"line":244,"column":25}},"66":{"start":{"line":244,"column":15},"end":{"line":244,"column":25}},"67":{"start":{"line":245,"column":2},"end":{"line":245,"column":52}},"68":{"start":{"line":245,"column":26},"end":{"line":245,"column":50}},"69":{"start":{"line":265,"column":24},"end":{"line":272,"column":1}},"70":{"start":{"line":266,"column":2},"end":{"line":266,"column":64}},"71":{"start":{"line":266,"column":30},"end":{"line":266,"column":64}},"72":{"start":{"line":266,"column":44},"end":{"line":266,"column":63}},"73":{"start":{"line":267,"column":14},"end":{"line":267,"column":41}},"74":{"start":{"line":268,"column":2},"end":{"line":268,"column":37}},"75":{"start":{"line":268,"column":25},"end":{"line":268,"column":37}},"76":{"start":{"line":269,"column":12},"end":{"line":269,"column":22}},"77":{"start":{"line":270,"column":2},"end":{"line":270,"column":35}},"78":{"start":{"line":270,"column":23},"end":{"line":270,"column":35}},"79":{"start":{"line":271,"column":2},"end":{"line":271,"column":73}},"80":{"start":{"line":284,"column":24},"end":{"line":289,"column":1}},"81":{"start":{"line":285,"column":12},"end":{"line":285,"column":23}},"82":{"start":{"line":286,"column":2},"end":{"line":286,"column":28}},"83":{"start":{"line":287,"column":2},"end":{"line":287,"column":69}},"84":{"start":{"line":287,"column":49},"end":{"line":287,"column":69}},"85":{"start":{"line":288,"column":2},"end":{"line":288,"column":29}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":36,"column":16},"end":{"line":36,"column":17}},"loc":{"start":{"line":36,"column":24},"end":{"line":36,"column":49}},"line":36},"1":{"name":"(anonymous_1)","decl":{"start":{"line":51,"column":25},"end":{"line":51,"column":26}},"loc":{"start":{"line":52,"column":2},"end":{"line":52,"column":54}},"line":52},"2":{"name":"(anonymous_2)","decl":{"start":{"line":63,"column":25},"end":{"line":63,"column":26}},"loc":{"start":{"line":63,"column":30},"end":{"line":63,"column":57}},"line":63},"3":{"name":"(anonymous_3)","decl":{"start":{"line":65,"column":21},"end":{"line":65,"column":22}},"loc":{"start":{"line":65,"column":34},"end":{"line":70,"column":1}},"line":65},"4":{"name":"(anonymous_4)","decl":{"start":{"line":83,"column":19},"end":{"line":83,"column":20}},"loc":{"start":{"line":83,"column":27},"end":{"line":95,"column":1}},"line":83},"5":{"name":"(anonymous_5)","decl":{"start":{"line":97,"column":13},"end":{"line":97,"column":14}},"loc":{"start":{"line":97,"column":33},"end":{"line":97,"column":76}},"line":97},"6":{"name":"(anonymous_6)","decl":{"start":{"line":97,"column":33},"end":{"line":97,"column":34}},"loc":{"start":{"line":97,"column":40},"end":{"line":97,"column":76}},"line":97},"7":{"name":"(anonymous_7)","decl":{"start":{"line":133,"column":21},"end":{"line":133,"column":22}},"loc":{"start":{"line":133,"column":28},"end":{"line":133,"column":44}},"line":133},"8":{"name":"(anonymous_8)","decl":{"start":{"line":142,"column":23},"end":{"line":142,"column":24}},"loc":{"start":{"line":142,"column":30},"end":{"line":150,"column":1}},"line":142},"9":{"name":"(anonymous_9)","decl":{"start":{"line":146,"column":20},"end":{"line":146,"column":21}},"loc":{"start":{"line":146,"column":34},"end":{"line":149,"column":3}},"line":146},"10":{"name":"(anonymous_10)","decl":{"start":{"line":163,"column":28},"end":{"line":163,"column":29}},"loc":{"start":{"line":163,"column":36},"end":{"line":171,"column":1}},"line":163},"11":{"name":"leadsheetSymbols","decl":{"start":{"line":199,"column":16},"end":{"line":199,"column":32}},"loc":{"start":{"line":199,"column":51},"end":{"line":205,"column":1}},"line":199},"12":{"name":"(anonymous_12)","decl":{"start":{"line":200,"column":37},"end":{"line":200,"column":38}},"loc":{"start":{"line":200,"column":45},"end":{"line":200,"column":76}},"line":200},"13":{"name":"(anonymous_13)","decl":{"start":{"line":204,"column":21},"end":{"line":204,"column":22}},"loc":{"start":{"line":204,"column":35},"end":{"line":204,"column":51}},"line":204},"14":{"name":"(anonymous_14)","decl":{"start":{"line":242,"column":28},"end":{"line":242,"column":29}},"loc":{"start":{"line":242,"column":36},"end":{"line":246,"column":1}},"line":242},"15":{"name":"(anonymous_15)","decl":{"start":{"line":245,"column":21},"end":{"line":245,"column":22}},"loc":{"start":{"line":245,"column":26},"end":{"line":245,"column":50}},"line":245},"16":{"name":"(anonymous_16)","decl":{"start":{"line":265,"column":24},"end":{"line":265,"column":25}},"loc":{"start":{"line":265,"column":39},"end":{"line":272,"column":1}},"line":265},"17":{"name":"(anonymous_17)","decl":{"start":{"line":266,"column":37},"end":{"line":266,"column":38}},"loc":{"start":{"line":266,"column":44},"end":{"line":266,"column":63}},"line":266},"18":{"name":"(anonymous_18)","decl":{"start":{"line":284,"column":24},"end":{"line":284,"column":25}},"loc":{"start":{"line":284,"column":32},"end":{"line":289,"column":1}},"line":284}},"branchMap":{"0":{"loc":{"start":{"line":52,"column":2},"end":{"line":52,"column":54}},"type":"cond-expr","locations":[{"start":{"line":52,"column":21},"end":{"line":52,"column":34}},{"start":{"line":52,"column":37},"end":{"line":52,"column":54}}],"line":52},"1":{"loc":{"start":{"line":65,"column":22},"end":{"line":65,"column":29}},"type":"default-arg","locations":[{"start":{"line":65,"column":28},"end":{"line":65,"column":29}}],"line":65},"2":{"loc":{"start":{"line":85,"column":2},"end":{"line":85,"column":35}},"type":"if","locations":[{"start":{"line":85,"column":2},"end":{"line":85,"column":35}},{"start":{"line":85,"column":2},"end":{"line":85,"column":35}}],"line":85},"3":{"loc":{"start":{"line":97,"column":18},"end":{"line":97,"column":28}},"type":"default-arg","locations":[{"start":{"line":97,"column":26},"end":{"line":97,"column":28}}],"line":97},"4":{"loc":{"start":{"line":97,"column":40},"end":{"line":97,"column":76}},"type":"binary-expr","locations":[{"start":{"line":97,"column":40},"end":{"line":97,"column":50}},{"start":{"line":97,"column":55},"end":{"line":97,"column":75}}],"line":97},"5":{"loc":{"start":{"line":144,"column":2},"end":{"line":144,"column":33}},"type":"if","locations":[{"start":{"line":144,"column":2},"end":{"line":144,"column":33}},{"start":{"line":144,"column":2},"end":{"line":144,"column":33}}],"line":144},"6":{"loc":{"start":{"line":148,"column":11},"end":{"line":148,"column":53}},"type":"cond-expr","locations":[{"start":{"line":148,"column":30},"end":{"line":148,"column":47}},{"start":{"line":148,"column":50},"end":{"line":148,"column":53}}],"line":148},"7":{"loc":{"start":{"line":165,"column":2},"end":{"line":165,"column":32}},"type":"if","locations":[{"start":{"line":165,"column":2},"end":{"line":165,"column":32}},{"start":{"line":165,"column":2},"end":{"line":165,"column":32}}],"line":165},"8":{"loc":{"start":{"line":166,"column":9},"end":{"line":170,"column":41}},"type":"cond-expr","locations":[{"start":{"line":167,"column":6},"end":{"line":167,"column":8}},{"start":{"line":168,"column":6},"end":{"line":170,"column":41}}],"line":166},"9":{"loc":{"start":{"line":168,"column":6},"end":{"line":170,"column":41}},"type":"cond-expr","locations":[{"start":{"line":169,"column":8},"end":{"line":169,"column":40}},{"start":{"line":170,"column":8},"end":{"line":170,"column":41}}],"line":168},"10":{"loc":{"start":{"line":200,"column":2},"end":{"line":200,"column":77}},"type":"if","locations":[{"start":{"line":200,"column":2},"end":{"line":200,"column":77}},{"start":{"line":200,"column":2},"end":{"line":200,"column":77}}],"line":200},"11":{"loc":{"start":{"line":202,"column":2},"end":{"line":202,"column":25}},"type":"if","locations":[{"start":{"line":202,"column":2},"end":{"line":202,"column":25}},{"start":{"line":202,"column":2},"end":{"line":202,"column":25}}],"line":202},"12":{"loc":{"start":{"line":244,"column":2},"end":{"line":244,"column":25}},"type":"if","locations":[{"start":{"line":244,"column":2},"end":{"line":244,"column":25}},{"start":{"line":244,"column":2},"end":{"line":244,"column":25}}],"line":244},"13":{"loc":{"start":{"line":266,"column":2},"end":{"line":266,"column":64}},"type":"if","locations":[{"start":{"line":266,"column":2},"end":{"line":266,"column":64}},{"start":{"line":266,"column":2},"end":{"line":266,"column":64}}],"line":266},"14":{"loc":{"start":{"line":268,"column":2},"end":{"line":268,"column":37}},"type":"if","locations":[{"start":{"line":268,"column":2},"end":{"line":268,"column":37}},{"start":{"line":268,"column":2},"end":{"line":268,"column":37}}],"line":268},"15":{"loc":{"start":{"line":270,"column":2},"end":{"line":270,"column":35}},"type":"if","locations":[{"start":{"line":270,"column":2},"end":{"line":270,"column":35}},{"start":{"line":270,"column":2},"end":{"line":270,"column":35}}],"line":270},"16":{"loc":{"start":{"line":287,"column":2},"end":{"line":287,"column":69}},"type":"if","locations":[{"start":{"line":287,"column":2},"end":{"line":287,"column":69}},{"start":{"line":287,"column":2},"end":{"line":287,"column":69}}],"line":287},"17":{"loc":{"start":{"line":287,"column":6},"end":{"line":287,"column":47}},"type":"binary-expr","locations":[{"start":{"line":287,"column":6},"end":{"line":287,"column":17}},{"start":{"line":287,"column":21},"end":{"line":287,"column":47}}],"line":287}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":22,"9":1,"10":3,"11":1,"12":10,"13":1,"14":2,"15":2,"16":2,"17":10,"18":2,"19":1,"20":1,"21":20,"22":20,"23":1,"24":19,"25":19,"26":19,"27":19,"28":19,"29":19,"30":19,"31":19,"32":19,"33":1,"34":1,"35":29,"36":1,"37":1,"38":1,"39":1,"40":2,"41":2,"42":0,"43":2,"44":2,"45":14,"46":14,"47":1,"48":2,"49":2,"50":0,"51":2,"52":7,"53":2,"54":4,"55":5,"56":5,"57":0,"58":5,"59":5,"60":35,"61":1,"62":1,"63":1,"64":1,"65":1,"66":0,"67":1,"68":7,"69":1,"70":3,"71":0,"72":0,"73":3,"74":3,"75":0,"76":3,"77":3,"78":0,"79":3,"80":1,"81":25,"82":25,"83":25,"84":3,"85":22},"f":{"0":22,"1":3,"2":10,"3":2,"4":20,"5":1,"6":29,"7":1,"8":2,"9":14,"10":2,"11":7,"12":4,"13":35,"14":1,"15":7,"16":3,"17":0,"18":25},"b":{"0":[1,2],"1":[1],"2":[1,19],"3":[1],"4":[29,20],"5":[0,2],"6":[8,6],"7":[0,2],"8":[0,2],"9":[1,1],"10":[2,5],"11":[0,5],"12":[0,1],"13":[0,3],"14":[0,3],"15":[0,3],"16":[3,22],"17":[25,24]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"0c308eda1d4e951197f25eaabc2b54f8fde42d02"} | ||
{"/Users/dani/Code/Music/tonal/extensions/key/index.js": {"path":"/Users/dani/Code/Music/tonal/extensions/key/index.js","statementMap":{"0":{"start":{"line":26,"column":14},"end":{"line":28,"column":1}},"1":{"start":{"line":29,"column":13},"end":{"line":29,"column":40}},"2":{"start":{"line":30,"column":14},"end":{"line":30,"column":40}},"3":{"start":{"line":32,"column":15},"end":{"line":32,"column":49}},"4":{"start":{"line":33,"column":17},"end":{"line":33,"column":55}},"5":{"start":{"line":34,"column":15},"end":{"line":34,"column":43}},"6":{"start":{"line":36,"column":16},"end":{"line":36,"column":49}},"7":{"start":{"line":36,"column":24},"end":{"line":36,"column":49}},"8":{"start":{"line":51,"column":25},"end":{"line":52,"column":54}},"9":{"start":{"line":52,"column":2},"end":{"line":52,"column":54}},"10":{"start":{"line":63,"column":25},"end":{"line":63,"column":57}},"11":{"start":{"line":63,"column":30},"end":{"line":63,"column":57}},"12":{"start":{"line":65,"column":21},"end":{"line":70,"column":1}},"13":{"start":{"line":66,"column":2},"end":{"line":66,"column":22}},"14":{"start":{"line":67,"column":17},"end":{"line":67,"column":19}},"15":{"start":{"line":68,"column":2},"end":{"line":68,"column":62}},"16":{"start":{"line":68,"column":36},"end":{"line":68,"column":62}},"17":{"start":{"line":69,"column":2},"end":{"line":69,"column":16}},"18":{"start":{"line":72,"column":15},"end":{"line":81,"column":2}},"19":{"start":{"line":83,"column":19},"end":{"line":95,"column":1}},"20":{"start":{"line":84,"column":12},"end":{"line":84,"column":26}},"21":{"start":{"line":85,"column":2},"end":{"line":85,"column":35}},"22":{"start":{"line":85,"column":21},"end":{"line":85,"column":35}},"23":{"start":{"line":86,"column":12},"end":{"line":86,"column":39}},"24":{"start":{"line":87,"column":2},"end":{"line":87,"column":34}},"25":{"start":{"line":88,"column":2},"end":{"line":88,"column":30}},"26":{"start":{"line":89,"column":13},"end":{"line":89,"column":37}},"27":{"start":{"line":90,"column":2},"end":{"line":90,"column":63}},"28":{"start":{"line":91,"column":2},"end":{"line":91,"column":26}},"29":{"start":{"line":92,"column":2},"end":{"line":92,"column":40}},"30":{"start":{"line":93,"column":2},"end":{"line":93,"column":48}},"31":{"start":{"line":94,"column":2},"end":{"line":94,"column":26}},"32":{"start":{"line":97,"column":13},"end":{"line":97,"column":76}},"33":{"start":{"line":97,"column":33},"end":{"line":97,"column":76}},"34":{"start":{"line":97,"column":40},"end":{"line":97,"column":76}},"35":{"start":{"line":118,"column":21},"end":{"line":118,"column":37}},"36":{"start":{"line":133,"column":21},"end":{"line":133,"column":44}},"37":{"start":{"line":133,"column":28},"end":{"line":133,"column":44}},"38":{"start":{"line":142,"column":23},"end":{"line":149,"column":1}},"39":{"start":{"line":143,"column":12},"end":{"line":143,"column":22}},"40":{"start":{"line":144,"column":2},"end":{"line":144,"column":33}},"41":{"start":{"line":144,"column":23},"end":{"line":144,"column":33}},"42":{"start":{"line":145,"column":17},"end":{"line":145,"column":44}},"43":{"start":{"line":146,"column":2},"end":{"line":148,"column":5}},"44":{"start":{"line":147,"column":4},"end":{"line":147,"column":43}},"45":{"start":{"line":162,"column":28},"end":{"line":170,"column":1}},"46":{"start":{"line":163,"column":14},"end":{"line":163,"column":29}},"47":{"start":{"line":164,"column":2},"end":{"line":164,"column":32}},"48":{"start":{"line":164,"column":20},"end":{"line":164,"column":32}},"49":{"start":{"line":165,"column":2},"end":{"line":169,"column":42}},"50":{"start":{"line":201,"column":2},"end":{"line":201,"column":79}},"51":{"start":{"line":201,"column":30},"end":{"line":201,"column":79}},"52":{"start":{"line":201,"column":47},"end":{"line":201,"column":78}},"53":{"start":{"line":202,"column":12},"end":{"line":202,"column":26}},"54":{"start":{"line":203,"column":2},"end":{"line":203,"column":25}},"55":{"start":{"line":203,"column":15},"end":{"line":203,"column":25}},"56":{"start":{"line":204,"column":16},"end":{"line":204,"column":42}},"57":{"start":{"line":205,"column":17},"end":{"line":205,"column":60}},"58":{"start":{"line":205,"column":43},"end":{"line":205,"column":59}},"59":{"start":{"line":206,"column":2},"end":{"line":206,"column":30}},"60":{"start":{"line":206,"column":16},"end":{"line":206,"column":30}},"61":{"start":{"line":207,"column":2},"end":{"line":207,"column":54}},"62":{"start":{"line":207,"column":39},"end":{"line":207,"column":52}},"63":{"start":{"line":223,"column":22},"end":{"line":223,"column":48}},"64":{"start":{"line":238,"column":22},"end":{"line":238,"column":46}},"65":{"start":{"line":251,"column":28},"end":{"line":255,"column":1}},"66":{"start":{"line":252,"column":12},"end":{"line":252,"column":23}},"67":{"start":{"line":253,"column":2},"end":{"line":253,"column":25}},"68":{"start":{"line":253,"column":15},"end":{"line":253,"column":25}},"69":{"start":{"line":254,"column":2},"end":{"line":254,"column":52}},"70":{"start":{"line":254,"column":26},"end":{"line":254,"column":50}},"71":{"start":{"line":274,"column":24},"end":{"line":281,"column":1}},"72":{"start":{"line":275,"column":2},"end":{"line":275,"column":64}},"73":{"start":{"line":275,"column":30},"end":{"line":275,"column":64}},"74":{"start":{"line":275,"column":44},"end":{"line":275,"column":63}},"75":{"start":{"line":276,"column":14},"end":{"line":276,"column":41}},"76":{"start":{"line":277,"column":2},"end":{"line":277,"column":37}},"77":{"start":{"line":277,"column":25},"end":{"line":277,"column":37}},"78":{"start":{"line":278,"column":12},"end":{"line":278,"column":22}},"79":{"start":{"line":279,"column":2},"end":{"line":279,"column":35}},"80":{"start":{"line":279,"column":23},"end":{"line":279,"column":35}},"81":{"start":{"line":280,"column":2},"end":{"line":280,"column":73}},"82":{"start":{"line":293,"column":24},"end":{"line":298,"column":1}},"83":{"start":{"line":294,"column":12},"end":{"line":294,"column":23}},"84":{"start":{"line":295,"column":2},"end":{"line":295,"column":28}},"85":{"start":{"line":296,"column":2},"end":{"line":296,"column":69}},"86":{"start":{"line":296,"column":49},"end":{"line":296,"column":69}},"87":{"start":{"line":297,"column":2},"end":{"line":297,"column":29}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":36,"column":16},"end":{"line":36,"column":17}},"loc":{"start":{"line":36,"column":24},"end":{"line":36,"column":49}},"line":36},"1":{"name":"(anonymous_1)","decl":{"start":{"line":51,"column":25},"end":{"line":51,"column":26}},"loc":{"start":{"line":52,"column":2},"end":{"line":52,"column":54}},"line":52},"2":{"name":"(anonymous_2)","decl":{"start":{"line":63,"column":25},"end":{"line":63,"column":26}},"loc":{"start":{"line":63,"column":30},"end":{"line":63,"column":57}},"line":63},"3":{"name":"(anonymous_3)","decl":{"start":{"line":65,"column":21},"end":{"line":65,"column":22}},"loc":{"start":{"line":65,"column":34},"end":{"line":70,"column":1}},"line":65},"4":{"name":"(anonymous_4)","decl":{"start":{"line":83,"column":19},"end":{"line":83,"column":20}},"loc":{"start":{"line":83,"column":27},"end":{"line":95,"column":1}},"line":83},"5":{"name":"(anonymous_5)","decl":{"start":{"line":97,"column":13},"end":{"line":97,"column":14}},"loc":{"start":{"line":97,"column":33},"end":{"line":97,"column":76}},"line":97},"6":{"name":"(anonymous_6)","decl":{"start":{"line":97,"column":33},"end":{"line":97,"column":34}},"loc":{"start":{"line":97,"column":40},"end":{"line":97,"column":76}},"line":97},"7":{"name":"(anonymous_7)","decl":{"start":{"line":133,"column":21},"end":{"line":133,"column":22}},"loc":{"start":{"line":133,"column":28},"end":{"line":133,"column":44}},"line":133},"8":{"name":"(anonymous_8)","decl":{"start":{"line":142,"column":23},"end":{"line":142,"column":24}},"loc":{"start":{"line":142,"column":30},"end":{"line":149,"column":1}},"line":142},"9":{"name":"(anonymous_9)","decl":{"start":{"line":146,"column":20},"end":{"line":146,"column":21}},"loc":{"start":{"line":146,"column":34},"end":{"line":148,"column":3}},"line":146},"10":{"name":"(anonymous_10)","decl":{"start":{"line":162,"column":28},"end":{"line":162,"column":29}},"loc":{"start":{"line":162,"column":36},"end":{"line":170,"column":1}},"line":162},"11":{"name":"leadsheetSymbols","decl":{"start":{"line":200,"column":16},"end":{"line":200,"column":32}},"loc":{"start":{"line":200,"column":60},"end":{"line":208,"column":1}},"line":200},"12":{"name":"(anonymous_12)","decl":{"start":{"line":201,"column":37},"end":{"line":201,"column":38}},"loc":{"start":{"line":201,"column":47},"end":{"line":201,"column":78}},"line":201},"13":{"name":"(anonymous_13)","decl":{"start":{"line":205,"column":29},"end":{"line":205,"column":30}},"loc":{"start":{"line":205,"column":43},"end":{"line":205,"column":59}},"line":205},"14":{"name":"(anonymous_14)","decl":{"start":{"line":207,"column":34},"end":{"line":207,"column":35}},"loc":{"start":{"line":207,"column":39},"end":{"line":207,"column":52}},"line":207},"15":{"name":"(anonymous_15)","decl":{"start":{"line":251,"column":28},"end":{"line":251,"column":29}},"loc":{"start":{"line":251,"column":36},"end":{"line":255,"column":1}},"line":251},"16":{"name":"(anonymous_16)","decl":{"start":{"line":254,"column":21},"end":{"line":254,"column":22}},"loc":{"start":{"line":254,"column":26},"end":{"line":254,"column":50}},"line":254},"17":{"name":"(anonymous_17)","decl":{"start":{"line":274,"column":24},"end":{"line":274,"column":25}},"loc":{"start":{"line":274,"column":39},"end":{"line":281,"column":1}},"line":274},"18":{"name":"(anonymous_18)","decl":{"start":{"line":275,"column":37},"end":{"line":275,"column":38}},"loc":{"start":{"line":275,"column":44},"end":{"line":275,"column":63}},"line":275},"19":{"name":"(anonymous_19)","decl":{"start":{"line":293,"column":24},"end":{"line":293,"column":25}},"loc":{"start":{"line":293,"column":32},"end":{"line":298,"column":1}},"line":293}},"branchMap":{"0":{"loc":{"start":{"line":52,"column":2},"end":{"line":52,"column":54}},"type":"cond-expr","locations":[{"start":{"line":52,"column":21},"end":{"line":52,"column":34}},{"start":{"line":52,"column":37},"end":{"line":52,"column":54}}],"line":52},"1":{"loc":{"start":{"line":65,"column":22},"end":{"line":65,"column":29}},"type":"default-arg","locations":[{"start":{"line":65,"column":28},"end":{"line":65,"column":29}}],"line":65},"2":{"loc":{"start":{"line":85,"column":2},"end":{"line":85,"column":35}},"type":"if","locations":[{"start":{"line":85,"column":2},"end":{"line":85,"column":35}},{"start":{"line":85,"column":2},"end":{"line":85,"column":35}}],"line":85},"3":{"loc":{"start":{"line":97,"column":18},"end":{"line":97,"column":28}},"type":"default-arg","locations":[{"start":{"line":97,"column":26},"end":{"line":97,"column":28}}],"line":97},"4":{"loc":{"start":{"line":97,"column":40},"end":{"line":97,"column":76}},"type":"binary-expr","locations":[{"start":{"line":97,"column":40},"end":{"line":97,"column":50}},{"start":{"line":97,"column":55},"end":{"line":97,"column":75}}],"line":97},"5":{"loc":{"start":{"line":144,"column":2},"end":{"line":144,"column":33}},"type":"if","locations":[{"start":{"line":144,"column":2},"end":{"line":144,"column":33}},{"start":{"line":144,"column":2},"end":{"line":144,"column":33}}],"line":144},"6":{"loc":{"start":{"line":164,"column":2},"end":{"line":164,"column":32}},"type":"if","locations":[{"start":{"line":164,"column":2},"end":{"line":164,"column":32}},{"start":{"line":164,"column":2},"end":{"line":164,"column":32}}],"line":164},"7":{"loc":{"start":{"line":165,"column":9},"end":{"line":169,"column":41}},"type":"cond-expr","locations":[{"start":{"line":166,"column":6},"end":{"line":166,"column":8}},{"start":{"line":167,"column":6},"end":{"line":169,"column":41}}],"line":165},"8":{"loc":{"start":{"line":167,"column":6},"end":{"line":169,"column":41}},"type":"cond-expr","locations":[{"start":{"line":168,"column":8},"end":{"line":168,"column":40}},{"start":{"line":169,"column":8},"end":{"line":169,"column":41}}],"line":167},"9":{"loc":{"start":{"line":201,"column":2},"end":{"line":201,"column":79}},"type":"if","locations":[{"start":{"line":201,"column":2},"end":{"line":201,"column":79}},{"start":{"line":201,"column":2},"end":{"line":201,"column":79}}],"line":201},"10":{"loc":{"start":{"line":203,"column":2},"end":{"line":203,"column":25}},"type":"if","locations":[{"start":{"line":203,"column":2},"end":{"line":203,"column":25}},{"start":{"line":203,"column":2},"end":{"line":203,"column":25}}],"line":203},"11":{"loc":{"start":{"line":206,"column":2},"end":{"line":206,"column":30}},"type":"if","locations":[{"start":{"line":206,"column":2},"end":{"line":206,"column":30}},{"start":{"line":206,"column":2},"end":{"line":206,"column":30}}],"line":206},"12":{"loc":{"start":{"line":253,"column":2},"end":{"line":253,"column":25}},"type":"if","locations":[{"start":{"line":253,"column":2},"end":{"line":253,"column":25}},{"start":{"line":253,"column":2},"end":{"line":253,"column":25}}],"line":253},"13":{"loc":{"start":{"line":275,"column":2},"end":{"line":275,"column":64}},"type":"if","locations":[{"start":{"line":275,"column":2},"end":{"line":275,"column":64}},{"start":{"line":275,"column":2},"end":{"line":275,"column":64}}],"line":275},"14":{"loc":{"start":{"line":277,"column":2},"end":{"line":277,"column":37}},"type":"if","locations":[{"start":{"line":277,"column":2},"end":{"line":277,"column":37}},{"start":{"line":277,"column":2},"end":{"line":277,"column":37}}],"line":277},"15":{"loc":{"start":{"line":279,"column":2},"end":{"line":279,"column":35}},"type":"if","locations":[{"start":{"line":279,"column":2},"end":{"line":279,"column":35}},{"start":{"line":279,"column":2},"end":{"line":279,"column":35}}],"line":279},"16":{"loc":{"start":{"line":296,"column":2},"end":{"line":296,"column":69}},"type":"if","locations":[{"start":{"line":296,"column":2},"end":{"line":296,"column":69}},{"start":{"line":296,"column":2},"end":{"line":296,"column":69}}],"line":296},"17":{"loc":{"start":{"line":296,"column":6},"end":{"line":296,"column":47}},"type":"binary-expr","locations":[{"start":{"line":296,"column":6},"end":{"line":296,"column":17}},{"start":{"line":296,"column":21},"end":{"line":296,"column":47}}],"line":296}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":22,"8":1,"9":3,"10":1,"11":10,"12":1,"13":2,"14":2,"15":2,"16":10,"17":2,"18":1,"19":1,"20":20,"21":20,"22":1,"23":19,"24":19,"25":19,"26":19,"27":19,"28":19,"29":19,"30":19,"31":19,"32":1,"33":1,"34":32,"35":1,"36":1,"37":1,"38":1,"39":2,"40":2,"41":0,"42":2,"43":2,"44":14,"45":1,"46":2,"47":2,"48":0,"49":2,"50":10,"51":2,"52":7,"53":8,"54":8,"55":0,"56":8,"57":8,"58":56,"59":8,"60":5,"61":3,"62":9,"63":1,"64":1,"65":1,"66":1,"67":1,"68":0,"69":1,"70":7,"71":1,"72":3,"73":0,"74":0,"75":3,"76":3,"77":0,"78":3,"79":3,"80":0,"81":3,"82":1,"83":25,"84":25,"85":25,"86":3,"87":22},"f":{"0":22,"1":3,"2":10,"3":2,"4":20,"5":1,"6":32,"7":1,"8":2,"9":14,"10":2,"11":10,"12":7,"13":56,"14":9,"15":1,"16":7,"17":3,"18":0,"19":25},"b":{"0":[1,2],"1":[1],"2":[1,19],"3":[1],"4":[32,20],"5":[0,2],"6":[0,2],"7":[0,2],"8":[1,1],"9":[2,8],"10":[0,8],"11":[5,3],"12":[0,1],"13":[0,3],"14":[0,3],"15":[0,3],"16":[3,22],"17":[25,24]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"5cd5def5022417008cdaac777698746252801a43"} | ||
} |
59
index.js
@@ -24,2 +24,3 @@ /** | ||
import { trFifths, fifths, interval, transpose } from "tonal-distance"; | ||
import { degree, decimal } from "tonal-roman-numeral"; | ||
@@ -34,3 +35,2 @@ const MODES = "major dorian phrygian lydian mixolydian minor locrian ionian aeolian".split( | ||
const SEVENTHS = "Maj7 m7 m7 Maj7 7 m7 m7b5".split(" "); | ||
const DEGREES = "I II III IV V VI VII".split(" "); | ||
const FIFTHS = [0, 2, 4, -1, 1, 3, 5, 0, 3]; | ||
@@ -104,13 +104,13 @@ | ||
* | ||
* - name {String}: name | ||
* - tonic {String}: key tonic | ||
* - mode {String}: key mode | ||
* - name {string}: name | ||
* - tonic {string}: key tonic | ||
* - mode {string}: key mode | ||
* - modenum {Number}: mode number (0 major, 1 dorian, ...) | ||
* - intervals {Array}: the scale intervals | ||
* - scale {Array}: the scale notes | ||
* - acc {String}: accidentals of the key signature | ||
* - acc {string}: accidentals of the key signature | ||
* - alt {Number}: alteration number (a numeric representation of accidentals) | ||
* | ||
* @function | ||
* @param {String} name - the key name | ||
* @param {string} name - the key name | ||
* @return {Object} the key properties object or null if not a valid key | ||
@@ -127,3 +127,3 @@ * | ||
* @function | ||
* @param {String|Object} key | ||
* @param {string|Object} key | ||
* @return {Array} the key scale | ||
@@ -141,3 +141,3 @@ * | ||
* Get a list of key scale degrees | ||
* @param {String} keyName | ||
* @param {string} keyName | ||
* @return {Array} | ||
@@ -152,4 +152,3 @@ * @example | ||
return chords.map((chord, i) => { | ||
const deg = DEGREES[i]; | ||
return chord[0] === "m" ? deg.toLowerCase() : deg; | ||
return degree(i + 1, chord[0] !== "m"); | ||
}); | ||
@@ -163,3 +162,3 @@ }; | ||
* @function | ||
* @param {String} key - the key name | ||
* @param {string} key - the key name | ||
* @return {Array} | ||
@@ -196,4 +195,5 @@ * | ||
* | ||
* @param {Array<String>} symbols - an array of symbols in major scale order | ||
* @param {String} keyName - the name of the key you want the symbols for | ||
* @param {Array<string>} symbols - an array of symbols in major scale order | ||
* @param {string} keyName - the name of the key you want the symbols for | ||
* @param {Array<string>} [degrees] - the list of degrees. By default from 1 to 7 in ascending order | ||
* @return {function} | ||
@@ -206,20 +206,26 @@ * @see Key.chords | ||
* chords("D dorian") //=> ["Dm", "Em", "FM", "G7", "Am", "Bdim", "CM"] | ||
* chords("D dorian", ['ii', 'V']) //=> [Em", "G7"] | ||
*/ | ||
export function leadsheetSymbols(symbols, keyName) { | ||
if (arguments.length === 1) return name => leadsheetSymbols(symbols, name); | ||
export function leadsheetSymbols(symbols, keyName, degrees) { | ||
if (arguments.length === 1) return (n, d) => leadsheetSymbols(symbols, n, d); | ||
const p = props(keyName); | ||
if (!p.name) return []; | ||
const names = rotate(p.modenum, symbols); | ||
return p.scale.map((tonic, i) => tonic + names[i]); | ||
const chords = p.scale.map((tonic, i) => tonic + names[i]); | ||
if (!degrees) return chords; | ||
return degrees.map(decimal).map(n => chords[n - 1]); | ||
} | ||
/** | ||
* Get key chords | ||
* Get key seventh chords | ||
* | ||
* @function | ||
* @param {String} name - the key name | ||
* @return {Array} | ||
* @param {string} name - the key name | ||
* @param {Array<number|string>} [degrees] - can be numbers or roman numerals | ||
* @return {Array<string>} seventh chord names | ||
* | ||
* @example | ||
* Key.chords("A major") // => ["AMaj7", "Bm7", "C#m7", "DMaj7", ..,] | ||
* Key.chords("A major", ['I', 'IV', 'V']) // => ["AMaj7", "DMaj7", "E7"] | ||
* Key.chords("A major", [5, 4, 1]) // => ["E7", "DMaj7", AMaj7"] | ||
*/ | ||
@@ -232,7 +238,10 @@ export const chords = leadsheetSymbols(SEVENTHS); | ||
* @function | ||
* @param {String} name - the key name | ||
* @return {Array} | ||
* @param {string} name - the key name | ||
* @param {Array<string|number>} [degrees] | ||
* @return {Array<string>} triad names | ||
* | ||
* @example | ||
* Key.triads("A major") // => ["AM", "Bm", "C#m", "DM", "E7", "F#m", "G#mb5"] | ||
* Key.triads("A major", ['I', 'IV', 'V']) // => ["AMaj7", "DMaj7", "E7"] | ||
* Key.triads("A major", [1, 4, 5]) // => ["AMaj7", "DMaj7", "E7"] | ||
*/ | ||
@@ -245,3 +254,3 @@ export const triads = leadsheetSymbols(TRIADS); | ||
* @function | ||
* @param {String} name - the key name | ||
* @param {string} name - the key name | ||
* @return {Array} | ||
@@ -266,4 +275,4 @@ * | ||
* @function | ||
* @param {String} mode - the relative destination | ||
* @param {String} key - the key source | ||
* @param {string} mode - the relative destination | ||
* @param {string} key - the key source | ||
* | ||
@@ -290,3 +299,3 @@ * @example | ||
* @function | ||
* @param {String} name | ||
* @param {string} name | ||
* @return {Array} an array in the form [tonic, key] | ||
@@ -293,0 +302,0 @@ * |
{ | ||
"name": "tonal-key", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "Conversion between key numbers and note names", | ||
@@ -23,5 +23,6 @@ "repository": "https://github.com/danigb/tonal/extensions/key", | ||
"dependencies": { | ||
"tonal-array": "^2.1.2", | ||
"tonal-distance": "^2.1.2", | ||
"tonal-note": "^2.1.2" | ||
"tonal-array": "^2.2.0", | ||
"tonal-distance": "^2.2.0", | ||
"tonal-note": "^2.2.0", | ||
"tonal-roman-numeral": "^2.2.0" | ||
}, | ||
@@ -28,0 +29,0 @@ "babel": { |
@@ -35,5 +35,5 @@ <a name="module_Key"></a> | ||
- [`.alteredNotes(key)`](#module_Key.alteredNotes) ⇒ <code>Array</code> | ||
- [`.leadsheetSymbols(symbols, keyName)`](#module_Key.leadsheetSymbols) ⇒ <code>function</code> | ||
- [`.chords(name)`](#module_Key.chords) ⇒ <code>Array</code> | ||
- [`.triads(name)`](#module_Key.triads) ⇒ <code>Array</code> | ||
- [`.leadsheetSymbols(symbols, keyName, [degrees])`](#module_Key.leadsheetSymbols) ⇒ <code>function</code> | ||
- [`.chords(name, [degrees])`](#module_Key.chords) ⇒ <code>Array.<string></code> | ||
- [`.triads(name, [degrees])`](#module_Key.triads) ⇒ <code>Array.<string></code> | ||
- [`.secDomChords(name)`](#module_Key.secDomChords) ⇒ <code>Array</code> | ||
@@ -53,3 +53,3 @@ - [`.relative(mode, key)`](#module_Key.relative) | ||
| ------- | ------------------- | | ||
| keyName | <code>String</code> | | ||
| keyName | <code>string</code> | | ||
@@ -110,9 +110,9 @@ **Example** | ||
- name {String}: name | ||
- tonic {String}: key tonic | ||
- mode {String}: key mode | ||
- name {string}: name | ||
- tonic {string}: key tonic | ||
- mode {string}: key mode | ||
- modenum {Number}: mode number (0 major, 1 dorian, ...) | ||
- intervals {Array}: the scale intervals | ||
- scale {Array}: the scale notes | ||
- acc {String}: accidentals of the key signature | ||
- acc {string}: accidentals of the key signature | ||
- alt {Number}: alteration number (a numeric representation of accidentals) | ||
@@ -125,3 +125,3 @@ | ||
| ----- | ------------------- | ------------ | | ||
| name | <code>String</code> | the key name | | ||
| name | <code>string</code> | the key name | | ||
@@ -145,3 +145,3 @@ **Example** | ||
| ----- | ------------------------------------------ | | ||
| key | <code>String</code> \| <code>Object</code> | | ||
| key | <code>string</code> \| <code>Object</code> | | ||
@@ -168,3 +168,3 @@ **Example** | ||
| ----- | ------------------- | ------------ | | ||
| key | <code>String</code> | the key name | | ||
| key | <code>string</code> | the key name | | ||
@@ -179,3 +179,3 @@ **Example** | ||
## `Key.leadsheetSymbols(symbols, keyName)` ⇒ <code>function</code> | ||
## `Key.leadsheetSymbols(symbols, keyName, [degrees])` ⇒ <code>function</code> | ||
@@ -203,6 +203,7 @@ Get a lead-sheet symbols for a given key name | ||
| Param | Type | Description | | ||
| ------- | --------------------------------- | -------------------------------------------- | | ||
| symbols | <code>Array.<String></code> | an array of symbols in major scale order | | ||
| keyName | <code>String</code> | the name of the key you want the symbols for | | ||
| Param | Type | Description | | ||
| --------- | --------------------------------- | -------------------------------------------------------------- | | ||
| symbols | <code>Array.<string></code> | an array of symbols in major scale order | | ||
| keyName | <code>string</code> | the name of the key you want the symbols for | | ||
| [degrees] | <code>Array.<string></code> | the list of degrees. By default from 1 to 7 in ascending order | | ||
@@ -214,2 +215,3 @@ **Example** | ||
chords("D dorian"); //=> ["Dm", "Em", "FM", "G7", "Am", "Bdim", "CM"] | ||
chords("D dorian", ["ii", "V"]); //=> [Em", "G7"] | ||
``` | ||
@@ -219,11 +221,13 @@ | ||
## `Key.chords(name)` ⇒ <code>Array</code> | ||
## `Key.chords(name, [degrees])` ⇒ <code>Array.<string></code> | ||
Get key chords | ||
Get key seventh chords | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Returns**: <code>Array.<string></code> - seventh chord names | ||
| Param | Type | Description | | ||
| ----- | ------------------- | ------------ | | ||
| name | <code>String</code> | the key name | | ||
| Param | Type | Description | | ||
| --------- | ------------------------------------------- | -------------------------------- | | ||
| name | <code>string</code> | the key name | | ||
| [degrees] | <code>Array.<(number\|string)></code> | can be numbers or roman numerals | | ||
@@ -234,2 +238,4 @@ **Example** | ||
Key.chords("A major"); // => ["AMaj7", "Bm7", "C#m7", "DMaj7", ..,] | ||
Key.chords("A major", ["I", "IV", "V"]); // => ["AMaj7", "DMaj7", "E7"] | ||
Key.chords("A major", [5, 4, 1]); // => ["E7", "DMaj7", AMaj7"] | ||
``` | ||
@@ -239,11 +245,13 @@ | ||
## `Key.triads(name)` ⇒ <code>Array</code> | ||
## `Key.triads(name, [degrees])` ⇒ <code>Array.<string></code> | ||
Get key triads | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Returns**: <code>Array.<string></code> - triad names | ||
| Param | Type | Description | | ||
| ----- | ------------------- | ------------ | | ||
| name | <code>String</code> | the key name | | ||
| Param | Type | Description | | ||
| --------- | ------------------------------------------- | ------------ | | ||
| name | <code>string</code> | the key name | | ||
| [degrees] | <code>Array.<(string\|number)></code> | | | ||
@@ -254,2 +262,4 @@ **Example** | ||
Key.triads("A major"); // => ["AM", "Bm", "C#m", "DM", "E7", "F#m", "G#mb5"] | ||
Key.triads("A major", ["I", "IV", "V"]); // => ["AMaj7", "DMaj7", "E7"] | ||
Key.triads("A major", [1, 4, 5]); // => ["AMaj7", "DMaj7", "E7"] | ||
``` | ||
@@ -267,3 +277,3 @@ | ||
| ----- | ------------------- | ------------ | | ||
| name | <code>String</code> | the key name | | ||
| name | <code>string</code> | the key name | | ||
@@ -289,4 +299,4 @@ **Example** | ||
| ----- | ------------------- | ------------------------ | | ||
| mode | <code>String</code> | the relative destination | | ||
| key | <code>String</code> | the key source | | ||
| mode | <code>string</code> | the relative destination | | ||
| key | <code>string</code> | the key source | | ||
@@ -314,3 +324,3 @@ **Example** | ||
| ----- | ------------------- | | ||
| name | <code>String</code> | | ||
| name | <code>string</code> | | ||
@@ -317,0 +327,0 @@ **Example** |
@@ -75,2 +75,14 @@ import * as key from "../index"; | ||
test("chords with degrees", () => { | ||
expect(key.chords("A major", ["i", "ii", "vii"]).join(" ")).toEqual( | ||
"AMaj7 Bm7 G#m7b5" | ||
); | ||
expect(key.chords("A major", ["V", "IV", "I"]).join(" ")).toEqual( | ||
"E7 DMaj7 AMaj7" | ||
); | ||
expect(key.chords("Bb dorian", [5, 4, 1]).join(" ")).toEqual( | ||
"Fm7 Eb7 Bbm7" | ||
); | ||
}); | ||
test("triads", () => { | ||
@@ -77,0 +89,0 @@ expect(key.triads("A major").join(" ")).toEqual("A Bm C#m D E F#m G#dim"); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
127142
1419
316
4
+ Addedtonal-roman-numeral@^2.2.0
+ Addedtonal-roman-numeral@2.2.2(transitive)
Updatedtonal-array@^2.2.0
Updatedtonal-distance@^2.2.0
Updatedtonal-note@^2.2.0