tonal-pcset
Advanced tools
Comparing version 1.0.0-pre6 to 1.0.0
@@ -21,4 +21,7 @@ 'use strict'; | ||
* ```js | ||
* var pcset = require('tonal-pcset') | ||
* pcset.isEqual('c2 d5 e6', 'c6 e3 d1') // => true | ||
* // es6 | ||
* import PcSet from "tonal-pcset" | ||
* var PcSet = require("tonal-pcset") | ||
* | ||
* PcSet.isEqual("c2 d5 e6", "c6 e3 d1") // => true | ||
* ``` | ||
@@ -28,11 +31,11 @@ * | ||
* | ||
* @module pcset | ||
* @module PcSet | ||
*/ | ||
var chr = function (str) { return tonalNote.chroma(str) || tonalInterval.chroma(str) || 0; }; | ||
var pcsetNum = function (set) { return parseInt(chroma$2(set), 2); }; | ||
var compact = function (arr) { return arr.filter(function (x) { return x; }); }; | ||
var clen = function (chroma$$1) { return chroma$$1.replace(/0/g, "").length; }; | ||
/** | ||
* Get chroma of a pitch class set. A chroma identifies each set uniquely. | ||
* It's a 12-digit binary each presenting one semitone of the octave. | ||
* It"s a 12-digit binary each presenting one semitone of the octave. | ||
* | ||
@@ -45,3 +48,3 @@ * Note that this function accepts a chroma as parameter and return it | ||
* @example | ||
* pcset.chroma(["C", "D", "E"]) // => '1010100000000' | ||
* PcSet.chroma(["C", "D", "E"]) // => "1010100000000" | ||
*/ | ||
@@ -58,5 +61,19 @@ function chroma$2(set) { | ||
var all = null; | ||
/** | ||
* Get a list of all possible chromas (all possible scales) | ||
* More information: http://allthescales.org/ | ||
* @return {Array} an array of possible chromas from '10000000000' to '11111111111' | ||
* | ||
*/ | ||
function chromas(n) { | ||
all = all || tonalArray.range(2048, 4095).map(function (n) { return n.toString(2); }); | ||
return typeof n === "number" | ||
? all.filter(function (chroma$$1) { return clen(chroma$$1) === n; }) | ||
: all.slice(); | ||
} | ||
/** | ||
* Given a a list of notes or a pcset chroma, produce the rotations | ||
* of the chroma discarding the ones that starts with '0' | ||
* of the chroma discarding the ones that starts with "0" | ||
* | ||
@@ -67,7 +84,7 @@ * This is used, for example, to get all the modes of a scale. | ||
* @param {Boolean} normalize - (Optional, true by default) remove all | ||
* the rotations that starts with '0' | ||
* the rotations that starts with "0" | ||
* @return {Array<String>} an array with all the modes of the chroma | ||
* | ||
* @example | ||
* pcset.modes(["C", "D", "E"]).map(pcset.intervals) | ||
* PcSet.modes(["C", "D", "E"]).map(PcSet.intervals) | ||
*/ | ||
@@ -77,3 +94,3 @@ function modes(set, normalize) { | ||
var binary = chroma$2(set).split(""); | ||
return compact( | ||
return tonalArray.compact( | ||
binary.map(function(_, i) { | ||
@@ -92,4 +109,4 @@ var r = tonalArray.rotate(i, binary); | ||
* @example | ||
* pcset.isChroma('101010101010') // => true | ||
* pcset.isChroma('101001') // => false | ||
* PcSet.isChroma("101010101010") // => true | ||
* PcSet.isChroma("101001") // => false | ||
*/ | ||
@@ -102,11 +119,11 @@ function isChroma(set) { | ||
/** | ||
* Given a pcset (notes or chroma) return it's intervals | ||
* Given a pcset (notes or chroma) return it"s intervals | ||
* @param {String|Array} pcset - the pitch class set (notes or chroma) | ||
* @return {Array} intervals or empty array if not valid pcset | ||
* @example | ||
* pcset.intervals('1010100000000') => ["1P", "2M", "3M"] | ||
* PcSet.intervals("1010100000000") => ["1P", "2M", "3M"] | ||
*/ | ||
function intervals(set) { | ||
if (!isChroma(set)) { return []; } | ||
return compact( | ||
return tonalArray.compact( | ||
set.split("").map(function(d, i) { | ||
@@ -125,3 +142,3 @@ return d === "1" ? IVLS[i] : null; | ||
* @example | ||
* pcset.isEqual(["c2", "d3"], ["c5", "d2"]) // => true | ||
* PcSet.isEqual(["c2", "d3"], ["c5", "d2"]) // => true | ||
*/ | ||
@@ -143,3 +160,3 @@ function isEqual(s1, s2) { | ||
* @example | ||
* const inCMajor = pcset.isSubsetOf(["C", "E", "G"]) | ||
* const inCMajor = PcSet.isSubsetOf(["C", "E", "G"]) | ||
* inCMajor(["e6", "c4"]) // => true | ||
@@ -165,3 +182,3 @@ * inCMajor(["e6", "c4", "d3"]) // => false | ||
* @example | ||
* const extendsCMajor = pcset.isSupersetOf(["C", "E", "G"]) | ||
* const extendsCMajor = PcSet.isSupersetOf(["C", "E", "G"]) | ||
* extendsCMajor(["e6", "a", "c4", "g2"]) // => true | ||
@@ -185,4 +202,4 @@ * extendsCMajor(["c6", "e4", "g3"]) // => false | ||
* @example | ||
* pcset.includes(["C", "D", "E"], 'C4') // => true | ||
* pcset.includes(["C", "D", "E"], 'C#4') // => false | ||
* PcSet.includes(["C", "D", "E"], "C4") // => true | ||
* PcSet.includes(["C", "D", "E"], "C#4") // => false | ||
*/ | ||
@@ -205,4 +222,4 @@ function includes(set, note) { | ||
* @example | ||
* pcset.filter(["C", "D", "E"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ 'c2', 'd2', 'c3', 'd3' ]) | ||
* pcset.filter(["C2"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ 'c2', 'c3' ]) | ||
* PcSet.filter(["C", "D", "E"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ "c2", "d2", "c3", "d3" ]) | ||
* PcSet.filter(["C2"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ "c2", "c3" ]) | ||
*/ | ||
@@ -215,2 +232,3 @@ function filter(set, notes) { | ||
exports.chroma = chroma$2; | ||
exports.chromas = chromas; | ||
exports.modes = modes; | ||
@@ -217,0 +235,0 @@ exports.isChroma = isChroma; |
@@ -13,4 +13,7 @@ /** | ||
* ```js | ||
* var pcset = require('tonal-pcset') | ||
* pcset.isEqual('c2 d5 e6', 'c6 e3 d1') // => true | ||
* // es6 | ||
* import PcSet from "tonal-pcset" | ||
* var PcSet = require("tonal-pcset") | ||
* | ||
* PcSet.isEqual("c2 d5 e6", "c6 e3 d1") // => true | ||
* ``` | ||
@@ -20,15 +23,15 @@ * | ||
* | ||
* @module pcset | ||
* @module PcSet | ||
*/ | ||
import { chroma as notechr } from "tonal-note"; | ||
import { chroma as ivlchr } from "tonal-interval"; | ||
import { rotate } from "tonal-array"; | ||
import { rotate, range, compact } from "tonal-array"; | ||
var chr = function (str) { return notechr(str) || ivlchr(str) || 0; }; | ||
var pcsetNum = function (set) { return parseInt(chroma(set), 2); }; | ||
var compact = function (arr) { return arr.filter(function (x) { return x; }); }; | ||
var clen = function (chroma) { return chroma.replace(/0/g, "").length; }; | ||
/** | ||
* Get chroma of a pitch class set. A chroma identifies each set uniquely. | ||
* It's a 12-digit binary each presenting one semitone of the octave. | ||
* It"s a 12-digit binary each presenting one semitone of the octave. | ||
* | ||
@@ -41,3 +44,3 @@ * Note that this function accepts a chroma as parameter and return it | ||
* @example | ||
* pcset.chroma(["C", "D", "E"]) // => '1010100000000' | ||
* PcSet.chroma(["C", "D", "E"]) // => "1010100000000" | ||
*/ | ||
@@ -54,5 +57,19 @@ export function chroma(set) { | ||
var all = null; | ||
/** | ||
* Get a list of all possible chromas (all possible scales) | ||
* More information: http://allthescales.org/ | ||
* @return {Array} an array of possible chromas from '10000000000' to '11111111111' | ||
* | ||
*/ | ||
export function chromas(n) { | ||
all = all || range(2048, 4095).map(function (n) { return n.toString(2); }); | ||
return typeof n === "number" | ||
? all.filter(function (chroma) { return clen(chroma) === n; }) | ||
: all.slice(); | ||
} | ||
/** | ||
* Given a a list of notes or a pcset chroma, produce the rotations | ||
* of the chroma discarding the ones that starts with '0' | ||
* of the chroma discarding the ones that starts with "0" | ||
* | ||
@@ -63,7 +80,7 @@ * This is used, for example, to get all the modes of a scale. | ||
* @param {Boolean} normalize - (Optional, true by default) remove all | ||
* the rotations that starts with '0' | ||
* the rotations that starts with "0" | ||
* @return {Array<String>} an array with all the modes of the chroma | ||
* | ||
* @example | ||
* pcset.modes(["C", "D", "E"]).map(pcset.intervals) | ||
* PcSet.modes(["C", "D", "E"]).map(PcSet.intervals) | ||
*/ | ||
@@ -87,4 +104,4 @@ export function modes(set, normalize) { | ||
* @example | ||
* pcset.isChroma('101010101010') // => true | ||
* pcset.isChroma('101001') // => false | ||
* PcSet.isChroma("101010101010") // => true | ||
* PcSet.isChroma("101001") // => false | ||
*/ | ||
@@ -97,7 +114,7 @@ export function isChroma(set) { | ||
/** | ||
* Given a pcset (notes or chroma) return it's intervals | ||
* Given a pcset (notes or chroma) return it"s intervals | ||
* @param {String|Array} pcset - the pitch class set (notes or chroma) | ||
* @return {Array} intervals or empty array if not valid pcset | ||
* @example | ||
* pcset.intervals('1010100000000') => ["1P", "2M", "3M"] | ||
* PcSet.intervals("1010100000000") => ["1P", "2M", "3M"] | ||
*/ | ||
@@ -120,3 +137,3 @@ export function intervals(set) { | ||
* @example | ||
* pcset.isEqual(["c2", "d3"], ["c5", "d2"]) // => true | ||
* PcSet.isEqual(["c2", "d3"], ["c5", "d2"]) // => true | ||
*/ | ||
@@ -138,3 +155,3 @@ export function isEqual(s1, s2) { | ||
* @example | ||
* const inCMajor = pcset.isSubsetOf(["C", "E", "G"]) | ||
* const inCMajor = PcSet.isSubsetOf(["C", "E", "G"]) | ||
* inCMajor(["e6", "c4"]) // => true | ||
@@ -160,3 +177,3 @@ * inCMajor(["e6", "c4", "d3"]) // => false | ||
* @example | ||
* const extendsCMajor = pcset.isSupersetOf(["C", "E", "G"]) | ||
* const extendsCMajor = PcSet.isSupersetOf(["C", "E", "G"]) | ||
* extendsCMajor(["e6", "a", "c4", "g2"]) // => true | ||
@@ -180,4 +197,4 @@ * extendsCMajor(["c6", "e4", "g3"]) // => false | ||
* @example | ||
* pcset.includes(["C", "D", "E"], 'C4') // => true | ||
* pcset.includes(["C", "D", "E"], 'C#4') // => false | ||
* PcSet.includes(["C", "D", "E"], "C4") // => true | ||
* PcSet.includes(["C", "D", "E"], "C#4") // => false | ||
*/ | ||
@@ -200,4 +217,4 @@ export function includes(set, note) { | ||
* @example | ||
* pcset.filter(["C", "D", "E"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ 'c2', 'd2', 'c3', 'd3' ]) | ||
* pcset.filter(["C2"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ 'c2', 'c3' ]) | ||
* PcSet.filter(["C", "D", "E"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ "c2", "d2", "c3", "d3" ]) | ||
* PcSet.filter(["C2"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ "c2", "c3" ]) | ||
*/ | ||
@@ -204,0 +221,0 @@ export function filter(set, notes) { |
59
index.js
@@ -13,4 +13,7 @@ /** | ||
* ```js | ||
* var pcset = require('tonal-pcset') | ||
* pcset.isEqual('c2 d5 e6', 'c6 e3 d1') // => true | ||
* // es6 | ||
* import PcSet from "tonal-pcset" | ||
* var PcSet = require("tonal-pcset") | ||
* | ||
* PcSet.isEqual("c2 d5 e6", "c6 e3 d1") // => true | ||
* ``` | ||
@@ -20,15 +23,15 @@ * | ||
* | ||
* @module pcset | ||
* @module PcSet | ||
*/ | ||
import { chroma as notechr } from "tonal-note"; | ||
import { chroma as ivlchr } from "tonal-interval"; | ||
import { rotate } from "tonal-array"; | ||
import { rotate, range, compact } from "tonal-array"; | ||
const chr = str => notechr(str) || ivlchr(str) || 0; | ||
const pcsetNum = set => parseInt(chroma(set), 2); | ||
const compact = arr => arr.filter(x => x); | ||
const clen = chroma => chroma.replace(/0/g, "").length; | ||
/** | ||
* Get chroma of a pitch class set. A chroma identifies each set uniquely. | ||
* It's a 12-digit binary each presenting one semitone of the octave. | ||
* It"s a 12-digit binary each presenting one semitone of the octave. | ||
* | ||
@@ -41,3 +44,3 @@ * Note that this function accepts a chroma as parameter and return it | ||
* @example | ||
* pcset.chroma(["C", "D", "E"]) // => '1010100000000' | ||
* PcSet.chroma(["C", "D", "E"]) // => "1010100000000" | ||
*/ | ||
@@ -54,5 +57,19 @@ export function chroma(set) { | ||
let all = null; | ||
/** | ||
* Get a list of all possible chromas (all possible scales) | ||
* More information: http://allthescales.org/ | ||
* @return {Array} an array of possible chromas from '10000000000' to '11111111111' | ||
* | ||
*/ | ||
export function chromas(n) { | ||
all = all || range(2048, 4095).map(n => n.toString(2)); | ||
return typeof n === "number" | ||
? all.filter(chroma => clen(chroma) === n) | ||
: all.slice(); | ||
} | ||
/** | ||
* Given a a list of notes or a pcset chroma, produce the rotations | ||
* of the chroma discarding the ones that starts with '0' | ||
* of the chroma discarding the ones that starts with "0" | ||
* | ||
@@ -63,7 +80,7 @@ * This is used, for example, to get all the modes of a scale. | ||
* @param {Boolean} normalize - (Optional, true by default) remove all | ||
* the rotations that starts with '0' | ||
* the rotations that starts with "0" | ||
* @return {Array<String>} an array with all the modes of the chroma | ||
* | ||
* @example | ||
* pcset.modes(["C", "D", "E"]).map(pcset.intervals) | ||
* PcSet.modes(["C", "D", "E"]).map(PcSet.intervals) | ||
*/ | ||
@@ -87,4 +104,4 @@ export function modes(set, normalize) { | ||
* @example | ||
* pcset.isChroma('101010101010') // => true | ||
* pcset.isChroma('101001') // => false | ||
* PcSet.isChroma("101010101010") // => true | ||
* PcSet.isChroma("101001") // => false | ||
*/ | ||
@@ -97,7 +114,7 @@ export function isChroma(set) { | ||
/** | ||
* Given a pcset (notes or chroma) return it's intervals | ||
* Given a pcset (notes or chroma) return it"s intervals | ||
* @param {String|Array} pcset - the pitch class set (notes or chroma) | ||
* @return {Array} intervals or empty array if not valid pcset | ||
* @example | ||
* pcset.intervals('1010100000000') => ["1P", "2M", "3M"] | ||
* PcSet.intervals("1010100000000") => ["1P", "2M", "3M"] | ||
*/ | ||
@@ -120,3 +137,3 @@ export function intervals(set) { | ||
* @example | ||
* pcset.isEqual(["c2", "d3"], ["c5", "d2"]) // => true | ||
* PcSet.isEqual(["c2", "d3"], ["c5", "d2"]) // => true | ||
*/ | ||
@@ -138,3 +155,3 @@ export function isEqual(s1, s2) { | ||
* @example | ||
* const inCMajor = pcset.isSubsetOf(["C", "E", "G"]) | ||
* const inCMajor = PcSet.isSubsetOf(["C", "E", "G"]) | ||
* inCMajor(["e6", "c4"]) // => true | ||
@@ -160,3 +177,3 @@ * inCMajor(["e6", "c4", "d3"]) // => false | ||
* @example | ||
* const extendsCMajor = pcset.isSupersetOf(["C", "E", "G"]) | ||
* const extendsCMajor = PcSet.isSupersetOf(["C", "E", "G"]) | ||
* extendsCMajor(["e6", "a", "c4", "g2"]) // => true | ||
@@ -180,4 +197,4 @@ * extendsCMajor(["c6", "e4", "g3"]) // => false | ||
* @example | ||
* pcset.includes(["C", "D", "E"], 'C4') // => true | ||
* pcset.includes(["C", "D", "E"], 'C#4') // => false | ||
* PcSet.includes(["C", "D", "E"], "C4") // => true | ||
* PcSet.includes(["C", "D", "E"], "C#4") // => false | ||
*/ | ||
@@ -200,4 +217,4 @@ export function includes(set, note) { | ||
* @example | ||
* pcset.filter(["C", "D", "E"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ 'c2', 'd2', 'c3', 'd3' ]) | ||
* pcset.filter(["C2"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ 'c2', 'c3' ]) | ||
* PcSet.filter(["C", "D", "E"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ "c2", "d2", "c3", "d3" ]) | ||
* PcSet.filter(["C2"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ "c2", "c3" ]) | ||
*/ | ||
@@ -204,0 +221,0 @@ export function filter(set, notes) { |
{ | ||
"name": "tonal-pcset", | ||
"version": "1.0.0-pre6", | ||
"version": "1.0.0", | ||
"description": "Create and manipulate pitch class sets", | ||
@@ -21,5 +21,5 @@ "keywords": [ | ||
"dependencies": { | ||
"tonal-array": "^1.0.0-pre6", | ||
"tonal-interval": "^1.0.0-pre6", | ||
"tonal-note": "^1.0.0-pre6" | ||
"tonal-array": "^1.0.0", | ||
"tonal-interval": "^1.0.0", | ||
"tonal-note": "^1.0.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "babel": { |
126
README.md
@@ -1,4 +0,4 @@ | ||
<a name="module_pcset"></a> | ||
<a name="module_PcSet"></a> | ||
# pcset | ||
# PcSet | ||
[![npm version](https://img.shields.io/npm/v/tonal-pcset.svg?style=flat-square)](https://www.npmjs.com/package/tonal-pcset) | ||
@@ -15,4 +15,7 @@ [![tonal](https://img.shields.io/badge/tonal-pcset-yellow.svg?style=flat-square)](https://www.npmjs.com/browse/keyword/tonal) | ||
```js | ||
var pcset = require('tonal-pcset') | ||
pcset.isEqual('c2 d5 e6', 'c6 e3 d1') // => true | ||
// es6 | ||
import PcSet from "tonal-pcset" | ||
var PcSet = require("tonal-pcset") | ||
PcSet.isEqual("c2 d5 e6", "c6 e3 d1") // => true | ||
``` | ||
@@ -23,18 +26,19 @@ | ||
* [pcset](#module_pcset) | ||
* [`.chroma(set)`](#module_pcset.chroma) ⇒ <code>String</code> | ||
* [`.modes(set, normalize)`](#module_pcset.modes) ⇒ <code>Array.<String></code> | ||
* [`.isChroma(chroma)`](#module_pcset.isChroma) ⇒ <code>Boolean</code> | ||
* [`.intervals(pcset)`](#module_pcset.intervals) ⇒ <code>Array</code> | ||
* [`.isEqual(set1, set2)`](#module_pcset.isEqual) ⇒ <code>Boolean</code> | ||
* [`.isSubsetOf(set, notes)`](#module_pcset.isSubsetOf) ⇒ <code>boolean</code> | ||
* [`.isSupersetOf(set, notes)`](#module_pcset.isSupersetOf) ⇒ <code>boolean</code> | ||
* [`.includes(set, note)`](#module_pcset.includes) ⇒ <code>Boolean</code> | ||
* [`.filter(set, notes)`](#module_pcset.filter) ⇒ <code>Array</code> | ||
* [PcSet](#module_PcSet) | ||
* [`.chroma(set)`](#module_PcSet.chroma) ⇒ <code>String</code> | ||
* [`.chromas()`](#module_PcSet.chromas) ⇒ <code>Array</code> | ||
* [`.modes(set, normalize)`](#module_PcSet.modes) ⇒ <code>Array.<String></code> | ||
* [`.isChroma(chroma)`](#module_PcSet.isChroma) ⇒ <code>Boolean</code> | ||
* [`.intervals(pcset)`](#module_PcSet.intervals) ⇒ <code>Array</code> | ||
* [`.isEqual(set1, set2)`](#module_PcSet.isEqual) ⇒ <code>Boolean</code> | ||
* [`.isSubsetOf(set, notes)`](#module_PcSet.isSubsetOf) ⇒ <code>boolean</code> | ||
* [`.isSupersetOf(set, notes)`](#module_PcSet.isSupersetOf) ⇒ <code>boolean</code> | ||
* [`.includes(set, note)`](#module_PcSet.includes) ⇒ <code>Boolean</code> | ||
* [`.filter(set, notes)`](#module_PcSet.filter) ⇒ <code>Array</code> | ||
<a name="module_pcset.chroma"></a> | ||
<a name="module_PcSet.chroma"></a> | ||
## `pcset.chroma(set)` ⇒ <code>String</code> | ||
## `PcSet.chroma(set)` ⇒ <code>String</code> | ||
Get chroma of a pitch class set. A chroma identifies each set uniquely. | ||
It's a 12-digit binary each presenting one semitone of the octave. | ||
It"s a 12-digit binary each presenting one semitone of the octave. | ||
@@ -44,3 +48,3 @@ Note that this function accepts a chroma as parameter and return it | ||
**Kind**: static method of [<code>pcset</code>](#module_pcset) | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>String</code> - a binary representation of the pitch class set | ||
@@ -54,13 +58,21 @@ | ||
```js | ||
pcset.chroma(["C", "D", "E"]) // => '1010100000000' | ||
PcSet.chroma(["C", "D", "E"]) // => "1010100000000" | ||
``` | ||
<a name="module_pcset.modes"></a> | ||
<a name="module_PcSet.chromas"></a> | ||
## `pcset.modes(set, normalize)` ⇒ <code>Array.<String></code> | ||
## `PcSet.chromas()` ⇒ <code>Array</code> | ||
Get a list of all possible chromas (all possible scales) | ||
More information: http://allthescales.org/ | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>Array</code> - an array of possible chromas from '10000000000' to '11111111111' | ||
<a name="module_PcSet.modes"></a> | ||
## `PcSet.modes(set, normalize)` ⇒ <code>Array.<String></code> | ||
Given a a list of notes or a pcset chroma, produce the rotations | ||
of the chroma discarding the ones that starts with '0' | ||
of the chroma discarding the ones that starts with "0" | ||
This is used, for example, to get all the modes of a scale. | ||
**Kind**: static method of [<code>pcset</code>](#module_pcset) | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>Array.<String></code> - an array with all the modes of the chroma | ||
@@ -71,14 +83,14 @@ | ||
| set | <code>Array</code> \| <code>String</code> | the list of notes or pitchChr of the set | | ||
| normalize | <code>Boolean</code> | (Optional, true by default) remove all the rotations that starts with '0' | | ||
| normalize | <code>Boolean</code> | (Optional, true by default) remove all the rotations that starts with "0" | | ||
**Example** | ||
```js | ||
pcset.modes(["C", "D", "E"]).map(pcset.intervals) | ||
PcSet.modes(["C", "D", "E"]).map(PcSet.intervals) | ||
``` | ||
<a name="module_pcset.isChroma"></a> | ||
<a name="module_PcSet.isChroma"></a> | ||
## `pcset.isChroma(chroma)` ⇒ <code>Boolean</code> | ||
## `PcSet.isChroma(chroma)` ⇒ <code>Boolean</code> | ||
Test if the given string is a pitch class set chroma. | ||
**Kind**: static method of [<code>pcset</code>](#module_pcset) | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>Boolean</code> - true if its a valid pcset chroma | ||
@@ -92,11 +104,11 @@ | ||
```js | ||
pcset.isChroma('101010101010') // => true | ||
pcset.isChroma('101001') // => false | ||
PcSet.isChroma("101010101010") // => true | ||
PcSet.isChroma("101001") // => false | ||
``` | ||
<a name="module_pcset.intervals"></a> | ||
<a name="module_PcSet.intervals"></a> | ||
## `pcset.intervals(pcset)` ⇒ <code>Array</code> | ||
Given a pcset (notes or chroma) return it's intervals | ||
## `PcSet.intervals(pcset)` ⇒ <code>Array</code> | ||
Given a pcset (notes or chroma) return it"s intervals | ||
**Kind**: static method of [<code>pcset</code>](#module_pcset) | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>Array</code> - intervals or empty array if not valid pcset | ||
@@ -110,10 +122,10 @@ | ||
```js | ||
pcset.intervals('1010100000000') => ["1P", "2M", "3M"] | ||
PcSet.intervals("1010100000000") => ["1P", "2M", "3M"] | ||
``` | ||
<a name="module_pcset.isEqual"></a> | ||
<a name="module_PcSet.isEqual"></a> | ||
## `pcset.isEqual(set1, set2)` ⇒ <code>Boolean</code> | ||
## `PcSet.isEqual(set1, set2)` ⇒ <code>Boolean</code> | ||
Test if two pitch class sets are identical | ||
**Kind**: static method of [<code>pcset</code>](#module_pcset) | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>Boolean</code> - true if they are equal | ||
@@ -128,7 +140,7 @@ | ||
```js | ||
pcset.isEqual(["c2", "d3"], ["c5", "d2"]) // => true | ||
PcSet.isEqual(["c2", "d3"], ["c5", "d2"]) // => true | ||
``` | ||
<a name="module_pcset.isSubsetOf"></a> | ||
<a name="module_PcSet.isSubsetOf"></a> | ||
## `pcset.isSubsetOf(set, notes)` ⇒ <code>boolean</code> | ||
## `PcSet.isSubsetOf(set, notes)` ⇒ <code>boolean</code> | ||
Create a function that test if a collection of notes is a | ||
@@ -139,3 +151,3 @@ subset of a given set | ||
**Kind**: static method of [<code>pcset</code>](#module_pcset) | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>boolean</code> - true if notes is a subset of set, false otherwise | ||
@@ -150,13 +162,13 @@ | ||
```js | ||
const inCMajor = pcset.isSubsetOf(["C", "E", "G"]) | ||
const inCMajor = PcSet.isSubsetOf(["C", "E", "G"]) | ||
inCMajor(["e6", "c4"]) // => true | ||
inCMajor(["e6", "c4", "d3"]) // => false | ||
``` | ||
<a name="module_pcset.isSupersetOf"></a> | ||
<a name="module_PcSet.isSupersetOf"></a> | ||
## `pcset.isSupersetOf(set, notes)` ⇒ <code>boolean</code> | ||
## `PcSet.isSupersetOf(set, notes)` ⇒ <code>boolean</code> | ||
Create a function that test if a collectio of notes is a | ||
superset of a given set (it contains all notes and at least one more) | ||
**Kind**: static method of [<code>pcset</code>](#module_pcset) | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>boolean</code> - true if notes is a superset of set, false otherwise | ||
@@ -171,12 +183,12 @@ | ||
```js | ||
const extendsCMajor = pcset.isSupersetOf(["C", "E", "G"]) | ||
const extendsCMajor = PcSet.isSupersetOf(["C", "E", "G"]) | ||
extendsCMajor(["e6", "a", "c4", "g2"]) // => true | ||
extendsCMajor(["c6", "e4", "g3"]) // => false | ||
``` | ||
<a name="module_pcset.includes"></a> | ||
<a name="module_PcSet.includes"></a> | ||
## `pcset.includes(set, note)` ⇒ <code>Boolean</code> | ||
## `PcSet.includes(set, note)` ⇒ <code>Boolean</code> | ||
Test if a given pitch class set includes a note | ||
**Kind**: static method of [<code>pcset</code>](#module_pcset) | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>Boolean</code> - true if the note is included in the pcset | ||
@@ -191,11 +203,11 @@ | ||
```js | ||
pcset.includes(["C", "D", "E"], 'C4') // => true | ||
pcset.includes(["C", "D", "E"], 'C#4') // => false | ||
PcSet.includes(["C", "D", "E"], "C4") // => true | ||
PcSet.includes(["C", "D", "E"], "C#4") // => false | ||
``` | ||
<a name="module_pcset.filter"></a> | ||
<a name="module_PcSet.filter"></a> | ||
## `pcset.filter(set, notes)` ⇒ <code>Array</code> | ||
## `PcSet.filter(set, notes)` ⇒ <code>Array</code> | ||
Filter a list with a pitch class set | ||
**Kind**: static method of [<code>pcset</code>](#module_pcset) | ||
**Kind**: static method of [<code>PcSet</code>](#module_PcSet) | ||
**Returns**: <code>Array</code> - the filtered notes | ||
@@ -210,4 +222,4 @@ | ||
```js | ||
pcset.filter(["C", "D", "E"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ 'c2', 'd2', 'c3', 'd3' ]) | ||
pcset.filter(["C2"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ 'c2', 'c3' ]) | ||
PcSet.filter(["C", "D", "E"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ "c2", "d2", "c3", "d3" ]) | ||
PcSet.filter(["C2"], ["c2", "c#2", "d2", "c3", "c#3", "d3"]) // => [ "c2", "c3" ]) | ||
``` |
@@ -15,2 +15,12 @@ var pcset = require("../index"); | ||
test("chromas", () => { | ||
expect(pcset.chromas().length).toBe(2048); | ||
expect(pcset.chromas()[0]).toBe("100000000000"); | ||
expect(pcset.chromas()[2047]).toBe("111111111111"); | ||
expect(pcset.chromas(0)).toEqual([]); | ||
expect(pcset.chromas(1)).toEqual(["100000000000"]); | ||
expect(pcset.chromas(12)).toEqual(["111111111111"]); | ||
expect(pcset.chromas(2).length).toEqual(11); | ||
}); | ||
test("intervals", () => { | ||
@@ -17,0 +27,0 @@ expect(pcset.intervals("101010101010")).toEqual($("1P 2M 3M 5d 6m 7m")); |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
132495
3090
1
213
Updatedtonal-array@^1.0.0
Updatedtonal-interval@^1.0.0
Updatedtonal-note@^1.0.0