- Accidental
- Alteration
- Constants
- EnumerableExtensions
- Generic
- IntExtensions
- Interval
- #ctor(genericWidth,specificWidth)
- Abbreviation
- Description
- GenericWidth
- SpecificWidth
- Between(bottom,top)
- Between(bottom,top)
- Between(bottom,top)
- Enharmonic(other)
- Equals(other)
- GenericName()
- GetHashCode()
- Parse(input)
- ParseFormal()
- ParseSimple()
- ReducedGenericWidth()
- ToString()
- op_Addition()
- op_Subtraction()
- Mode
- Name
- Note
- ParseHelpers
- Pitch
- Program
- Quality
- Voicing
Cadd9.Model
Represents an accidental that shifts some note or pitch by a certain number of semitones away from natural.
Returns a new Accidental
Name | Type | Description |
---|---|---|
semitones | System.Int32 | The number of semitones this accidental shifts a pitch or note |
A formatted representation of this Accidental as a UTF-8 string.
The number of semitones this accidental shifts a pitch or note. Positive values indicate sharps, negative values indicate flats.
Returns true if other
is enharmonic with this Accidental.
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Accidental | The Accidental to compare with |
Two accidentals are enharmonic if they are equal or if their Semitones
differ by an even multiple of
12. For example 5 sharps is enharmonic with 7 flats: C♯♯♯♯♯ and C♭♭♭♭♭♭♭ are both enharmonic with each
other and with F natural.
Determines whether two Accidentals are value-equivalent
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Accidental | The Accidental to compare |
Produces a high-entropy hash code such that two value-equivalent Accidentals are guaranteed to produce the same result.
This method has no parameters.
Returns a new Accidental based on the given input string.
Name | Type | Description |
---|---|---|
input | System.String | The plain ASCII input string to parse |
Name | Description |
---|---|
System.FormatException | The given input cannot be parsed |
Assumes the input will be in plain ASCII: "b" for flats and "#" for sharps. An empty string or the string
"nat"
may be used for natural.
Returns a string representation of this Accidental, primarily for debugging purposes.
This method has no parameters.
Cadd9.Model.Quality
Encapsulates an alteration of a chord quality, by dropping, adding, or replacing some intervals.
Returns a new Alteration
This constructor has no parameters.
The interval that is added as part of this modification, or null if nothing is added.
The generic interval to be removed by this modification, or null if nothing is removed.
Cadd9.Model
Defines several frequently-used music theory constants.
The MIDI note number corresponding to middle C
This is not a universal definition. In fact as far as the MIDI standard is concerned, the note numbers are not strictly related to any musical pitches. They are simply a set of 127 sequential numbers that can be turned on and off with control messages. But 60 is used by most device manufacturers.
The octave number of middle C
There is no universal definition: middle C is also sometimes labeled as C3.
The number of note names per octave
Western tonal music is built around the diatonic scale, which is a heptatonic scale (containing seven tones) arranged so there are 2 half-steps (single semitone) and 5 whole-steps (two semitones) separating each. The arrangement of steps and half-steps determines the Mode of the scale.
The number of semitones per octave
In Western tonal music using equal temperament, an octave is a doubling of frequency, and it is further subdivided into 12 semitones where each is in a 2^(1/12):1 ratio with the one before it.
Cadd9.Util
Adds useful extension methods to IEnumerable`1
Returns the first element in the input and every Nth afterward.
This method has no parameters.
This example demonstrates how to use EveryN``1 to take every Nth element of a range.
var result = Enumerable.Range(1, 10).EveryN(3);
foreach (var num in result)
{
Console.WriteLine(num);
}
// This produces: 1, 4, 7, 10
Cadd9.Model.Interval
Represents a generic interval between two notes or pitches independent of semitone width
For instance, the generic interval between any F and any A is always a third. From F to A♯ is an augmented third (5 semitones), and from F to A♭ is a minor third (3 semitones) but the generic interval is always a third. In other words, this is the number of note names shifted from the bottom to top of the interval.
Cadd9.Util
Adds extension methods for some useful integer math
Returns the integer congruent to operand (mod modulus) with smallest absolute value.
This method has no parameters.
The range of this method is [-modulus/2, modulus/2)
-- basically the goal is
to return an integer that is modulo-congruent with operand but is as close as
possible to zero. Primarily this is used to simplify accidentals as much as
possible: if we have 11 sharps, a more ideal (and enharmonic) accidental would be
one flat, represented as -1 and congruent to 11 (mod 12).
Returns the value of operand
mod modulus
This method has no parameters.
Formally this method returns the least non-negative integer N
such that
operand ≡ N (mod modulus)
. It differs from C#'s %
operator in its
treatment of negative values: -1 % 7 == -1
while -1.Modulus(7) == 6
.
Returns a string representation of an integer in ordinal form
This method has no parameters.
Cadd9.Model
Represents a musical width between notes or pitches.
Creates an Interval with the given generic and specific widths.
Name | Type | Description |
---|---|---|
genericWidth | Cadd9.Model.Interval.Generic | The number of note names spanned by the interval |
specificWidth | System.Int32 | The number of semitones spanned by the interval |
A short formatted description of the interval, like "P4"
A long-form formatted description of the interval, like "Perfect Fourth"
The generic width of this Interval, in other words, the difference in note names from bottom to top.
The specific width of this Interval, in other words, the semitones shifted between the bottom and top.
Returns a new Interval representing the width between two Names.
Name | Type | Description |
---|---|---|
bottom | Cadd9.Model.Name | The lower Name to compare |
top | Cadd9.Model.Name | The higher Name to compare |
It is always assumed that the interval is going up from first to second: C to B would give an interval of a major seventh (despite being much closer to go down a minor second). Also for this reason, this method will always produce an interval between unison (inclusive) and an octave (exclusive).
Returns a new Interval representing the width between two Notes.
Name | Type | Description |
---|---|---|
bottom | Cadd9.Model.Note | The lower Note to compare |
top | Cadd9.Model.Note | The higher Note to compare |
It is always assumed that the interval is going up from first to second: C♯ to B would give an interval of a minor seventh (despite being much closer to go down a major second). Also for this reason, this method will always produce an interval between unison (inclusive) and an octave (exclusive).
Returns a new Interval representing the width between two Pitches.
Name | Type | Description |
---|---|---|
bottom | Cadd9.Model.Pitch | The lower Pitch to compare |
top | Cadd9.Model.Pitch | The higher Pitch to compare |
It is always assumed that the interval is going up from first to second: C♯3 to B4 would give an interval of a minor fifteenth.
Returns true if other
is enharmonically equivalent to this interval.
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Interval | The other Interval to compare |
Two intervals are enharmonic if they have the same specific width. Perfect unison and diminished second, for example, are enharmonic despite having different generic widths.
Determines whether two Intervals are value-equivalent
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Interval | The Intervals to compare |
Returns the name of the given generic width
This method has no parameters.
Produces a high-entropy hash code such that two value-equivalent Intervals are guaranteed to produce the same result.
This method has no parameters.
Returns a new Interval by parsing the given string input.
Name | Type | Description |
---|---|---|
input | System.String | The input to parse |
Name | Description |
---|---|
System.FormatException | The given input cannot be parsed |
System.ArgumentException | If an illegal modifier is supplied for the interval |
Two formats are accepted: Formal, like P4
and d3
, or simple, like b5
and #9
. If
the simple form is used, then the major/perfect matching interval is sharped the given number of times. The
formal form understands (P)erfect, (d)iminished, (m)inor, (M)ajor, and (A)ugmented descriptors for each
interval as appropriate.
Parses the given input using "formal" notation, or null if it cannot be parsed accordingly
This method has no parameters.
Name | Description |
---|---|
System.ArgumentException | If an illegal modifier is supplied for the interval |
"Formal" notation indicates "P4" for a perfect fourth, "m3" for a minor third, etc.
Parses the given input using "simple" notation, or returns null if it cannot be parsed accordingly
This method has no parameters.
This notation uses "3" for a major third, "b5" for a flat fifth, etc. Commonly used to describe the component intervals of chords.
Returns the generic width from unison to seventh that is enharmonic with the given generic width
This method has no parameters.
A string representation of this Interval, useful for debugging.
This method has no parameters.
Creates a new compound Interval by combining two others.
This method has no parameters.
For example, adding together a perfect octave and a perfect fifth produces a perfect thirteenth.
Creates a new compound Interval by subtracting one from the other.
This method has no parameters.
For example, subtracting a minor second from a perfect octave produces a major seventh.
Cadd9.Model
Represents a musical mode based on its component intervals.
Returns a new Mode
Name | Type | Description |
---|---|---|
title | System.String | The title of this Mode |
intervals | Cadd9.Model.Interval[] | The intervals that make up this Mode |
Name | Description |
---|---|
System.ArgumentException | Thrown if a generic interval appears multiple times |
Returns a new Mode
Name | Type | Description |
---|---|---|
title | System.String | The title of this Mode |
intervals | System.String[] | String representations of the intervals that make up this Mode |
Name | Description |
---|---|
System.ArgumentException | Thrown if the given intervals do not feature every generic interval 0-6 exactly once |
The intervals given in this constructor will be parsed according to the behavior in Parse which allows short-hand construction.
A set of all the Intervals that make up this Mode
A descriptive title of this Mode
Yields the Accidental associated with a given name for a given key.
This method has no parameters.
This may be used, for example, to place sharps and flats on a staff given a particular key. In the D major (Ionian) key, F and C have a sharp accidental while all other names are natural. This may also be used to determine how to render a note: if its accidental is the same as the accidental for its name in the key, no symbol need be added.
Yields every Interval in this mode starting from unison.
This method has no parameters.
Will progress infinitely, so take only what is needed.
Returns a chord based on stacked thirds from the given scale degree of this mode.
Name | Type | Description |
---|---|---|
degree | Cadd9.Model.Degree | The scale degree to use as the root |
count | System.Int32 | The number of notes to return (3 = triad, 4 = 7th, 5 = 9th, etc) (min 3) |
Name | Description |
---|---|
System.ArgumentException | If degree or width are out of bounds |
Each mode has 7 scale degrees that produce 7 signature chord qualities. For example, the major (Ionian) mode's fourth scale degree (iv) is a minor triad, while the Phrygian mode's fifth scale degree (v°) is a diminished triad.
Important note: the value of degree
is treated starting at zero.
Determines whether two Modes are value-equivalent.
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Mode | The other Mode to compare |
Produces a high-entropy hash code such that two value-equivalent Modes are guaranteed to produce the same result.
This method has no parameters.
Yields every Note in this mode starting from the given tonic.
This method has no parameters.
Will progress infinitely, so take only what is needed.
Yields every Pitch in this mode starting from the given tonic.
This method has no parameters.
Will progress infinitely, so take only what is needed.
A string representation of this Mode, useful for debugging.
This method has no parameters.
Cadd9.Model
An enumeration of the seven note Names used in Western tonal music.
Cadd9.Model
Represents a note Name with an associated modifying Accidental.
Returns a new Note
Name | Type | Description |
---|---|---|
name | Cadd9.Model.Name | The Name associated with this Note |
accidental | Cadd9.Model.Accidental | The Accidental modifying this Note |
The Accidental modifying this Note
A formatted representation of this Note as a UTF-8 string.
The Name associated with this Note
The pitch class (0 to 11) of this Note.
The concept of pitch class is often used in post-tonal music to describe pitches without being based in any given heptatonic scale. C is equivalent to a pitch class of 0, and each pitch class going up is separated by a semitone. All Notes that are enharmonic by definition have the same pitch class.
Produces a new Note by applying the given Interval.
Name | Type | Description |
---|---|---|
interval | Cadd9.Model.Interval | The width between the current Note and the new Note to be generated. |
Determines whether two Notes are enharmonically equivalent
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Note | The other Note to compare |
Two Notes are enharmonic if they map to the same key on a keyboard: for example, while D♯ and E♭ are distinct notes that play different musical roles, they are enharmonic.
Determines whether two Notes are value-equivalent
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Note | The other Note to compare |
Produces a high-entropy hash code such that two value-equivalent Notes are guaranteed to produce the same result.
This method has no parameters.
Parses the given input as a Note
Name | Type | Description |
---|---|---|
input | System.String | The input to parse |
Name | Description |
---|---|
System.FormatException | The given input cannot be parsed |
The input is treated as case-insensitive. The first character is parsed as a Name while the rest is parsed according to Parse. Examples of valid Notes would include "B", "Ebb", "c#"
Returns a string representation of this Note, primarily for debugging purposes.
This method has no parameters.
Cadd9.Util
Contains helper methods to parse notes, pitches, and intervals
Parses the given input as a Note
This method has no parameters.
Parses the given input as a Pitch
This method has no parameters.
Parses the given input as an Interval
This method has no parameters.
The letter W (for Width) is used instead of I to prevent collision with I when both are statically included in the same file.
Cadd9.Model
A particular musical pitch achieved by playing a Note in a particular octave
Returns a new Pitch
Name | Type | Description |
---|---|---|
note | Cadd9.Model.Note | The Note to represent this Pitch |
octave | System.Int32 | The octave corresponding to this Pitch |
Returns a new Pitch
Name | Type | Description |
---|---|---|
name | Cadd9.Model.Name | The Name of this Pitch's Note |
accidental | Cadd9.Model.Accidental | The Accidental of this Pitch's Note |
octave | System.Int32 | The octave corresponding to this Pitch |
A formatted representation of this Pitch as a UTF-8 string.
The MIDI note number associated with this Pitch
Though there is no universal standard for what octave represents middle-C, we treat C-4 as middle C, with the MIDI note number 60.
The Note represented by this Pitch
The octave corresponding to this Pitch, where middle C = C4
Produces a new (higher) Pitch by applying the given Interval.
Name | Type | Description |
---|---|---|
interval | Cadd9.Model.Interval | The Interval between this and the new Pitch |
The Note Name will be incremented by interval.Generic
, while the pitch will be
incremented by interval.Specific
(in semitones). The new Accidental will be set as
appropriate to achieve this pitch.
A formatted representation of this Pitch as a UTF-8 string in the given key.
Name | Type | Description |
---|---|---|
key | Cadd9.Model.Note | The tonic of the key |
signature | Cadd9.Model.Mode | The mode of the key |
This method will include a symbol for the accidental only if it is different than the associated Name in the given key. For example, C♮4 would be rendered "C4" in the key of C Ionian, but would be "C♮4" in the key of D Ionian, because in that key a C would normally be sharp. Likewise, in D Ionian the pitch F♯3 would be rendered as "F3" because F is normally sharp in that key.
Determines whether two Pitches are enharmonically equivalent
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Pitch | The other Pitch to compare |
Two Pitches are enharmonic if they map to the same key on a keyboard: for example, while D♯4 and E♭4 are distinct notes that play different musical roles, they are enharmonic.
Determines whether two Pitches are value-equivalent
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Pitch | The other Pitch to compare |
Produces a high-entropy hash code such that two value-equivalent Pitches are guaranteed to produce the same result.
This method has no parameters.
Returns a new Note transposed into the given octave.
Name | Type | Description |
---|---|---|
octave | System.Int32 | The octave of the desired note. |
Parses the given input as a Pitch
Name | Type | Description |
---|---|---|
input | System.String | The input to parse |
Name | Description |
---|---|
System.FormatException | The given input cannot be parsed |
The input is treated as case-insensitive. The first character is parsed as a Name and the rest is broken into an accidental part and an octave. The accidental is parsed according to Parse. Examples of valid Pitches would include "B2", "Ebb17", "c#-1"
Returns a string representation of this Pitch, primarily for debugging purposes.
This method has no parameters.
Returns a new Note transposed by the given number of octaves.
Name | Type | Description |
---|---|---|
octaves | System.Int32 | The number of octaves to transpose. |
If octaves
is positive, the pitch will increase. If negative, it will decrease.
Empty program class
Exists only to allow the library to compile successfully. For some reason, netcoreapp2.2 class libraries still require a class with a Main method.
Empty main method
This method has no parameters.
Cadd9.Model
Represents a particular chord quality that may be applied with any given root
Returns a new Quality
Name | Type | Description |
---|---|---|
intervals | Cadd9.Model.Interval[] | The set of Intervals that define this chord quality |
Name | Description |
---|---|
System.ArgumentException | Thrown if a generic interval appears multiple times |
Returns a new Quality
Name | Type | Description |
---|---|---|
intervals | System.String[] | String representations of the Intervals for this chord quality |
Name | Description |
---|---|
System.ArgumentException | Thrown if a generic interval appears multiple times |
The intervals given in this constructor will be parsed according to the behavior in Parse which allows short-hand construction.
The set of Intervals that define this chord quality
Returns a new Quality by adding the given Interval
Name | Type | Description |
---|---|---|
add | Cadd9.Model.Interval | The Interval to add |
This can be used to create a chord with arbitrary extensions, like 9th, 13th, etc.
Returns a new Quality by applying the given Alteration.
Name | Type | Description |
---|---|---|
alt | Cadd9.Model.Quality.Alteration | The Alteration to apply |
This is generally used to modify the 3rd or 5th of the quality, like creating a sus2 or a flat-5 chord.
Returns a sequence of Notes by applying all of this Quality's Intervals to the given root.
This method has no parameters.
Returns a sequence of Pitches by applying all of this Quality's Intervals to the given root.
This method has no parameters.
Determines whether two Qualities are value-equivalent
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Quality | The other Quality to compare |
Produces a high-entropy hash code such that two value-equivalent Qualities are guaranteed to produce the same result.
This method has no parameters.
A string representation of this Mode, useful for debugging.
This method has no parameters.
Cadd9.Model
Determines whether two Voicings are value-equivalent
Name | Type | Description |
---|---|---|
other | Cadd9.Model.Voicing | The other Voicings to compare |
Produces a high-entropy hash code such that two value-equivalent Qualities are guaranteed to produce the same result.
This method has no parameters.