Static
nameHolds a function which will be used for any chord that needs to recalculate what its name is.
Example:
const scale = shimi.ScaleTemplate.major.create(shimi.pitch('Eb'));
const finder = new shimi.ChordFinder().withDefaultChordLookups();
shimi.Chord.nameGenerator = (chord) => {
const result = finder.lookupChord(chord.pitches, chord.root, null, scale);
if (result == null)
return null;
return result.name
.replace('{r}', scale.getPitchName(result.root))
.replace('{r}', scale.getPitchName(result.bass));
};
The bass note of the chord.
Holds the name of the chord.
Each time a pitch on the chord gets changed, the name property gets wiped out. So long as the static nameGenerator property has been set, then the next time an attempt is made to get the name, it will be automatically recalculated.
Contains the pitches that make up the chord.
Intended for read use only. To modify the chord, use addPitch, addPitches & removePitches methods.
Pitches should always be held in ascending order.
The root note of the chord.
Setting this property is the same as calling the setRoot method.
Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable.
Adds one or more pitches to a chord, based on chord degrees. For example, addDegrees([3,5]) would add a 3rd & 5th to the chord. The degrees added will always default to the major/perfect variety, though if the scale parameter is used, then the minor/diminished/augmented versions can be used if they would be deemed to be a better fit within the scale. If you want to force the use of the minor/diminished version of the degree, then the degree can be provided as a negative, for example: addDegrees([-3,5])
Returns the chord instance, so that method calls can be chained together.
The degrees of the chord to be added.
Optional, used to allow for better fitting pitch selection.
Adds a new pitch to the chord. This method ensures that pitches are stored in ascending order.
Returns the chord instance, so that method calls can be chained together.
The pitch to add to the chord. This is only added if the chord doesn't already contain the pitch. Can also take pitch names, see the pitch method for more information.
Adds multiple new pitches to the chord. This method ensures that pitches are stored in ascending order.
Returns the chord instance, so that method calls can be chained together.
The pitches to add to the chord. Each one will only be added if the chord doesn't already contain the pitch. Can also take pitch names, see the pitch method for more information.
Returns true if the chord contains the passed in pitch. The method doesn't care if the pitches are in different octaves.
The pitch to check if contained by the chord. Can also take pitch names, see the pitch method for more information.
Returns a pitch near to the passed in pitch, but which should fit better with the notes within the chord.
Returns a new pitch number
The pitch which we want to fit to the chord. Can also take pitch names, see the pitch method for more information.
Optional
options: Partial<FitPitchOptions>The options allow us to configure how we want the pitch to be fitted to the chord
Returns a pitch from the chord based on its degree. To use this, you must have set the chord root.
Example:
new shimi.Chord().setRoot(36).addPitches([40, 43]).getPitchByDegree(5) => 43
new shimi.Chord().setRoot(36).addPitches([40, 43]).getPitchByDegree(8) => 48
new shimi.Chord().setRoot(36).addPitches([40, 43]).getPitchByDegree(9) => 50
Returns a number representing the pitch at the specified degree.
The degree of the chord to fetch
Optional
scale: ScaleUsed to find which pitch to use when the chord doesn't contain the requested degree.
Returns a pitch from the chord based on its index. Allows indices below zero or above pitches.length to fetch pitches from additional registers.
Example:
new shimi.Chord().addPitches([36, 40, 43]).getPitchByIndex(2) => 43
new shimi.Chord().addPitches([36, 40, 43]).getPitchByIndex(3) => 48
new shimi.Chord().addPitches([36, 40, 43]).getPitchByIndex(-1) => 31
Returns a number representing the pitch at the specified index
The index of the pitch to fetch within the chord
Modifies the pitches within a chord up/down octaves so that they are nearer to the desired pitch
Returns the chord instance which the method was called on.
The pitch which the chord should be moved closer to
Defaults to false, meaning the entire chord must be moved up/down as one. If true, then single pitches within the chord can be moved, allowing for inversions.
Removes pitches from the chord that match the passed in condition.
Returns the chord instance, so that method calls can be chained together.
The condition to determine how to remove pitches, for example: pitch => pitch % 2 == 0
would remove all even numbered pitches from the chord.
Sets the root pitch of the chord, also adds the root pitch to the list of pitches if the chord doesn't already contain it.
Returns the chord instance, so that method calls can be chained together.
The pitch to be set as the new chord root. Can also take pitch names, see the pitch method for more information.
Generated using TypeDoc
The Chord class holds a collection of pitches that represent a chord.
Examples: