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
NoteNames
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.
ScalePatternNames

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