Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
tonal-pcset
Advanced tools
tonal-pcset
is a collection of functions to work with pitch class sets, oriented
to make comparations (isEqual, isSubset, isSuperset)
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-pcset
var pcset = require('tonal-pcset')
pcset.isEqual('c2 d5 e6', 'c6 e3 d1') // => true
.chroma(set)
⇒ String
.notes(notes)
⇒ Array
.modes(set, normalize)
⇒ Array.<String>
.chromaModes()
.isChroma(chroma)
⇒ Boolean
.intervals(pcset)
⇒ Array
.fromChroma(binary, tonic)
⇒ Array
.isEqual(set1, set2)
⇒ Boolean
.isSubset(set, test)
⇒ Boolean
.isSuperset(set, test)
⇒ Boolean
.includes(set, note)
⇒ Boolean
.filter(set, notes)
⇒ Array
pcset.chroma(set)
⇒ String
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.
Note that this function accepts a chroma as parameter and return it without modification.
Kind: static method of pcset
Returns: String
- a binary representation of the pitch class set
Param | Type | Description |
---|---|---|
set | Array | String | the pitch class set |
Example
pcset.chroma('C D E') // => '1010100000000'
pcset.notes(notes)
⇒ Array
Deprecated
Kind: static method of pcset
Returns: Array
- an array of pitch class sets
See: collection.pcset
Given a list of notes, return the pitch class names of the set
starting with the first note of the list
Param | Type | Description |
---|---|---|
notes | String | Array | the pitch class set notes |
pcset.modes(set, normalize)
⇒ Array.<String>
Given a a list of notes or a pcset chroma, produce the rotations 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 pcset
Returns: Array.<String>
- an array with all the modes of the chroma
Param | Type | Description |
---|---|---|
set | Array | String | the list of notes or pitchChr of the set |
normalize | Boolean | (Optional, true by default) remove all the rotations that starts with '0' |
Example
pcset.modes('C E G')
pcset.chromaModes()
Deprecated
Kind: static method of pcset
See: modes
pcset.isChroma(chroma)
⇒ Boolean
Test if the given string is a pitch class set chroma.
Kind: static method of pcset
Returns: Boolean
- true if its a valid pcset chroma
Param | Type | Description |
---|---|---|
chroma | String | the pitch class set chroma |
Example
pcset.isChroma('101010101010') // => true
pcset.isChroma('101001') // => false
pcset.intervals(pcset)
⇒ Array
Given a pcset (notes or chroma) return it's intervals
Kind: static method of pcset
Returns: Array
- intervals or empty array if not valid pcset
Param | Type | Description |
---|---|---|
pcset | String | Array | the pitch class set (notes or chroma) |
Example
pcset.intervals('1010100000000') => ['C', 'D', 'E']
pcset.fromChroma(binary, tonic)
⇒ Array
Deprecated
Kind: static method of pcset
Returns: Array
- a list of notes or intervals
See: intervals
Given a pitch class set in binary notation it returns the intervals or notes
(depending on the tonic)
Param | Type | Description |
---|---|---|
binary | String | the pitch class set in binary representation |
tonic | String | Pitch | the pitch class set tonic |
Example
pcset.fromChroma('101010101010', 'C') // => ['C', 'D', 'E', 'Gb', 'Ab', 'Bb']
pcset.isEqual(set1, set2)
⇒ Boolean
Test if two pitch class sets are identical
Kind: static method of pcset
Returns: Boolean
- true if they are equal
Param | Type | Description |
---|---|---|
set1 | Array | String | one of the pitch class sets |
set2 | Array | String | the other pitch class set |
Example
pcset.isEqual('c2 d3', 'c5 d2') // => true
pcset.isSubset(set, test)
⇒ Boolean
Test if a pitch class set is a subset of another
Kind: static method of pcset
Returns: Boolean
- true if the test set is a subset of the set
Param | Type | Description |
---|---|---|
set | Array | String | the base set to test against |
test | Array | String | the set to test |
Example
pcset.subset('c d e', 'C2 D4 D5 C6') // => true
pcset.isSuperset(set, test)
⇒ Boolean
Test if a pitch class set is a superset
Kind: static method of pcset
Returns: Boolean
- true if the test set is a superset of the set
Param | Type | Description |
---|---|---|
set | Array | String | the base set to test against |
test | Array | String | the set to test |
Example
pcset.isSuperset('c d e', 'C2 D4 F4 D5 E5 C6') // => true
pcset.includes(set, note)
⇒ Boolean
Test if a given pitch class set includes a note
Kind: static method of pcset
Returns: Boolean
- true if the note is included in the pcset
Param | Type | Description |
---|---|---|
set | Array | String | the base set to test against |
note | String | Pitch | the note to test |
Example
pcset.includes('c d e', 'C4') // =A true
pcset.includes('c d e', 'C#4') // =A false
pcset.filter(set, notes)
⇒ Array
Filter a list with a pitch class set
Kind: static method of pcset
Returns: Array
- the filtered notes
Param | Type | Description |
---|---|---|
set | Array | String | the pitch class set notes |
notes | Array | String | the note list to be filtered |
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' ])
FAQs
Create and manipulate pitch class sets
We found that tonal-pcset demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.