Sharp11 Mehegan Module
October 12, 2017 · View on GitHub
require('sharp11').mehegan
Contains a Mehegan object, which can be created with mehegan.fromChord() or mehegan.fromString(). Methods of the Mehegan object do not mutate it, they return a new object.
Exported Functions
fromChord .fromChord(key, chord)
Given a key (string or Note object) and a chord (string or Chord object), return a Mehegan object representing the given chord in the given key. For example, mehegan.fromChord('G', 'B7') returns IIIx.
fromString .fromString(sym)
Given a string representation of a Mehegan symbol, e.g., "IIIx", return the corresponding Mehegan object. If no quality is given, the quality will be inferred diatonically.
fromChords .fromChords(key, chords)
Given a key (string or Note object) and an array of chords (string or Chord object), return an array of Mehegan objects representing each chord in the given key.
fromStrings .fromStrings(sym)
Given an array of string representations of Mehegan symbols, return an array of corresponding Mehegan objects.
asMehegan .asMehegan(obj, cache)
If the given object is a Mehegan object, return it, otherwise parse it as a Mehegan string. If an object is passed in as the optional cache parameter, it will be used to cache Mehegan objects created for corresponding Mehegan strings. That means that if .asMehegan() is called twice with the same string, the results will point to the same cached Mehegan object. The purpose of allowing an optional cache is to increase performance for .asMehegan and functions that invoke it such as Mehegan.eq().
asMeheganArray .asMeheganArray(arr, cache)
Returns an array resulting from invoking .asMehegan with each element and the optional cache.
Mehegan Object
The Mehegan object represents a Mehegan symbol, i.e., a roman numeral representation of a jazz chord based on John Mehegan's Sixty Chord System (extended slightly by introducing a separate quality for suspended chords). Mehegan symbols have a roman numeral and a chord quality, which is one of: M (major), m (minor), x (dominant), ø (half-diminished), o (diminished), or s (suspended). Additional chord alterations are ignored when converting to Mehegan symbols. The Mehegan constructor is accessible directly as .Mehegan, however new instances should be created using .fromString() or .fromChord() instead.
numeral .numeral
The roman numeral of the Mehegan symbol, e.g., "VI".
quality .quality
The quality of the Mehegan symbol ("M", "m", "x", "ø", "o", or "s").
intveral .interval
The number of half-steps between the Mehegan symbol and I. For example, mehegan.fromString('V').interval returns 7.
equals .eq(sym, cache) or .equals(sym, cache)
Given a string or Mehegan object, return true if it has the same quality and is enharmonically equivalent. The optional cache parameter, if provided, will be passed into the .asMehegan() function.
toInterval .toInterval()
Return an Interval object corresponding to the roman numeral. For example, mehegan.fromString('bIIIx').toInterval() returns m3.
transpose .transpose(interval, down)
Transposes the Mehegan symbol by an interval (string or Interval object). The interval will be transposed up unless down is truthy.
transposeDown .transposeDown(interval)
Calls .transpose(interval, true).
withQuality .withQuality(quality)
Returns a Mehegan symbol with the same numeral and the given quality.
toChord .toChord(key)
Returns a Chord object that corresponds to the Mehegan symbol in a given key (string or Note object).
toStylized .toStylized()
Returns a string representation of the Mehegan symbol where case-sensitive roman numerals are used and qualities are omitted for diatonic chords.