tonal-chord
Version:
Music chords creation and manipulation
111 lines (108 loc) • 3.4 kB
TypeScript
type Chord = string;
type Interval = string;
type ChordChroma = string;
type SetNum = number;
type ChordProps = {
name: Chord;
names: Chord[];
intervals: Interval[];
chroma: ChordChroma;
setnum: number;
};
/**
* Return the available chord names
*
* @function
* @param {boolean} aliases - true to include aliases
* @return {Array} the chord names
*
* @example
* Chord.names() // => ["maj7", ...]
*/
export declare const names: () => Chord[];
/**
* Get chord properties. It returns an object with:
*
* - name: the chord name
* - names: a list with all possible names (includes the current)
* - intervals: an array with the chord intervals
* - chroma: chord croma (see pcset)
* - setnum: chord chroma number
*
* @function
* @param {string} name - the chord name (without tonic)
* @return {Object} an object with the properties or a object with all properties
* set to null if not valid chord name
*/
export declare const props: (str: string) => ChordProps;
/**
* Get chord intervals. It always returns an array
*
* @function
* @param {string} name - the chord name (optionally a tonic and type)
* @return {Array<String>} a list of intervals or null if the type is not known
*/
export declare const intervals: (name: string) => string[] | null;
/**
* Get the chord notes of a chord. This function accepts either a chord name
* (for example: "Cmaj7") or a list of notes.
*
* It always returns an array, even if the chord is not found.
*
* @function
* @param {string} nameOrTonic - name of the chord or the tonic (if the second parameter is present)
* @param {string} [name] - (Optional) name if the first parameter is the tonic
* @return {Array} an array of notes or an empty array
*
* @example
* Chord.notes("Cmaj7") // => ["C", "E", "G", "B"]
* Chord.notes("C", "maj7") // => ["C", "E", "G", "B"]
*/
export declare function notes(nameOrTonic: string, name?: string): string[];
/**
* Check if a given name correspond to a chord in the dictionary
*
* @function
* @param {string} name
* @return {Boolean}
* @example
* Chord.exists("CMaj7") // => true
* Chord.exists("Maj7") // => true
* Chord.exists("Ablah") // => false
*/
export declare const exists: (name: string) => boolean;
/**
* Get all chords names that are a superset of the given one
* (has the same notes and at least one more)
*
* @function
* @param {string} name
* @return {Array} a list of chord names
*/
export declare const supersets: (name: string) => string[];
/**
* Find all chords names that are a subset of the given one
* (has less notes but all from the given chord)
*
* @function
* @param {string} name
* @return {Array} a list of chord names
*/
export declare const subsets: (name: string) => string[];
/**
* Tokenize a chord name. It returns an array with the tonic and chord type
* If not tonic is found, all the name is considered the chord name.
*
* This function does NOT check if the chord type exists or not. It only tries
* to split the tonic and chord type.
*
* @function
* @param {string} name - the chord name
* @return {Array} an array with [type, tonic]
* @example
* Chord.tokenize("Cmaj7") // => [ "C", "maj7" ]
* Chord.tokenize("C7") // => [ "C", "7" ]
* Chord.tokenize("mMaj7") // => [ "", "mMaj7" ]
* Chord.tokenize("Cnonsense") // => [ "C", "nonsense" ]
*/
export declare function tokenize(name: string): [string, string];