Comparing version 2.2.1 to 2.2.2
{ | ||
"name": "tonal-key", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Conversion between key numbers and note names", | ||
@@ -23,6 +23,6 @@ "repository": "https://github.com/danigb/tonal/extensions/key", | ||
"dependencies": { | ||
"tonal-array": "^2.2.1", | ||
"tonal-distance": "^2.2.1", | ||
"tonal-note": "^2.2.1", | ||
"tonal-roman-numeral": "^2.2.1" | ||
"tonal-array": "^2.2.2", | ||
"tonal-distance": "^2.2.2", | ||
"tonal-note": "^2.2.2", | ||
"tonal-roman-numeral": "^2.2.2" | ||
}, | ||
@@ -29,0 +29,0 @@ "babel": { |
248
README.md
<a name="module_Key"></a> | ||
# Key | ||
[![npm version](https://img.shields.io/npm/v/tonal-key.svg?style=flat-square)](https://www.npmjs.com/package/tonal-key) | ||
@@ -12,31 +11,28 @@ [![tonal](https://img.shields.io/badge/tonal-key-yellow.svg?style=flat-square)](https://www.npmjs.com/browse/keyword/tonal) | ||
**Example** | ||
**Example** | ||
```js | ||
// es6 | ||
import * as Key from "tonal-key"; | ||
import * as Key from "tonal-key" | ||
// es5 | ||
const Key = require("tonal-key"); | ||
const Key = require("tonal-key") | ||
``` | ||
**Example** | ||
**Example** | ||
```js | ||
Key.scale("E mixolydian"); // => [ "E", "F#", "G#", "A", "B", "C#", "D" ] | ||
Key.relative("minor", "C major"); // => "A minor" | ||
Key.scale("E mixolydian") // => [ "E", "F#", "G#", "A", "B", "C#", "D" ] | ||
Key.relative("minor", "C major") // => "A minor" | ||
``` | ||
- [Key](#module_Key) | ||
- [`.degrees`](#module_Key.degrees) β <code>Array</code> | ||
- [`.modeNames(alias)`](#module_Key.modeNames) β <code>Array</code> | ||
- [`.fromAlter(alt)`](#module_Key.fromAlter) β <code>Key</code> | ||
- [`.props(name)`](#module_Key.props) β <code>Object</code> | ||
- [`.scale(key)`](#module_Key.scale) β <code>Array</code> | ||
- [`.alteredNotes(key)`](#module_Key.alteredNotes) β <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> | ||
- [`.relative(mode, key)`](#module_Key.relative) | ||
- [`.tokenize(name)`](#module_Key.tokenize) β <code>Array</code> | ||
* [Key](#module_Key) | ||
* [`.degrees`](#module_Key.degrees) β <code>Array</code> | ||
* [`.modeNames(alias)`](#module_Key.modeNames) β <code>Array</code> | ||
* [`.fromAlter(alt)`](#module_Key.fromAlter) β <code>Key</code> | ||
* [`.props(name)`](#module_Key.props) β <code>Object</code> | ||
* [`.scale(key)`](#module_Key.scale) β <code>Array</code> | ||
* [`.alteredNotes(key)`](#module_Key.alteredNotes) β <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> | ||
* [`.relative(mode, key)`](#module_Key.relative) | ||
* [`.tokenize(name)`](#module_Key.tokenize) β <code>Array</code> | ||
@@ -46,21 +42,17 @@ <a name="module_Key.degrees"></a> | ||
## `Key.degrees` β <code>Array</code> | ||
Get a list of key scale degrees in roman numerals | ||
**Kind**: static constant of [<code>Key</code>](#module_Key) | ||
**Kind**: static constant of [<code>Key</code>](#module_Key) | ||
| Param | Type | | ||
| ------- | ------------------- | | ||
| keyName | <code>string</code> | | ||
| Param | Type | | ||
| --- | --- | | ||
| keyName | <code>string</code> | | ||
**Example** | ||
**Example** | ||
```js | ||
Key.degrees("C major") => ["I", "ii", "iii", "IV", "V", "vi", "vii"] | ||
``` | ||
<a name="module_Key.modeNames"></a> | ||
## `Key.modeNames(alias)` β <code>Array</code> | ||
Get a list of valid mode names. The list of modes will be always in | ||
@@ -70,40 +62,34 @@ increasing order (ionian to locrian) | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Returns**: <code>Array</code> - an array of strings | ||
**Returns**: <code>Array</code> - an array of strings | ||
| Param | Type | Description | | ||
| ----- | -------------------- | ------------------------- | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| alias | <code>Boolean</code> | true to get aliases names | | ||
**Example** | ||
**Example** | ||
```js | ||
Key.modes(); // => [ "ionian", "dorian", "phrygian", "lydian", | ||
Key.modes() // => [ "ionian", "dorian", "phrygian", "lydian", | ||
// "mixolydian", "aeolian", "locrian" ] | ||
Key.modes(true); // => [ "ionian", "dorian", "phrygian", "lydian", | ||
Key.modes(true) // => [ "ionian", "dorian", "phrygian", "lydian", | ||
// "mixolydian", "aeolian", "locrian", "major", "minor" ] | ||
``` | ||
<a name="module_Key.fromAlter"></a> | ||
## `Key.fromAlter(alt)` β <code>Key</code> | ||
Create a major key from alterations | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Returns**: <code>Key</code> - the key object | ||
**Returns**: <code>Key</code> - the key object | ||
| Param | Type | Description | | ||
| ----- | -------------------- | ------------------------------------------------------- | | ||
| alt | <code>Integer</code> | the alteration number (positive sharps, negative flats) | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| alt | <code>Integer</code> | the alteration number (positive sharps, negative flats) | | ||
**Example** | ||
**Example** | ||
```js | ||
Key.fromAlter(2); // => "D major" | ||
Key.fromAlter(2) // => "D major" | ||
``` | ||
<a name="module_Key.props"></a> | ||
## `Key.props(name)` β <code>Object</code> | ||
Return the a key properties object with the following information: | ||
@@ -121,59 +107,50 @@ | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Returns**: <code>Object</code> - the key properties object or null if not a valid key | ||
**Returns**: <code>Object</code> - the key properties object or null if not a valid key | ||
| Param | Type | Description | | ||
| ----- | ------------------- | ------------ | | ||
| name | <code>string</code> | the key name | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| name | <code>string</code> | the key name | | ||
**Example** | ||
**Example** | ||
```js | ||
Key.props("C3 dorian"); // => { tonic: "C", mode: "dorian", ... } | ||
Key.props("C3 dorian") // => { tonic: "C", mode: "dorian", ... } | ||
``` | ||
<a name="module_Key.scale"></a> | ||
## `Key.scale(key)` β <code>Array</code> | ||
Get scale of a key | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Returns**: <code>Array</code> - the key scale | ||
**Returns**: <code>Array</code> - the key scale | ||
| Param | Type | | ||
| ----- | ------------------------------------------ | | ||
| key | <code>string</code> \| <code>Object</code> | | ||
| Param | Type | | ||
| --- | --- | | ||
| key | <code>string</code> \| <code>Object</code> | | ||
**Example** | ||
**Example** | ||
```js | ||
Key.scale("A major"); // => [ "A", "B", "C#", "D", "E", "F#", "G#" ] | ||
Key.scale("Bb minor"); // => [ "Bb", "C", "Db", "Eb", "F", "Gb", "Ab" ] | ||
Key.scale("C dorian"); // => [ "C", "D", "Eb", "F", "G", "A", "Bb" ] | ||
Key.scale("E mixolydian"); // => [ "E", "F#", "G#", "A", "B", "C#", "D" ] | ||
Key.scale("A major") // => [ "A", "B", "C#", "D", "E", "F#", "G#" ] | ||
Key.scale("Bb minor") // => [ "Bb", "C", "Db", "Eb", "F", "Gb", "Ab" ] | ||
Key.scale("C dorian") // => [ "C", "D", "Eb", "F", "G", "A", "Bb" ] | ||
Key.scale("E mixolydian") // => [ "E", "F#", "G#", "A", "B", "C#", "D" ] | ||
``` | ||
<a name="module_Key.alteredNotes"></a> | ||
## `Key.alteredNotes(key)` β <code>Array</code> | ||
Get a list of the altered notes of a given Key. The notes will be in | ||
the same order than in the key signature. | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
| Param | Type | Description | | ||
| ----- | ------------------- | ------------ | | ||
| key | <code>string</code> | the key name | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| key | <code>string</code> | the key name | | ||
**Example** | ||
**Example** | ||
```js | ||
Key.alteredNotes("Eb major"); // => [ "Bb", "Eb", "Ab" ] | ||
Key.alteredNotes("Eb major") // => [ "Bb", "Eb", "Ab" ] | ||
``` | ||
<a name="module_Key.leadsheetSymbols"></a> | ||
## `Key.leadsheetSymbols(symbols, keyName, [degrees])` β <code>function</code> | ||
Get a lead-sheet symbols for a given key name | ||
@@ -200,82 +177,71 @@ | ||
| 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 | | ||
**Example** | ||
**Example** | ||
```js | ||
const chords = Key.leadsheetSymbols(["M", "m", "m", "M", "7", "m", "dim"]); | ||
chords("D dorian"); //=> ["Dm", "Em", "FM", "G7", "Am", "Bdim", "CM"] | ||
chords("D dorian", ["ii", "V"]); //=> [Em", "G7"] | ||
const chords = Key.leadsheetSymbols(["M", "m", "m", "M", "7", "m", "dim"]) | ||
chords("D dorian") //=> ["Dm", "Em", "FM", "G7", "Am", "Bdim", "CM"] | ||
chords("D dorian", ['ii', 'V']) //=> [Em", "G7"] | ||
``` | ||
<a name="module_Key.chords"></a> | ||
## `Key.chords(name, [degrees])` β <code>Array.<string></code> | ||
Get key seventh chords | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Returns**: <code>Array.<string></code> - seventh chord names | ||
**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 | | ||
**Example** | ||
**Example** | ||
```js | ||
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"] | ||
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"] | ||
``` | ||
<a name="module_Key.triads"></a> | ||
## `Key.triads(name, [degrees])` β <code>Array.<string></code> | ||
Get key triads | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Returns**: <code>Array.<string></code> - triad names | ||
**Returns**: <code>Array.<string></code> - triad names | ||
| Param | Type | Description | | ||
| --------- | ------------------------------------------- | ------------ | | ||
| name | <code>string</code> | the key name | | ||
| [degrees] | <code>Array.<(string\|number)></code> | | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| name | <code>string</code> | the key name | | ||
| [degrees] | <code>Array.<(string\|number)></code> | | | ||
**Example** | ||
**Example** | ||
```js | ||
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"] | ||
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"] | ||
``` | ||
<a name="module_Key.secDomChords"></a> | ||
## `Key.secDomChords(name)` β <code>Array</code> | ||
Get secondary dominant key chords | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
| Param | Type | Description | | ||
| ----- | ------------------- | ------------ | | ||
| name | <code>string</code> | the key name | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| name | <code>string</code> | the key name | | ||
**Example** | ||
**Example** | ||
```js | ||
Key.secDomChords("A major"); // => ["E7", "F#7", ...] | ||
Key.secDomChords("A major") // => ["E7", "F#7", ...] | ||
``` | ||
<a name="module_Key.relative"></a> | ||
## `Key.relative(mode, key)` | ||
Get relative of a key. Two keys are relative when the have the same | ||
@@ -286,36 +252,32 @@ key signature (for example C major and A minor) | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
| Param | Type | Description | | ||
| ----- | ------------------- | ------------------------ | | ||
| mode | <code>string</code> | the relative destination | | ||
| key | <code>string</code> | the key source | | ||
| Param | Type | Description | | ||
| --- | --- | --- | | ||
| mode | <code>string</code> | the relative destination | | ||
| key | <code>string</code> | the key source | | ||
**Example** | ||
**Example** | ||
```js | ||
Key.relative("dorian", "B major"); // => "C# dorian" | ||
Key.relative("dorian", "B major") // => "C# dorian" | ||
// partial application | ||
var minor = Key.relative("minor"); | ||
minor("C major"); // => "A minor" | ||
minor("E major"); // => "C# minor" | ||
var minor = Key.relative("minor") | ||
minor("C major") // => "A minor" | ||
minor("E major") // => "C# minor" | ||
``` | ||
<a name="module_Key.tokenize"></a> | ||
## `Key.tokenize(name)` β <code>Array</code> | ||
Split the key name into its components (pitch class tonic and mode name) | ||
**Kind**: static method of [<code>Key</code>](#module_Key) | ||
**Returns**: <code>Array</code> - an array in the form [tonic, key] | ||
**Returns**: <code>Array</code> - an array in the form [tonic, key] | ||
| Param | Type | | ||
| ----- | ------------------- | | ||
| name | <code>string</code> | | ||
| Param | Type | | ||
| --- | --- | | ||
| name | <code>string</code> | | ||
**Example** | ||
**Example** | ||
```js | ||
Key.tokenize("C major"); // => ["C", "major"] | ||
Key.tokenize("C major") // => ["C", "major"] | ||
``` |
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
126137
278
Updatedtonal-array@^2.2.2
Updatedtonal-distance@^2.2.2
Updatedtonal-note@^2.2.2
Updatedtonal-roman-numeral@^2.2.2