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

Create and manipulate pitch class sets

  • 2.2.2
  • latest
  • 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

// es6
import PcSet from "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.chromas()Array

Get a list of all possible chromas (all possible scales) More information: http://allthescales.org/

Kind: static method of PcSet
Returns: Array - an array of possible chromas from '10000000000' to '11111111111'

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", "D", "E"]).map(PcSet.intervals)

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") => ["1P", "2M", "3M"]

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.isSubsetOf(set, notes)boolean

Create a function that test if a collection of notes is a subset of a given set

The function can be partially applied

Kind: static method of PcSet
Returns: boolean - true if notes is a subset of set, false otherwise

ParamTypeDescription
setArray | Stringan array of notes or a chroma set string to test against
notesArray | Stringan array of notes or a chroma set

Example

const inCMajor = PcSet.isSubsetOf(["C", "E", "G"])
inCMajor(["e6", "c4"]) // => true
inCMajor(["e6", "c4", "d3"]) // => false

PcSet.isSupersetOf(set, notes)boolean

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 PcSet
Returns: boolean - true if notes is a superset of set, false otherwise

ParamTypeDescription
setArray | Stringan array of notes or a chroma set string to test against
notesArray | Stringan array of notes or a chroma set

Example

const extendsCMajor = PcSet.isSupersetOf(["C", "E", "G"])
extendsCMajor(["e6", "a", "c4", "g2"]) // => true
extendsCMajor(["c6", "e4", "g3"]) // => false

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") // => true
PcSet.includes(["C", "D", "E"], "C#4") // => 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 03 Apr 2019

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