tonal-scale
Advanced tools
Comparing version 1.0.0-pre6 to 1.0.0
@@ -17,7 +17,13 @@ 'use strict'; | ||
* This module provides functions to get and manipulate scales. | ||
* | ||
* @example | ||
* // es6 | ||
* import * as Scale from "tonal-scale" | ||
* // es5 | ||
* const Scale = require("tonal-scale"); | ||
* | ||
* @example | ||
* scale.notes('Ab bebop') // => [ 'Ab', 'Bb', 'C', 'Db', 'Eb', 'F', 'Gb', 'G' ] | ||
* scale.names() => ['major', 'minor', ...] | ||
* @module scale | ||
* Scale.notes("Ab bebop") // => [ "Ab", "Bb", "C", "Db", "Eb", "F", "Gb", "G" ] | ||
* Scale.names() => ["major", "minor", ...] | ||
* @module Scale | ||
*/ | ||
@@ -66,4 +72,3 @@ var NO_SCALE = Object.freeze({ | ||
* @example | ||
* const scale = require('tonal-scale') | ||
* scale.names() // => ['maj7', ...] | ||
* Scale.names() // => ["maj7", ...] | ||
*/ | ||
@@ -83,3 +88,3 @@ var names = tonalDictionary.scale.names; | ||
* @example | ||
* scale.intervals('major') // => [ '1P', '2M', '3M', '4P', '5P', '6M', '7M' ] | ||
* Scale.intervals("major") // => [ "1P", "2M", "3M", "4P", "5P", "6M", "7M" ] | ||
*/ | ||
@@ -103,7 +108,7 @@ var intervals = function (name$$1) { | ||
* @example | ||
* scale.notes("C", 'major') // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
* scale.notes("C major") // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
* scale.notes("C4", 'major') // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
* scale.notes("A4", "no-scale") // => [] | ||
* scale.notes("blah", "major") // => [] | ||
* Scale.notes("C", "major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
* Scale.notes("C major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
* Scale.notes("C4", "major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
* Scale.notes("A4", "no-scale") // => [] | ||
* Scale.notes("blah", "major") // => [] | ||
*/ | ||
@@ -134,3 +139,3 @@ function notes(nameOrTonic, name$$1) { | ||
* note name or null and name can be any arbitrary string | ||
* (this function doesn't check if that scale name exists) | ||
* (this function doesn"t check if that scale name exists) | ||
* | ||
@@ -141,5 +146,5 @@ * @function | ||
* @example | ||
* scale.tokenize('C mixolydean') // => ["C", "mixolydean"] | ||
* scale.tokenize('anything is valid') // => [null, "anything is valid"] | ||
* scale.tokenize() // => [null, null] | ||
* Scale.tokenize("C mixolydean") // => ["C", "mixolydean"] | ||
* Scale.tokenize("anything is valid") // => ["", "anything is valid"] | ||
* Scale.tokenize() // => ["", ""] | ||
*/ | ||
@@ -146,0 +151,0 @@ function tokenize(str) { |
@@ -7,7 +7,13 @@ /** | ||
* This module provides functions to get and manipulate scales. | ||
* | ||
* @example | ||
* // es6 | ||
* import * as Scale from "tonal-scale" | ||
* // es5 | ||
* const Scale = require("tonal-scale"); | ||
* | ||
* @example | ||
* scale.notes('Ab bebop') // => [ 'Ab', 'Bb', 'C', 'Db', 'Eb', 'F', 'Gb', 'G' ] | ||
* scale.names() => ['major', 'minor', ...] | ||
* @module scale | ||
* Scale.notes("Ab bebop") // => [ "Ab", "Bb", "C", "Db", "Eb", "F", "Gb", "G" ] | ||
* Scale.names() => ["major", "minor", ...] | ||
* @module Scale | ||
*/ | ||
@@ -67,4 +73,3 @@ import { name as noteName, pc } from "tonal-note"; | ||
* @example | ||
* const scale = require('tonal-scale') | ||
* scale.names() // => ['maj7', ...] | ||
* Scale.names() // => ["maj7", ...] | ||
*/ | ||
@@ -84,3 +89,3 @@ export var names = scale.names; | ||
* @example | ||
* scale.intervals('major') // => [ '1P', '2M', '3M', '4P', '5P', '6M', '7M' ] | ||
* Scale.intervals("major") // => [ "1P", "2M", "3M", "4P", "5P", "6M", "7M" ] | ||
*/ | ||
@@ -104,7 +109,7 @@ export var intervals = function (name) { | ||
* @example | ||
* scale.notes("C", 'major') // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
* scale.notes("C major") // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
* scale.notes("C4", 'major') // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
* scale.notes("A4", "no-scale") // => [] | ||
* scale.notes("blah", "major") // => [] | ||
* Scale.notes("C", "major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
* Scale.notes("C major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
* Scale.notes("C4", "major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
* Scale.notes("A4", "no-scale") // => [] | ||
* Scale.notes("blah", "major") // => [] | ||
*/ | ||
@@ -135,3 +140,3 @@ export function notes(nameOrTonic, name) { | ||
* note name or null and name can be any arbitrary string | ||
* (this function doesn't check if that scale name exists) | ||
* (this function doesn"t check if that scale name exists) | ||
* | ||
@@ -142,5 +147,5 @@ * @function | ||
* @example | ||
* scale.tokenize('C mixolydean') // => ["C", "mixolydean"] | ||
* scale.tokenize('anything is valid') // => [null, "anything is valid"] | ||
* scale.tokenize() // => [null, null] | ||
* Scale.tokenize("C mixolydean") // => ["C", "mixolydean"] | ||
* Scale.tokenize("anything is valid") // => ["", "anything is valid"] | ||
* Scale.tokenize() // => ["", ""] | ||
*/ | ||
@@ -147,0 +152,0 @@ export function tokenize(str) { |
35
index.js
@@ -7,7 +7,13 @@ /** | ||
* This module provides functions to get and manipulate scales. | ||
* | ||
* @example | ||
* // es6 | ||
* import * as Scale from "tonal-scale" | ||
* // es5 | ||
* const Scale = require("tonal-scale"); | ||
* | ||
* @example | ||
* scale.notes('Ab bebop') // => [ 'Ab', 'Bb', 'C', 'Db', 'Eb', 'F', 'Gb', 'G' ] | ||
* scale.names() => ['major', 'minor', ...] | ||
* @module scale | ||
* Scale.notes("Ab bebop") // => [ "Ab", "Bb", "C", "Db", "Eb", "F", "Gb", "G" ] | ||
* Scale.names() => ["major", "minor", ...] | ||
* @module Scale | ||
*/ | ||
@@ -67,4 +73,3 @@ import { name as noteName, pc } from "tonal-note"; | ||
* @example | ||
* const scale = require('tonal-scale') | ||
* scale.names() // => ['maj7', ...] | ||
* Scale.names() // => ["maj7", ...] | ||
*/ | ||
@@ -84,3 +89,3 @@ export const names = scale.names; | ||
* @example | ||
* scale.intervals('major') // => [ '1P', '2M', '3M', '4P', '5P', '6M', '7M' ] | ||
* Scale.intervals("major") // => [ "1P", "2M", "3M", "4P", "5P", "6M", "7M" ] | ||
*/ | ||
@@ -104,7 +109,7 @@ export const intervals = name => { | ||
* @example | ||
* scale.notes("C", 'major') // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
* scale.notes("C major") // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
* scale.notes("C4", 'major') // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
* scale.notes("A4", "no-scale") // => [] | ||
* scale.notes("blah", "major") // => [] | ||
* Scale.notes("C", "major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
* Scale.notes("C major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
* Scale.notes("C4", "major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
* Scale.notes("A4", "no-scale") // => [] | ||
* Scale.notes("blah", "major") // => [] | ||
*/ | ||
@@ -135,3 +140,3 @@ export function notes(nameOrTonic, name) { | ||
* note name or null and name can be any arbitrary string | ||
* (this function doesn't check if that scale name exists) | ||
* (this function doesn"t check if that scale name exists) | ||
* | ||
@@ -142,5 +147,5 @@ * @function | ||
* @example | ||
* scale.tokenize('C mixolydean') // => ["C", "mixolydean"] | ||
* scale.tokenize('anything is valid') // => ["", "anything is valid"] | ||
* scale.tokenize() // => ["", ""] | ||
* Scale.tokenize("C mixolydean") // => ["C", "mixolydean"] | ||
* Scale.tokenize("anything is valid") // => ["", "anything is valid"] | ||
* Scale.tokenize() // => ["", ""] | ||
*/ | ||
@@ -147,0 +152,0 @@ export function tokenize(str) { |
{ | ||
"name": "tonal-scale", | ||
"version": "1.0.0-pre6", | ||
"version": "1.0.0", | ||
"description": "Music scales creation and manipulation", | ||
@@ -21,7 +21,7 @@ "repository": "https://github.com/danigb/tonal/packages/scale", | ||
"dependencies": { | ||
"tonal-array": "^1.0.0-pre6", | ||
"tonal-dictionary": "^1.0.0-pre6", | ||
"tonal-distance": "^1.0.0-pre6", | ||
"tonal-note": "^1.0.0-pre6", | ||
"tonal-pcset": "^1.0.0-pre6" | ||
"tonal-array": "^1.0.0", | ||
"tonal-dictionary": "^1.0.0", | ||
"tonal-distance": "^1.0.0", | ||
"tonal-note": "^1.0.0", | ||
"tonal-pcset": "^1.0.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "babel": { |
128
README.md
@@ -1,4 +0,4 @@ | ||
<a name="module_scale"></a> | ||
<a name="module_Scale"></a> | ||
# scale | ||
# Scale | ||
[![npm version](https://img.shields.io/npm/v/tonal-scale.svg?style=flat-square)](https://www.npmjs.com/package/tonal-scale) | ||
@@ -12,22 +12,29 @@ | ||
```js | ||
scale.notes('Ab bebop') // => [ 'Ab', 'Bb', 'C', 'Db', 'Eb', 'F', 'Gb', 'G' ] | ||
scale.names() => ['major', 'minor', ...] | ||
// es6 | ||
import * as Scale from "tonal-scale" | ||
// es5 | ||
const Scale = require("tonal-scale"); | ||
``` | ||
**Example** | ||
```js | ||
Scale.notes("Ab bebop") // => [ "Ab", "Bb", "C", "Db", "Eb", "F", "Gb", "G" ] | ||
Scale.names() => ["major", "minor", ...] | ||
``` | ||
* [scale](#module_scale) | ||
* [`.props(name)`](#module_scale.props) ⇒ <code>Object</code> | ||
* [`.names(aliases)`](#module_scale.names) ⇒ <code>Array</code> | ||
* [`.intervals(name)`](#module_scale.intervals) ⇒ <code>Array.<String></code> | ||
* [`.notes(tonic, nameOrTonic, [name])`](#module_scale.notes) ⇒ <code>Array</code> | ||
* [`.exists(name)`](#module_scale.exists) ⇒ <code>Boolean</code> | ||
* [`.tokenize(name)`](#module_scale.tokenize) ⇒ <code>Array</code> | ||
* [`.modeNames(name)`](#module_scale.modeNames) | ||
* [`.chords(name)`](#module_scale.chords) | ||
* [`.toScale(notes)`](#module_scale.toScale) ⇒ <code>Array</code> | ||
* [`.supersets(name)`](#module_scale.supersets) ⇒ <code>Array</code> | ||
* [`.subsets(name)`](#module_scale.subsets) ⇒ <code>Array</code> | ||
* [Scale](#module_Scale) | ||
* [`.props(name)`](#module_Scale.props) ⇒ <code>Object</code> | ||
* [`.names(aliases)`](#module_Scale.names) ⇒ <code>Array</code> | ||
* [`.intervals(name)`](#module_Scale.intervals) ⇒ <code>Array.<String></code> | ||
* [`.notes(tonic, nameOrTonic, [name])`](#module_Scale.notes) ⇒ <code>Array</code> | ||
* [`.exists(name)`](#module_Scale.exists) ⇒ <code>Boolean</code> | ||
* [`.tokenize(name)`](#module_Scale.tokenize) ⇒ <code>Array</code> | ||
* [`.modeNames(name)`](#module_Scale.modeNames) | ||
* [`.chords(name)`](#module_Scale.chords) | ||
* [`.toScale(notes)`](#module_Scale.toScale) ⇒ <code>Array</code> | ||
* [`.supersets(name)`](#module_Scale.supersets) ⇒ <code>Array</code> | ||
* [`.subsets(name)`](#module_Scale.subsets) ⇒ <code>Array</code> | ||
<a name="module_scale.props"></a> | ||
<a name="module_Scale.props"></a> | ||
## `scale.props(name)` ⇒ <code>Object</code> | ||
## `Scale.props(name)` ⇒ <code>Object</code> | ||
Get scale properties. It returns an object with: | ||
@@ -40,3 +47,3 @@ - name: the scale name | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
@@ -47,8 +54,8 @@ | Param | Type | Description | | ||
<a name="module_scale.names"></a> | ||
<a name="module_Scale.names"></a> | ||
## `scale.names(aliases)` ⇒ <code>Array</code> | ||
## `Scale.names(aliases)` ⇒ <code>Array</code> | ||
Return the available scale names | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
**Returns**: <code>Array</code> - the scale names | ||
@@ -62,8 +69,7 @@ | ||
```js | ||
const scale = require('tonal-scale') | ||
scale.names() // => ['maj7', ...] | ||
Scale.names() // => ["maj7", ...] | ||
``` | ||
<a name="module_scale.intervals"></a> | ||
<a name="module_Scale.intervals"></a> | ||
## `scale.intervals(name)` ⇒ <code>Array.<String></code> | ||
## `Scale.intervals(name)` ⇒ <code>Array.<String></code> | ||
Given a scale name, return its intervals. The name can be the type and | ||
@@ -74,3 +80,3 @@ optionally the tonic (which is ignored) | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
**Returns**: <code>Array.<String></code> - the scale intervals if is a known scale or an empty | ||
@@ -85,7 +91,7 @@ array if no scale found | ||
```js | ||
scale.intervals('major') // => [ '1P', '2M', '3M', '4P', '5P', '6M', '7M' ] | ||
Scale.intervals("major") // => [ "1P", "2M", "3M", "4P", "5P", "6M", "7M" ] | ||
``` | ||
<a name="module_scale.notes"></a> | ||
<a name="module_Scale.notes"></a> | ||
## `scale.notes(tonic, nameOrTonic, [name])` ⇒ <code>Array</code> | ||
## `Scale.notes(tonic, nameOrTonic, [name])` ⇒ <code>Array</code> | ||
Get the notes (pitch classes) of a scale. | ||
@@ -95,3 +101,3 @@ | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
**Returns**: <code>Array</code> - a pitch classes array | ||
@@ -107,14 +113,14 @@ | ||
```js | ||
scale.notes("C", 'major') // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
scale.notes("C major") // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
scale.notes("C4", 'major') // => [ 'C', 'D', 'E', 'F', 'G', 'A', 'B' ] | ||
scale.notes("A4", "no-scale") // => [] | ||
scale.notes("blah", "major") // => [] | ||
Scale.notes("C", "major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
Scale.notes("C major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
Scale.notes("C4", "major") // => [ "C", "D", "E", "F", "G", "A", "B" ] | ||
Scale.notes("A4", "no-scale") // => [] | ||
Scale.notes("blah", "major") // => [] | ||
``` | ||
<a name="module_scale.exists"></a> | ||
<a name="module_Scale.exists"></a> | ||
## `scale.exists(name)` ⇒ <code>Boolean</code> | ||
## `Scale.exists(name)` ⇒ <code>Boolean</code> | ||
Check if the given name is a known scale from the scales dictionary | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
@@ -125,5 +131,5 @@ | Param | Type | Description | | ||
<a name="module_scale.tokenize"></a> | ||
<a name="module_Scale.tokenize"></a> | ||
## `scale.tokenize(name)` ⇒ <code>Array</code> | ||
## `Scale.tokenize(name)` ⇒ <code>Array</code> | ||
Given a string with a scale name and (optionally) a tonic, split | ||
@@ -134,5 +140,5 @@ that components. | ||
note name or null and name can be any arbitrary string | ||
(this function doesn't check if that scale name exists) | ||
(this function doesn"t check if that scale name exists) | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
**Returns**: <code>Array</code> - an array [tonic, name] | ||
@@ -146,12 +152,12 @@ | ||
```js | ||
scale.tokenize('C mixolydean') // => ["C", "mixolydean"] | ||
scale.tokenize('anything is valid') // => ["", "anything is valid"] | ||
scale.tokenize() // => ["", ""] | ||
Scale.tokenize("C mixolydean") // => ["C", "mixolydean"] | ||
Scale.tokenize("anything is valid") // => ["", "anything is valid"] | ||
Scale.tokenize() // => ["", ""] | ||
``` | ||
<a name="module_scale.modeNames"></a> | ||
<a name="module_Scale.modeNames"></a> | ||
## `scale.modeNames(name)` | ||
## `Scale.modeNames(name)` | ||
Find mode names of a scale | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
@@ -162,8 +168,8 @@ | Param | Type | Description | | ||
<a name="module_scale.chords"></a> | ||
<a name="module_Scale.chords"></a> | ||
## `scale.chords(name)` | ||
## `Scale.chords(name)` | ||
Get all chords that fits a given scale | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
@@ -174,9 +180,9 @@ | Param | Type | | ||
<a name="module_scale.toScale"></a> | ||
<a name="module_Scale.toScale"></a> | ||
## `scale.toScale(notes)` ⇒ <code>Array</code> | ||
## `Scale.toScale(notes)` ⇒ <code>Array</code> | ||
Given an array of notes, return the scale: a pitch class set starting from | ||
the first note of the array | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
@@ -187,9 +193,9 @@ | Param | Type | | ||
<a name="module_scale.supersets"></a> | ||
<a name="module_Scale.supersets"></a> | ||
## `scale.supersets(name)` ⇒ <code>Array</code> | ||
## `Scale.supersets(name)` ⇒ <code>Array</code> | ||
Get all scales names that are a superset of the given one | ||
(has the same notes and at least one more) | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
**Returns**: <code>Array</code> - a list of scale names | ||
@@ -201,9 +207,9 @@ | ||
<a name="module_scale.subsets"></a> | ||
<a name="module_Scale.subsets"></a> | ||
## `scale.subsets(name)` ⇒ <code>Array</code> | ||
## `Scale.subsets(name)` ⇒ <code>Array</code> | ||
Find all scales names that are a subset of the given one | ||
(has less notes but all from the given scale) | ||
**Kind**: static method of [<code>scale</code>](#module_scale) | ||
**Kind**: static method of [<code>Scale</code>](#module_Scale) | ||
**Returns**: <code>Array</code> - a list of scale names | ||
@@ -210,0 +216,0 @@ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
104531
2538
1
206
Updatedtonal-array@^1.0.0
Updatedtonal-dictionary@^1.0.0
Updatedtonal-distance@^1.0.0
Updatedtonal-note@^1.0.0
Updatedtonal-pcset@^1.0.0