Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
tonal-scale
Advanced tools
A scale is a collection of pitches in ascending or descending order.
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", ...]
.props(name)
⇒ Object
.names(aliases)
⇒ Array
.intervals(name)
⇒ Array.<String>
.notes(tonic, nameOrTonic, [name])
⇒ Array
.exists(name)
⇒ Boolean
.tokenize(name)
⇒ Array
.modeNames(name)
.chords(name)
.toScale(notes)
⇒ Array
.supersets(name)
⇒ Array
.subsets(name)
⇒ Array
Scale.props(name)
⇒ Object
Get scale properties. It returns an object with:
Kind: static method of Scale
Param | Type | Description |
---|---|---|
name | String | the scale name (without tonic) |
Scale.names(aliases)
⇒ Array
Return the available scale names
Kind: static method of Scale
Returns: Array
- the scale names
Param | Type | Description |
---|---|---|
aliases | boolean | true to include aliases |
Example
Scale.names() // => ["maj7", ...]
Scale.intervals(name)
⇒ Array.<String>
Given a scale name, return its intervals. The name can be the type and optionally the tonic (which is ignored)
It retruns an empty array when no scale found
Kind: static method of Scale
Returns: Array.<String>
- the scale intervals if is a known scale or an empty
array if no scale found
Param | Type | Description |
---|---|---|
name | String | the scale name (tonic and type, tonic is optional) |
Example
Scale.intervals("major") // => [ "1P", "2M", "3M", "4P", "5P", "6M", "7M" ]
Scale.notes(tonic, nameOrTonic, [name])
⇒ Array
Get the notes (pitch classes) of a scale.
Note that it always returns an array, and the values are only pitch classes.
Kind: static method of Scale
Returns: Array
- a pitch classes array
Param | Type | Description |
---|---|---|
tonic | String | |
nameOrTonic | String | the scale name or tonic (if 2nd param) |
[name] | String | the scale name without tonic |
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.exists(name)
⇒ Boolean
Check if the given name is a known scale from the scales dictionary
Kind: static method of Scale
Param | Type | Description |
---|---|---|
name | String | the scale name |
Scale.tokenize(name)
⇒ Array
Given a string with a scale name and (optionally) a tonic, split that components.
It retuns an array with the form [ name, tonic ] where tonic can be a note name or null and name can be any arbitrary string (this function doesn"t check if that scale name exists)
Kind: static method of Scale
Returns: Array
- an array [tonic, name]
Param | Type | Description |
---|---|---|
name | String | the scale name |
Example
Scale.tokenize("C mixolydean") // => ["C", "mixolydean"]
Scale.tokenize("anything is valid") // => ["", "anything is valid"]
Scale.tokenize() // => ["", ""]
Scale.modeNames(name)
Find mode names of a scale
Kind: static method of Scale
Param | Type | Description |
---|---|---|
name | String | scale name |
Scale.chords(name)
Get all chords that fits a given scale
Kind: static method of Scale
Param | Type |
---|---|
name | String |
Scale.toScale(notes)
⇒ Array
Given an array of notes, return the scale: a pitch class set starting from the first note of the array
Kind: static method of Scale
Param | Type |
---|---|
notes | Array |
Scale.supersets(name)
⇒ Array
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 Scale
Returns: Array
- a list of scale names
Param | Type |
---|---|
name | String |
Scale.subsets(name)
⇒ Array
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 Scale
Returns: Array
- a list of scale names
Param | Type |
---|---|
name | String |
FAQs
Music scales creation and manipulation
The npm package tonal-scale receives a total of 844 weekly downloads. As such, tonal-scale popularity was classified as not popular.
We found that tonal-scale 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
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.