Skip to content

Latest commit

 

History

History
71 lines (48 loc) · 4.83 KB

chord.md

File metadata and controls

71 lines (48 loc) · 4.83 KB

Sharp11 Chord Module

require('sharp11').chord

Contains a Chord object, which can be created with chord.create(). Methods of the Chord object do not mutate it, they return a new object.

Exported Functions

create .create(chord, octave)

Returns a Chord object given a string and an optional octave number. The chord argument should contain the root of the chord, an optional symbol (defaults to major triad), and an optional bass note given in slash notation. Sharp11 supports a wide variety of chord symbols, so anything you'd find in a jazz fake book should be valid here.

identify .identify(notes...)

Returns the chord name as a string given an argument list of Note objects or strings, ignoring octave numbers. Inversions are supported, so chord.identify('B', 'C', 'Eb', 'G') returns "CmM7/B".

identifyArray .identifyArray([notes])

Invokes .identify() with the contents of [notes] as its arguments.

getPossibleChordNames .getPossibleChordNames(notes...)

Returns a list of chord names given an argument list of Note objects or strings, ignoring octave numbers. Similar to .identify(notes...), but returns all possible matches. Matches are sorted by how "reasonable" they are, with reasonable ones coming first in the list.

getPossibleChordNamesFromArray .getPossibleChordNamesFromArray([notes])

Invokes .getPossibleChordNames() with the contents of [notes] as its arguments.

isChord .isChord(obj)

Returns true if an object is a Chord.

Chord Object

Chord objects consist of a root, a chord symbol, and an optional bass (meaning the lowest note in the chord is not the root). The chord symbol is parsed, producing an array of notes that make up the chord. A Chord object can have an optional octave number, which is applied to the notes of the chord, starting with the first note and increasing accordingly. For example, the notes in a C13 in octave 4 are C4, E4, G4, Bb4, D5, F5, A5. The Chord constructor is accessible directly as .Chord, however new instances should be created using .create() instead.

name .name

The chord name, given by the chord argument in chord.create().

root .root

A Note object representing the root of the chord.

symbol .symbol

A string containing the symbol of the chord (no root or bass).

formattedSymbol .formattedSymbol

A string containing the symbol of the chord (no root or bass) with aliases replaced, e.g. '-' becomes 'm'.

bass .bass

A Note object representing the bass of the chord.

chord .chord

An array of Note objects representing the notes in the chord, with optional octave numbers.

octave .octave

The (optional) octave number of the chord, i.e., an integer between 0 and 9, or null.

scales .scales()

Returns an array of scale objects representing scales that could be played over the chord. A scale can be played over a chord if every note contained in the chord is contained in the scale (with a few optimizations). The returned array of scales is ordered based on a pre-defined "precedence" array, which orders scales based on how commonly used they are.

scale .scale()

Returns the first element of the array returned by .scales().

scaleNames .scaleNames()

Returns the names of the scales returned by .scales().

transpose .transpose(interval, down)

Transposes the chord, applying note.transpose().

transposeDown .transposeDown(interval)

Calls .transpose(interval, true).

clean .clean()

Applies note.clean() to the root, bass, and every note in the chord.

contains .contains(note)

Returns true if the given note is in the chord, following the rules of note.containedIn().

inOctave .inOctave(octave)

Assigns the chord the given octave number.