text: Music theory for JavaScript
  Teoria.js is a lightweight and fast JavaScript library for music theory, both Jazz and Classical. It aims at providing an intuitive programming interface for music software (such as Sheet Readers, Sheet Writers, MIDI Players etc.).
  A note object (
  teoria.Note), which understands alterations, octaves,
  key number, frequency and etc. and Helmholtz notation
  A chord object (
  teoria.Chord), which understands everything
  from simple major/minor chords to advanced Jazz chords (Ab#5b9, F(#11) and such)
  A scale object (
  teoria.Scale), The scale object is a powerful presentation of
  a scale, which supports quite a few handy methods. A scale can either be
  constructed from the predefined scales, which by default contains the 7 modes
  (Ionian, Dorian, Phrygian etc.) a major and minor pentatonic and the harmonic
  chromatic scale or from an arbitrary array of intervals. The scale object
  also supports solfège, which makes it perfect for tutorials on sight-reading.
  An interval object (
  teoria.Interval), which makes it easy to find the
  interval between two notes, or find a note that is a given interval from a note.
  There's also support for counting the interval span in semitones and inverting the
  interval.
  $ npm install teoria
  Can be used with both Node and Browserify/webpack/etc.
  Include the bundled build file,
  teoria.js from this repository, directly:
  This is just a short introduction to what teoria-code looks like, for a technical library reference, look further down this document.
  // Create notes:var a4 = teoria; // Scientific notationvar g5 = teoria; // Helmholtz notationvar c3 = teorianote; // From a piano key number// Find and create notes based on intervalsteoria; // Returns a Interval object representing a minor seventhteoria; // Returns a Note representing F#5a4; // Returns a Note representing C#4a4; // Returns a Interval object representing a minor seventha4; // Returns a Interval representing a major seventh// Create scales, based on notes.a4; // Returns: ["a", "b", "c#", "d", "e", "f#", "g"]a4; // Returns: ["a", "b", "c", "d", "e", "f", "g"]g5; // Returns: ["g", "a", "b", "c", "d", "e", "f#"]g5; // Returns a Scale object// Create chords with the powerful chord parsera4name; // Returns the name of the chord: 'Asus2'c3name; // Returns 'Cm'teoria; // Returns a Chord object, representing a Ab#5b9 chordg5; // Returns a Chord object, representing a Gdim chord// Calculate note frequencies or find the note corresponding to a frequencyteorianote; // Returns: {'note':{...},'cents':3.102831} -> A4# a little out of tune.a4; // Outputs 440g5; // Outputs 783.9908719634985// teoria allows for crazy chaining:teoria // Create a note, A3// Create a lydian scale with that note as root (A lydian)// Transpose the whole scale a major second up (B lydian)// Get the third note of the scale (D#4)// Create a maj9 chord with that note as root (D#maj9); // Make a string representation: 'D#maj9'
  name - The name argument is the note name as a string. The note can both
  be expressed in scientific and Helmholtz notation.
  Some examples of valid note names:
  Eb4,
  C#,,,
  C4,
  d#'',
  Ab2
  coord - If the first argument isn't a string, but a coord array,
  it will instantiate a
  Note instance.
  duration - The duration argument is an optional
  object argument.
  The object has two also optional parameters:
  value - A
  number corresponding to the value of the duration, such that:
  1 = whole,
  2 = half (minim),
  4 = quarter,
  8 = eight
  dots - The number of dots attached to the note. Defaults to
  0.
  A static method that returns an instance of Note set to the note at the given piano key, where A0 is key number 1. See Wikipedia's piano key article for more information.
  A static method returns an object containing two elements:
  note - A
  Note which corresponds to the closest note with the given frequency
  cents - A number value of how many cents the note is out of tune
  note - A number ranging from 0-127 representing a MIDI note value
  note - The name argument is the note name as a string. The note can both
  be expressed in scientific and Helmholtz notation.
  Some examples of valid note names:
  Eb4,
  C#,,,
  C4,
  d#'',
  Ab2
  x,
  #,
  bor
  bb)
  x = 2, # = 1, b = -1, bb = -2
  whitenotes - If this parameter is set to
  true only the white keys will
  be counted when finding the key number. This is mostly for internal use.
  concertPitch - If supplied this number will be used instead of the normal concert pitch which is 440hz. This is useful for some classical music.
  This allows for easy enharmonic checking:
  teoria.note('e').chroma() === teoria.note('fb').chroma();
  The chroma number is ranging from pitch class C which is 0 to 11 which is B
  scaleName - The name of the scale to be returned.
  'minor',
  'chromatic',
  'ionian' and others are valid scale names.
  Look at the documentation for
  teoria.interval
  #intervalmethod, but changes
  thisnote, instead of returning a new
  name - The name attribute is the last part of the chord symbol.
  Examples:
  'm7',
  '#5b9',
  'major'. If the name parameter
  isn't set, a standard major chord will be returned.
  Example:
  teoria.note('A5').helmholtz() -> "a''"
  Example:
  teoria.note("ab'").scientific() -> "Ab4"
  oneAccidental - Boolean, if set to true, only enharmonic notes with one accidental is returned. E.g. results such as 'eb' and 'c#' but not 'ebb' and 'cx'
  teoria;// -> 'dbb, b#'teoria;// -> 'b#'
  scale - An instance of
  Scale, which is the context of the solfege step measuring
  showOctaves - A boolean. If set to true, a "Helmholtz-like" notation will be used if there's bigger intervals than an octave
  Examples:
  teoria.note('A', 8).durationName() -> 'eighth',
  teoria.note('C', 16).durationName() -> 'sixteenth'
  Din a C major scale will return
  2as it is the second degree of that scale. If however the note isn't a part of the scale, the degree returned will be
  0, meaning that the degree doesn't exist. This allows this method to be both a scale degree index finder and an "isNoteInScale" method.
  scale - An instance of
  Scale which is the context of the degree measuring
  dontShow - If set to
  true the octave will not be included in the returned string.
  root - A
  Note instance which is to be the root of the chord
  chord - A string containing the chord symbol. This can be anything from
  simple chords, to super-advanced jazz chords thanks to the detailed and
  robust chord parser engine. Example values:
  'm',
  'm7',
  '#5b9',
  '9sus4 and
  '#11b5#9'
  name - A string containing the full chord symbol, with note name. Examples:
  'Ab7',
  'F#(#11b5)'
  note - Instead of supplying a string containing the full chord symbol,
  one can pass a
  Note object instead. The note will be considered root in
  the new chord object
  octave - If the first argument of the function is a chord name (
  typeof "string"),
  then the second argument is an optional octave number (
  typeof "number") of the root.
  symbol - A string containing the chord symbol (excluding the note name)
  Notethat is the root of the chord.
  Notes that the chord consists of.
  Arrayof only the notes' names, not the full
  Noteobjects.
  Intervals
  voicing - An optional array of intervals in simple-format that represents the current voicing of the chord.
  Here's an example:
  var bbmaj = teoria;// Default voicing:bbmaj; // #-> ['P1', 'M3', 'P5', 'M7'];bbmaj; // #-> ['bb', 'd', 'f', 'a'];// New voicingbbmaj;bbmaj; // #-> ['bb', 'f', 'a', 'd'];
  NB: Note that above returned results are pseudo-results, as they will be
  returned wrapped in
  Interval and
  Note objects.
  'major',
  'minor',
  'augmented',
  'diminished',
  'half-diminished',
  'dominant'or
  undefined
  interval - A string name of an interval, for example
  'third',
  'fifth',
  'ninth'.
  additional - Additional chord extension, for example:
  'b9' or
  '#5'
  additional - Like the dominant's.
  additional - Like the dominant's
  'dyad',
  'triad',
  'trichord',
  'tetrad'or
  'unknown'.
  intervalaway
  #intervalmethod, except it's
  thischord that gets changed instead of returning a new chord.
  tonic - A
  Note which is to be the tonic of the scale
  scale - Can either be a name of a scale (string), or an array of absolute intervals that defines the scale. The scales supported by default are:
  Scaleobject
  Notes which is the scale's notes
  stringor
  undefined
  Notewhich is the scale's tonic
  Notes which is the scale's notes
  Arrayof only the notes' names, not the full
  Noteobjects.
  index - Can be a number referring to the scale step, or the name (string) of the scale step. E.g. 'first', 'second', 'fourth', 'seventh'.
  index Same as
  Scale#get
  showOctaves - A boolean meaning the same as
  showOctaves in
  Note#solfege
  #fromand
  #betweenmethods of the same namespace and for creating
  Intervalobjects.
  string: from)
  Interval.toCoordfunction
  Note: from,
  string: to)
  Interval.fromfunction
  Note: from,
  Interval: to)
  Intervalinstead of a string representation of the interval
  Note: from,
  Note: to)
  Interval.betweenfunction
  Intervalrepresenting the interval expressed in string form.
  from - The
  Note which is the root of the measuring
  to - A
  Interval
  from and to are two
  Notes which are the notes that the
  interval is measured from. For example if 'a' and 'c' are given, the resulting
  interval object would represent a minor third.
  Interval -> teoria
  simpleInterval - An interval represented in simple string form. Examples:
  'm' = minor,
  'M' = major,
  'A' = augmented and
  'd' = diminished
  The number may be prefixed with a
  - to signify that its direction is down. E.g.:
  m-3 means a descending minor third, and
  P-5 means a descending perfect fifth.
  'P5',
  'M3',
  'A9', etc.
  'perfect'(1, 4, 5, 8) or
  'minor'(2, 3, 6, 7)
  'dd',
  'd'
  'm',
  'P',
  'M',
  'A'or
  'AA')
  verbose is set to a truish value, then long quality names are returned:
  'doubly diminished',
  'diminished',
  'minor', etc.
  dir - If supplied, then the interval's direction is to the
  newDirection
  which is either
  'up' or
  'down'
  numberof semitones the interval span.
  ignoreDirection - An optional boolean that, if set to
  true, returns the
  "direction-agnostic" interval. That is the interval with a positive number.
  teoria; // #-> 'M3'teoria; // #-> 'm2'teoria; // #-> 'P5'teoria; // #-> 'P-4'// With ignoreDirection = trueteoria; // #->'M3'teoria; // #-> 'm3'
  NB: Note that above returned results are pseudo-results, as they will be
  returned wrapped in
  Interval objects.
  intervalto this interval, and returns a
  Intervalrepresenting the result of the addition
  intervalis equal to this interval
  intervalis greater than this interval
  intervalis smaller than this interval
  Interval