New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tonal-pcset

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tonal-pcset

Pitch class sets

  • 0.69.9
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

pcset

npm version tonal

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

API documentation

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

ParamTypeDescription
setArray | Stringthe 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

ParamTypeDescription
notesString | Arraythe 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

ParamTypeDescription
setArray | Stringthe list of notes or pitchChr of the set
normalizeBoolean(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

ParamTypeDescription
chromaStringthe 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

ParamTypeDescription
pcsetString | Arraythe 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)

ParamTypeDescription
binaryStringthe pitch class set in binary representation
tonicString | Pitchthe 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

ParamTypeDescription
set1Array | Stringone of the pitch class sets
set2Array | Stringthe 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

ParamTypeDescription
setArray | Stringthe base set to test against
testArray | Stringthe 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

ParamTypeDescription
setArray | Stringthe base set to test against
testArray | Stringthe 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

ParamTypeDescription
setArray | Stringthe base set to test against
noteString | Pitchthe 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

ParamTypeDescription
setArray | Stringthe pitch class set notes
notesArray | Stringthe 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' ])

Keywords

FAQs

Package last updated on 06 Aug 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc