tonic library

Classes

Chord
A Chord is a set of pitches. It can also be considered as a root, and a set of intervals.
ChordPattern
An instance of ChordPattern represents the intervals of the chord, without the root; for example, Dom7. A ChordPattern represents the quality, suspensions, and additions.
FretPosition
A FretPosition represents the a fret on a specific string of a fretted instrument.
FrettedInstrument
A fretted instrument. Instances of this are used to compute chord frettings.
Fretting
A Fretting is a map of fingers to sets of frets, that voice a chord on a fretted instrument.
Instrument
A musical instrument. This is the superclass for FrettedInstrument, and is used as a factory/dictionary of instruments.
Interval
An Interval is the signed distance between two notes. Intervals that represent the same semitone span and accidental are interned. Thus, two instance of M3 are ===, but sharp P4 and flat P5 are distinct from each other and from TT.
Mode
Pitch
A musical pitch, represented as a pair of the number of diatonic semitones C, and the number of accidental semitones above this diatonic value.
PitchClass
A pitch class represents a set of pitches separated by an integral number of octaves. For example, C is a single pitch class.
Scale
A scale is a set of musical notes. Equivalently, it is a scale pattern and a tonic.
ScalePattern
A scale pattern is a named set of intervals (or scale degrees) independent of root (or tonic). For example, there is a Major scale pattern, that is realized at particular roots as C Major, D Major, etc.

Properties

accidentalValues ā†’ Map<String, int>
A map from the string representation of an accidental (ā™Æ, ā™­, š„Ŗ, š„«) to the number of half-steps that the accidental adds to a pitch.
final
flatNoteNames ā†’ List<String>
Note names (e.g. C, Dā™­), indexed by half-steps above C. Notes that require accidentals use flats (ā™­).
final
intervalNames ā†’ List<String>
The canonical abbreviated names of pitch intervals (e.g. P1, P4), indexed by their half-step counts minus one.
final
longIntervalNames ā†’ List<String>
The canonical long names of pitch intervals (e.g. Unicon, Perfect 4th), indexed by one less than their half-step counts.
final
midiNamePattern ā†’ RegExp
final
noteNames ā†’ List<String>
Note names (e.g. C, Cā™Æ), indexed by half-steps above C. This has the same value as sharpNoteNames.
final
pitchToPitchClass ā†’ int Function(int pitchClass)
final
scaleDegreeNames ā†’ List<String>
final
sharpNoteNames ā†’ List<String>
Note names (e.g. C, Cā™Æ), indexed by half-steps above C. Notes that require accidentals use sharps (ā™Æ).
final

Functions

accidentalsToString(int semitones) ā†’ String
bestFrettingFor(Chord chord, FrettedInstrument instrument) ā†’ Fretting
chordFrets(Chord chord, FrettedInstrument instrument, int highestFret) ā†’ Set<FretPosition>
chordFrettings(Chord chord, FrettedInstrument instrument, {dynamic highestFret = 4}) ā†’ List<Fretting>
diatonicFloor(int semitones) ā†’ int
eachWithIndex<T>(List<T> list, void fn(T, int)) ā†’ void
Call fn first with list[0] and 0, then with list[1] and 1, etc.
intervalClassDifference(int pca, int pcb) ā†’ int
The interval class (an integer 0 < x < 12) between two pitch class numbers.
midi2name(int number) ā†’ String
name2midi(String midiNoteName) ā†’ int
normalizePitchClass(int pitchClass) ā†’ int
parseAccidentals(String accidentals) ā†’ int
pitchClassToString(int pitch, {bool flat = false, bool sharp = false}) ā†’ String
sortedBy<T>(Iterable<T> items, int sortKey(T), {bool reverse = false}) ā†’ List
Returns a copy of `items, stably sorted by sortKey.

Exceptions / Errors

NotFoundException