Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@tonaljs/chord
Advanced tools
ES6:
import { Chord } from "tonal";
Nodejs:
const { Chord } = require("tonal");
Chord.getChord(type: string, tonic?: string, root?: string) => Chord
Chord.get(name: string | [string, string] | [string, string, string]) => Chord
Given a chord symbol or tokens, it returns the chord properties.
Chord properties is the the same object that ChordType.get
but with additional fields:
Cmaj7
, Db7b5/F
. The symbol always uses pitch classes (note names without octaves) for both the tonic and root.Example:
Chord.get("Cmaj7/B"); // =>
// {
// empty: false,
// name: 'C major seventh over B',
// setNum: 2193,
// chroma: '100010010001',
// normalized: '100010010001',
// intervals: [ '7M', '8P', '10M', '12P' ],
// quality: 'Major',
// aliases: [ 'maj7', 'Δ', 'ma7', 'M7', 'Maj7', '^7' ],
// symbol: 'Cmaj7/B',
// tonic: 'C',
// type: 'major seventh',
// root: 'B',
// bass: 'B',
// rootDegree: 4,
// notes: [ 'B', 'C', 'E', 'G' ]
// }
Chord.chord
is an alias that is handy if using the @tonaljs/chord
directly:
import { chord } from "@tonaljs/chord";
chord("C6add2");
Chord.getChord(chordType, tonic, bass)
is very similar but with arguments for each chord part:
Chord.getChord("maj7", "C", "B") === Chord.get("Cmaj7/B");
Chord.notes(chordType: string, tonic?: string) => string[]
Print the notes of the given chord at the given tonic:
Chord.notes("maj7", "C4"); // => ["C4", "E4", "G4", "B4"]
Chord.degrees(chordType: string, tonic?: string) => (degree: number) => string
Scale.degrees
returns a function to get a note name from a scale degree:
const c4m7 = Chord.degrees("m7", "C4");
c4m7(1); // => "C4"
c4m7(2); // => "Eb4"
c4m7(3); // => "G4"
c4m7(4); // => "Bb4"
c4m7(1); // => "C5"
It can be used, for example, to get the notes of chord inversions:
[1, 2, 3, 4].map(c4m7); // => ["C4", "Eb4", "G4", "Bb4"]
[2, 3, 4, 5].map(c4m7); // => ["Eb4", "G4", "Bb4", "C5"]
[3, 4, 5, 6].map(c4m7); // => ["G4", "Bb4", "C5", "Eb5"]
[4, 5, 6, 7].map(c4m7); // => ["Bb4", "C5", "Eb5", "G5"]
Bear in mind that degree numbers starts with 1 and 0 returns an empty string:
c4m7(0); // => ""
See Scale.degrees
Chord.steps(chordName: string) => (degree: number) => string
Same as Chord.degrees
but 0 is the tonic. Plays better with numeric ranges:
import { Range, Chord } from "tonal";
Range.numeric([-3, 3]).map(Chord.steps(["C4", "aug"]));
// => ["G#3", "E3", "C3", "C4", "E4", "G#4", "C5"]
Chord.detect(notes: string[]) => string[]
Given a list of notes, get the possible chord names:
Chord.detect(["D", "F#", "A", "C"]); // => ["D7"]
Chord.detect(["F#", "A", "C", "D"]); // => ["D7/F#"]
Read more at chord-detect
Chord.transpose(chordName: string, intervalName: string) => string
Transpose a chord symbol by an interval:
Chord.transpose("Eb7b9", "5P"); // => "Bb7b9"
Chord.chordScales(chordName: string) => string[]
Get all scales where the given chord fits:
Chord.chordScales("C7b9");
// => ["phrygian dominant", "flamenco", "spanish heptatonic", "half-whole diminished", "chromatic"]
Chord.extended(chord: string) => string[]
Get all chords names that are a superset of the given one (has the same notes and at least one more)
Chord.extended("Cmaj7");
// => [ 'Cmaj#4', 'Cmaj7#9#11', 'Cmaj9', 'CM7add13', 'Cmaj13', 'Cmaj9#11', 'CM13#11', 'CM7b9' ]
Chord.reduced(chord: string) => string[]
Find all chords names that are a subset of the given one (less notes but all from the given chord)
Chord.reduced("Cmaj7"); // => ["C5", "CM"]
FAQs
Musical chords and its relations
The npm package @tonaljs/chord receives a total of 1,199 weekly downloads. As such, @tonaljs/chord popularity was classified as popular.
We found that @tonaljs/chord demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
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.