|
maiacore 1.10.1
Music analisys library
|
Represents a musical chord. More...
#include <chord.h>
Public Member Functions | |
| Chord () | |
| Construct an empty Chord object. More... | |
| Chord (const std::vector< Note > ¬es, const RhythmFigure rhythmFigure=RhythmFigure::QUARTER) | |
| Construct a Chord from a vector of Note objects. More... | |
| Chord (const std::vector< std::string > &pitches, const RhythmFigure rhythmFigure=RhythmFigure::QUARTER) | |
| Construct a Chord from a vector of pitch strings. More... | |
| ~Chord () | |
| Destroy the Chord object and release resources. | |
| void | clear () |
| Remove all notes from the chord, resetting its state. | |
| void | addNote (const Note ¬e) |
| Add a Note object to the chord. More... | |
| void | addNote (const std::string &pitch) |
| Add a note to the chord by pitch string. More... | |
| void | removeTopNote () |
| Remove the top (last) note from the chord. | |
| void | insertNote (Note &insertNote, int positionNote=0) |
| Insert a note at a specific position in the chord. More... | |
| void | removeNote (int noteIndex) |
| Remove a note at a specific index from the chord. More... | |
| void | setDuration (const Duration &duration) |
| Set the duration for all notes in the chord. More... | |
| void | setDuration (const float quarterDuration, const int divisionsPerQuarterNote=256) |
| Set the duration for all notes in the chord using quarter note value. More... | |
| void | toInversion (int inversionNumber) |
| Invert the chord by moving the lowest note up by one octave, repeated inversionNumber times. More... | |
| void | transpose (const int semiTonesNumber) |
| Transpose all notes in the chord by a number of semitones. More... | |
| void | transposeStackOnly (const int semiTonesNumber) |
| Transpose only the stacked (open) version of the chord by a number of semitones. More... | |
| void | removeDuplicateNotes () |
| Remove duplicate notes (by pitch) from the chord. | |
| std::vector< HeapData > | getStackedHeaps (const bool enharmonyNotes=false) |
| Get all possible stacked heaps (enharmonic variants) for the chord. More... | |
| std::string | getDuration () const |
| Get the shortest duration type among all notes in the chord. More... | |
| float | getQuarterDuration () const |
| Get the shortest duration in quarter notes among all notes. More... | |
| int | getDurationTicks () const |
| Get the minimum duration in ticks among all notes. More... | |
| Note & | getNote (int noteIndex) |
| Get a reference to a note at a given index. More... | |
| const Note & | getNote (const int noteIndex) const |
| Get a const reference to a note at a given index. More... | |
| const Note & | getRoot () |
| Get the root note of the chord (after stacking in thirds). More... | |
| std::string | getName () |
| Get the chord name using tonal analysis (e.g., "Cm7", "G7"). More... | |
| const Note & | getBassNote () |
| Get the bass note of the chord (lowest note). More... | |
| const std::vector< Note > & | getNotes () const |
| Get all notes in the chord (original order). More... | |
| float | getCloseStackHarmonicComplexity (const bool useEnharmony=false) |
| Compute the harmonic complexity of the chord in closed position. More... | |
| float | getHarmonicDensity (int lowerBoundMIDI=-1, int higherBoundMIDI=-1) const |
| Compute the harmonic density of the chord in a MIDI range. More... | |
| float | getHarmonicDensity (const std::string &lowerBoundPitch={}, const std::string &higherBoundPitch={}) const |
| Compute the harmonic density of the chord in a pitch range. More... | |
| bool | haveMajorInterval (const bool useEnharmony=false) const |
| Check if the chord contains at least one major interval. More... | |
| bool | haveMinorInterval (const bool useEnharmony=false) const |
| Check if the chord contains at least one minor interval. More... | |
| bool | havePerfectInterval (const bool useEnharmony=false) const |
| Check if the chord contains at least one perfect interval. More... | |
| bool | haveDiminishedInterval (const bool useEnharmony=false) const |
| Check if the chord contains at least one diminished interval. More... | |
| bool | haveAugmentedInterval (const bool useEnharmony=false) const |
| Check if the chord contains at least one augmented interval. More... | |
| bool | haveDiminishedUnisson (const bool useEnharmony=false) const |
| Checks if the chord contains a diminished unison interval (e.g., C and Cb). More... | |
| bool | havePerfectUnisson (const bool useEnharmony=false) const |
| Checks if the chord contains a perfect unison interval (e.g., two notes with the same pitch). More... | |
| bool | haveAugmentedUnisson (const bool useEnharmony=false) const |
| Checks if the chord contains an augmented unison interval (e.g., C and C#). More... | |
| bool | haveMinorSecond (const bool useEnharmony=false) |
| Checks if the chord contains a minor second interval (e.g., C and Db). More... | |
| bool | haveMajorSecond (const bool useEnharmony=false) |
| Checks if the chord contains a major second interval (e.g., C and D). More... | |
| bool | haveMinorThird (const bool useEnharmony=false) |
| Checks if the chord contains a minor third interval (e.g., C and Eb). More... | |
| bool | haveMajorThird (const bool useEnharmony=false) |
| Checks if the chord contains a major third interval (e.g., C and E). More... | |
| bool | havePerfectFourth (const bool useEnharmony=false) |
| Checks if the chord contains a perfect fourth interval (e.g., C and F). More... | |
| bool | haveAugmentedFourth (const bool useEnharmony=false) |
| Checks if the chord contains an augmented fourth interval (tritone, e.g., C and F#). More... | |
| bool | haveDiminishedFifth (const bool useEnharmony=false) |
| Checks if the chord contains a diminished fifth interval (tritone, e.g., C and Gb). More... | |
| bool | havePerfectFifth (const bool useEnharmony=false) |
| Checks if the chord contains a perfect fifth interval (e.g., C and G). More... | |
| bool | haveAugmentedFifth (const bool useEnharmony=false) |
| Checks if the chord contains an augmented fifth interval (e.g., C and G#). More... | |
| bool | haveMinorSixth (const bool useEnharmony=false) |
| Checks if the chord contains a minor sixth interval (e.g., C and Ab). More... | |
| bool | haveMajorSixth (const bool useEnharmony=false) |
| Checks if the chord contains a major sixth interval (e.g., C and A). More... | |
| bool | haveDiminishedSeventh (const bool useEnharmony=false) |
| Checks if the chord contains a diminished seventh interval (e.g., C and Bbb). More... | |
| bool | haveMinorSeventh (const bool useEnharmony=false) |
| Checks if the chord contains a minor seventh interval (e.g., C and Bb). More... | |
| bool | haveMajorSeventh (const bool useEnharmony=false) |
| Checks if the chord contains a major seventh interval (e.g., C and B). More... | |
| bool | haveDiminishedOctave (const bool useEnharmony=false) |
| Checks if the chord contains a diminished octave interval (e.g., C and Cb an octave apart). More... | |
| bool | havePerfectOctave (const bool useEnharmony=false) |
| Checks if the chord contains a perfect octave interval (e.g., C4 and C5). More... | |
| bool | haveAugmentedOctave (const bool useEnharmony=false) |
| Checks if the chord contains an augmented octave interval (e.g., C and C# an octave apart). More... | |
| bool | haveMinorNinth (const bool useEnharmony=false) |
| Checks if the chord contains a minor ninth interval (e.g., C and Db an octave apart). More... | |
| bool | haveMajorNinth (const bool useEnharmony=false) |
| Checks if the chord contains a major ninth interval (e.g., C and D an octave apart). More... | |
| bool | havePerfectEleventh (const bool useEnharmony=false) |
| Checks if the chord contains a perfect eleventh interval (e.g., C and F two octaves apart). More... | |
| bool | haveSharpEleventh (const bool useEnharmony=false) |
| Checks if the chord contains a sharp eleventh interval (e.g., C and F# two octaves apart). More... | |
| bool | haveMinorThirdteenth (const bool useEnharmony=false) |
| Checks if the chord contains a minor thirteenth interval (e.g., C and Ab two octaves plus a sixth apart). More... | |
| bool | haveMajorThirdteenth (const bool useEnharmony=false) |
| Checks if the chord contains a major thirteenth interval (e.g., C and A two octaves plus a sixth apart). More... | |
| bool | haveSecond (const bool useEnharmony=false) const |
| Checks if the chord contains any second interval (major or minor) between its notes. More... | |
| bool | haveThird (const bool useEnharmony=false) const |
| Checks if the chord contains any third interval (major or minor) between its notes. More... | |
| bool | haveFourth (const bool useEnharmony=false) const |
| Checks if the chord contains any fourth interval (perfect, augmented, or diminished) between its notes. More... | |
| bool | haveFifth (const bool useEnharmony=false) const |
| Checks if the chord contains any fifth interval (perfect, augmented, or diminished) between its notes. More... | |
| bool | haveSixth (const bool useEnharmony=false) const |
| Checks if the chord contains any sixth interval (major or minor) between its notes. More... | |
| bool | haveSeventh (const bool useEnharmony=false) const |
| Checks if the chord contains any seventh interval (major, minor, or diminished) between its notes. More... | |
| bool | haveOctave (const bool useEnharmony=false) const |
| Checks if the chord contains any octave interval (perfect, augmented, or diminished) between its notes. More... | |
| bool | haveNinth (const bool useEnharmony=false) const |
| Checks if the chord contains any ninth interval (major or minor) between its notes. More... | |
| bool | haveEleventh (const bool useEnharmony=false) const |
| Checks if the chord contains any eleventh interval (perfect or sharp) between its notes. More... | |
| bool | haveThirdteenth (const bool useEnharmony=false) const |
| Checks if the chord contains any thirteenth interval (major or minor) between its notes. More... | |
| bool | haveAnyOctaveMinorSecond (const bool useEnharmony=false) const |
| Checks if the chord contains a minor second interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveMajorSecond (const bool useEnharmony=false) const |
| Checks if the chord contains a major second interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveMinorThird (const bool useEnharmony=false) const |
| Checks if the chord contains a minor third interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveMajorThird (const bool useEnharmony=false) const |
| Checks if the chord contains a major third interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctavePerfectFourth (const bool useEnharmony=false) const |
| Checks if the chord contains a perfect fourth interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveAugmentedFourth (const bool useEnharmony=false) const |
| Checks if the chord contains an augmented fourth interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveDiminishedFifth (const bool useEnharmony=false) const |
| Checks if the chord contains a diminished fifth interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctavePerfectFifth (const bool useEnharmony=false) const |
| Checks if the chord contains a perfect fifth interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveAugmentedFifth (const bool useEnharmony=false) const |
| Checks if the chord contains an augmented fifth interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveMinorSixth (const bool useEnharmony=false) const |
| Checks if the chord contains a minor sixth interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveMajorSixth (const bool useEnharmony=false) const |
| Checks if the chord contains a major sixth interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveDiminishedSeventh (const bool useEnharmony=false) const |
| Checks if the chord contains a diminished seventh interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveMinorSeventh (const bool useEnharmony=false) const |
| Checks if the chord contains a minor seventh interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveMajorSeventh (const bool useEnharmony=false) const |
| Checks if the chord contains a major seventh interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveDiminishedOctave (const bool useEnharmony=false) const |
| Checks if the chord contains a diminished octave interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctavePerfectOctave (const bool useEnharmony=false) const |
| Checks if the chord contains a perfect octave interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveAugmentedOctave (const bool useEnharmony=false) const |
| Checks if the chord contains an augmented octave interval between any two notes, ignoring octave differences. More... | |
| bool | haveAnyOctaveSecond () const |
| Checks if the chord contains a generic second interval (major or minor, any octave). More... | |
| bool | haveAnyOctaveThird () const |
| Checks if the chord contains a generic third interval (major or minor, any octave). More... | |
| bool | haveAnyOctaveFourth () const |
| Checks if the chord contains a generic fourth interval (perfect, augmented, or diminished, any octave). More... | |
| bool | haveAnyOctaveFifth () const |
| Checks if the chord contains a generic fifth interval (perfect, augmented, or diminished, any octave). More... | |
| bool | haveAnyOctaveSixth () const |
| Checks if the chord contains a generic sixth interval (major or minor, any octave). More... | |
| bool | haveAnyOctaveSeventh () const |
| Checks if the chord contains a generic seventh interval (major, minor, or diminished, any octave). More... | |
| bool | haveAnyOctaveOctave () const |
| Checks if the chord contains a generic octave interval (perfect, augmented, or diminished, any octave). More... | |
| bool | isDyad () |
| Determines if the chord is a dyad (contains exactly two distinct notes). More... | |
| bool | isSus () |
| Determines if the chord is a suspended chord (sus2 or sus4). More... | |
| bool | isMajorChord () |
| Determines if the chord is a major triad. More... | |
| bool | isMinorChord () |
| Determines if the chord is a minor triad. More... | |
| bool | isAugmentedChord () |
| Determines if the chord is an augmented triad. More... | |
| bool | isDiminishedChord () |
| Determines if the chord is a diminished triad. More... | |
| bool | isHalfDiminishedChord () |
| Determines if the chord is a half-diminished seventh chord. More... | |
| bool | isWholeDiminishedChord () |
| Determines if the chord is a fully diminished seventh chord. More... | |
| bool | isDominantSeventhChord () |
| Determines if the chord is a dominant seventh chord. More... | |
| std::string | getQuality () |
| Returns a string describing the chord quality (e.g., "major", "minor", "diminished", "augmented", "sus", etc). More... | |
| bool | isSorted () const |
| Checks if the notes in the chord are sorted in ascending order by MIDI number. More... | |
| bool | isTonal (std::function< bool(const Chord &chord)> model=nullptr) |
| Determines if the chord is tonal according to a given model or default rules. More... | |
| bool | isInRootPosition () |
| Checks if the chord is in root position (lowest note is the root). More... | |
| std::vector< int > | getMidiIntervals (const bool firstNoteAsReference=false) const |
| Returns the intervals between notes in the chord as MIDI semitone values. More... | |
| std::vector< Interval > | getIntervals (const bool firstNoteAsReference=false) const |
| Returns the intervals between notes in the chord as Interval objects. More... | |
| std::vector< Interval > | getIntervalsFromOriginalSortedNotes () const |
| Returns the intervals between the sorted original notes as Interval objects. More... | |
| std::vector< Interval > | getOpenStackIntervals (const bool firstNoteAsReference=false) |
| Returns the intervals between notes in the open stack as Interval objects. More... | |
| std::vector< Interval > | getCloseStackIntervals (const bool firstNoteAsReference=false) |
| Returns the intervals between notes in the closed stack as Interval objects. More... | |
| std::vector< Note > | getOpenStackNotes () |
| Returns the notes of the chord in open stack (stacked in thirds) order. More... | |
| int | size () const |
| Returns the number of notes in the chord. More... | |
| int | stackSize () |
| Returns the number of notes in the open stack (after stacking in thirds). More... | |
| void | print () const |
| Prints the pitches of all notes in the chord to the log. More... | |
| void | printStack () const |
| Prints the pitches of all notes in the open stack to the log. More... | |
| void | info () |
| Prints detailed information about the chord, including name, size, notes, and stack. More... | |
| Chord | getOpenStackChord (const bool enharmonyNotes=false) |
| Returns a Chord object representing the open stack (stacked in thirds). More... | |
| Chord | getCloseStackChord (const bool enharmonyNotes=false) |
| Returns a Chord object representing the closed stack (stacked in thirds, closed position). More... | |
| Chord | getCloseChord (const bool enharmonyNotes=false) |
| Returns a Chord object representing the closed chord, with octaves adjusted to match the original. More... | |
| void | sortNotes () |
| Sorts the notes in the chord in ascending order by MIDI number. More... | |
| std::vector< int > | toCents () const |
| Returns a vector with the intervals (in cents) between each pair of adjacent notes in the chord. More... | |
| int | getDegree (const Key &key, bool enharmonyNotes=false) |
| Returns the scale degree of the chord's root in a given key. More... | |
| std::string | getRomanDegree (const Key &key, bool enharmonyNotes=false) |
| Returns the Roman numeral degree of the chord's root in a given key. More... | |
| float | getMeanFrequency (const float freqA4=440.0f) const |
| Calculates the arithmetic mean of the frequencies of all notes in the chord. More... | |
| float | getMeanOfExtremesFrequency (const float freqA4=440.0f) const |
| Calculates the mean frequency between the lowest and highest notes in the chord. More... | |
| float | getFrequencyStd (const float freqA4=440.0f) const |
| Calculates the standard deviation of the frequencies of all notes in the chord. More... | |
| int | getMeanMidiValue () const |
| Calculates the arithmetic mean of the MIDI numbers of all notes in the chord. More... | |
| int | getMeanOfExtremesMidiValue () const |
| Calculates the mean MIDI value between the lowest and highest notes in the chord. More... | |
| float | getMidiValueStd () const |
| Calculates the standard deviation of the MIDI numbers of all notes in the chord. More... | |
| std::string | getMeanPitch (const std::string &accType={}) const |
| Returns the pitch name corresponding to the mean MIDI value of the chord. More... | |
| std::string | getMeanOfExtremesPitch (const std::string &accType={}) const |
| Returns the pitch name corresponding to the mean of the lowest and highest MIDI values in the chord. More... | |
| std::pair< std::vector< float >, std::vector< float > > | getHarmonicSpectrum (const int numPartialsPerNote=6, const std::function< std::vector< float >(std::vector< float >)> amplCallback=nullptr, const float partialsDecayExpRate=0.88f) const |
| Computes the combined harmonic spectrum of the chord by summing the spectra of all notes. More... | |
| SetharesDissonanceTable | getSetharesDyadsDissonanceValue (const int numPartials=6, const bool useMinModel=true, const std::function< std::vector< float >(std::vector< float >)> amplCallback=nullptr, const float partialsDecayExpRate=0.88f) const |
| Calculates the Sethares dissonance value for all dyads in the chord. More... | |
| float | getSetharesDissonance (const int numPartialsPerNote=6, const bool useMinModel=true, const std::function< std::vector< float >(std::vector< float >)> amplCallback=nullptr, const float partialsDecayExpRate=0.88f, const std::function< float(std::vector< float >)> dissCallback=nullptr) const |
| Calculates the total Sethares dissonance for the chord. More... | |
| const Note & | operator[] (size_t index) const |
| Array subscript operator for read-only access to notes in original (unsorted) order. More... | |
| Note & | operator[] (size_t index) |
| Array subscript operator for mutable access to notes in original (unsorted) order. More... | |
| bool | operator== (const Chord &otherChord) const |
| Equality operator comparing chords by pitch-space note ordering. More... | |
| bool | operator!= (const Chord &otherChord) const |
| Inequality operator comparing chords by pitch-space note ordering. More... | |
| Chord | operator+ (const Chord &otherChord) const |
| std::vector< Note >::iterator | begin () |
| Returns an iterator to the beginning of the original notes vector. More... | |
| std::vector< Note >::iterator | end () |
| Returns an iterator to the end of the original notes vector. More... | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Chord &chord) |
| Output stream operator for Chord. Prints the chord as a list of pitches. More... | |
Represents a musical chord.
The Chord class encapsulates a collection of musical notes, allowing for operations such as stacking in thirds, transposing, and computing harmonic properties. It supports both open and closed stack representations, as well as enharmonic transformations of notes.
| Chord::Chord | ( | ) |
Construct an empty Chord object.
The chord will have no notes initially.
|
explicit |
|
explicit |
Construct a Chord from a vector of pitch strings.
| pitches | Vector of pitch strings (e.g., "C4", "E4", "G4"). |
| rhythmFigure | The rhythm figure to assign to each note (default: QUARTER). |
| void Chord::addNote | ( | const Note & | note | ) |
| void Chord::addNote | ( | const std::string & | pitch | ) |
Add a note to the chord by pitch string.
| pitch | The pitch string (e.g., "C4"). |
|
inline |
Returns an iterator to the beginning of the original notes vector.
|
inline |
Returns an iterator to the end of the original notes vector.
| const Note & Chord::getBassNote | ( | ) |
Get the bass note of the chord (lowest note).
| Chord Chord::getCloseChord | ( | const bool | enharmonyNotes = false | ) |
| Chord Chord::getCloseStackChord | ( | const bool | enharmonyNotes = false | ) |
| float Chord::getCloseStackHarmonicComplexity | ( | const bool | useEnharmony = false | ) |
Compute the harmonic complexity of the chord in closed position.
| useEnharmony | If true, considers enharmonic equivalents. |
Calculates harmonic complexity by analyzing the intervallic structure of the chord in its closed-stack (root position) configuration. The complexity metric quantifies the degree of dissonance and intervallic tension based on:
Returns a normalized value where:
When useEnharmony=true, enharmonic equivalents (e.g., C# ≡ Db) are treated as identical pitch classes, reducing perceived complexity in chromatic contexts.
This metric is useful for:
| std::vector< Interval > Chord::getCloseStackIntervals | ( | const bool | firstNoteAsReference = false | ) |
Returns the intervals between notes in the closed stack as Interval objects.
If firstNoteAsReference is true, intervals are calculated from the first note to each subsequent note. Otherwise, intervals are calculated between each pair of adjacent notes.
| firstNoteAsReference | If true, use the first note as the reference for all intervals. |
| int Chord::getDegree | ( | const Key & | key, |
| bool | enharmonyNotes = false |
||
| ) |
Returns the scale degree of the chord's root in a given key.
The degree is calculated relative to the provided Key object, considering enharmonic spelling if requested.
| key | The Key object representing the tonal center. |
| enharmonyNotes | If true, considers enharmonic equivalents for the root. |
| std::string Chord::getDuration | ( | ) | const |
Get the shortest duration type among all notes in the chord.
| int Chord::getDurationTicks | ( | ) | const |
Get the minimum duration in ticks among all notes.
| float Chord::getFrequencyStd | ( | const float | freqA4 = 440.0f | ) | const |
Calculates the standard deviation of the frequencies of all notes in the chord.
Useful for measuring the spectral spread or compactness of the chord.
| freqA4 | Reference frequency for A4 (default: 440.0 Hz). |
| float Chord::getHarmonicDensity | ( | const std::string & | lowerBoundPitch = {}, |
| const std::string & | higherBoundPitch = {} |
||
| ) | const |
Compute the harmonic density of the chord in a pitch range.
| lowerBoundPitch | Lowest pitch string (e.g., "C4"). |
| higherBoundPitch | Highest pitch string (e.g., "G5"). |
| float Chord::getHarmonicDensity | ( | int | lowerBoundMIDI = -1, |
| int | higherBoundMIDI = -1 |
||
| ) | const |
Compute the harmonic density of the chord in a MIDI range.
| lowerBoundMIDI | Lowest MIDI note (default: -1, auto-detect). |
| higherBoundMIDI | Highest MIDI note (default: -1, auto-detect). |
Calculates the spatial distribution of notes within a specified MIDI pitch range, quantifying how densely packed the harmonic content is across the frequency spectrum. The density metric reflects:
When bounds are set to -1 (default), the function automatically detects the range using the chord's lowest and highest notes. Custom bounds enable:
Higher density values indicate:
Lower density values indicate:
Useful for analyzing orchestration, voice-leading efficiency, and harmonic texture.
| std::pair< std::vector< float >, std::vector< float > > Chord::getHarmonicSpectrum | ( | const int | numPartialsPerNote = 6, |
| const std::function< std::vector< float >(std::vector< float >)> | amplCallback = nullptr, |
||
| const float | partialsDecayExpRate = 0.88f |
||
| ) | const |
Computes the combined harmonic spectrum of the chord by summing the spectra of all notes.
Useful for timbral and psychoacoustic analysis.
| numPartialsPerNote | Number of partials to include for each note. |
| amplCallback | Optional: function to modify amplitude vector. |
| partialsDecayExpRate | Optional Partials decay exponential rate (default: 0.88). |
| std::vector< Interval > Chord::getIntervals | ( | const bool | firstNoteAsReference = false | ) | const |
Returns the intervals between notes in the chord as Interval objects.
If firstNoteAsReference is true, intervals are calculated from the first note to each subsequent note. Otherwise, intervals are calculated between each pair of adjacent notes.
| firstNoteAsReference | If true, use the first note as the reference for all intervals. |
| std::vector< Interval > Chord::getIntervalsFromOriginalSortedNotes | ( | ) | const |
| float Chord::getMeanFrequency | ( | const float | freqA4 = 440.0f | ) | const |
Calculates the arithmetic mean of the frequencies of all notes in the chord.
Useful for spectral centroid and timbral analysis.
| freqA4 | Reference frequency for A4 (default: 440.0 Hz). |
| int Chord::getMeanMidiValue | ( | ) | const |
Calculates the arithmetic mean of the MIDI numbers of all notes in the chord.
Useful for pitch center analysis.
| float Chord::getMeanOfExtremesFrequency | ( | const float | freqA4 = 440.0f | ) | const |
Calculates the mean frequency between the lowest and highest notes in the chord.
Useful for summarizing the chord's spectral span.
| freqA4 | Reference frequency for A4 (default: 440.0 Hz). |
| int Chord::getMeanOfExtremesMidiValue | ( | ) | const |
Calculates the mean MIDI value between the lowest and highest notes in the chord.
Useful for summarizing the pitch range of the chord.
| std::string Chord::getMeanOfExtremesPitch | ( | const std::string & | accType = {} | ) | const |
Returns the pitch name corresponding to the mean of the lowest and highest MIDI values in the chord.
The accidental type can be specified (e.g., sharp, flat, natural).
| accType | Optional: specify accidental type for pitch spelling. |
| std::string Chord::getMeanPitch | ( | const std::string & | accType = {} | ) | const |
Returns the pitch name corresponding to the mean MIDI value of the chord.
The accidental type can be specified (e.g., sharp, flat, natural).
| accType | Optional: specify accidental type for pitch spelling. |
| std::vector< int > Chord::getMidiIntervals | ( | const bool | firstNoteAsReference = false | ) | const |
Returns the intervals between notes in the chord as MIDI semitone values.
If firstNoteAsReference is true, intervals are calculated from the first note to each subsequent note. Otherwise, intervals are calculated between each pair of adjacent notes.
| firstNoteAsReference | If true, use the first note as the reference for all intervals. |
| float Chord::getMidiValueStd | ( | ) | const |
Calculates the standard deviation of the MIDI numbers of all notes in the chord.
Useful for measuring the pitch spread or compactness of the chord.
| std::string Chord::getName | ( | ) |
Get the chord name using tonal analysis (e.g., "Cm7", "G7").
| const Note & Chord::getNote | ( | const int | noteIndex | ) | const |
Get a const reference to a note at a given index.
| noteIndex | Index of the note. |
| Note & Chord::getNote | ( | int | noteIndex | ) |
Get a reference to a note at a given index.
| noteIndex | Index of the note. |
| const std::vector< Note > & Chord::getNotes | ( | ) | const |
Get all notes in the chord (original order).
| Chord Chord::getOpenStackChord | ( | const bool | enharmonyNotes = false | ) |
| std::vector< Interval > Chord::getOpenStackIntervals | ( | const bool | firstNoteAsReference = false | ) |
Returns the intervals between notes in the open stack as Interval objects.
If firstNoteAsReference is true, intervals are calculated from the first note to each subsequent note. Otherwise, intervals are calculated between each pair of adjacent notes.
| firstNoteAsReference | If true, use the first note as the reference for all intervals. |
| std::vector< Note > Chord::getOpenStackNotes | ( | ) |
Returns the notes of the chord in open stack (stacked in thirds) order.
Triggers stacking if not already performed.
| std::string Chord::getQuality | ( | ) |
Returns a string describing the chord quality (e.g., "major", "minor", "diminished", "augmented", "sus", etc).
The quality is determined by the chord's interval structure and is useful for harmonic analysis.
| float Chord::getQuarterDuration | ( | ) | const |
Get the shortest duration in quarter notes among all notes.
| std::string Chord::getRomanDegree | ( | const Key & | key, |
| bool | enharmonyNotes = false |
||
| ) |
Returns the Roman numeral degree of the chord's root in a given key.
The degree is calculated relative to the provided Key object, considering enharmonic spelling if requested.
| key | The Key object representing the tonal center. |
| enharmonyNotes | If true, considers enharmonic equivalents for the root. |
| const Note & Chord::getRoot | ( | ) |
Get the root note of the chord (after stacking in thirds).
| float Chord::getSetharesDissonance | ( | const int | numPartialsPerNote = 6, |
| const bool | useMinModel = true, |
||
| const std::function< std::vector< float >(std::vector< float >)> | amplCallback = nullptr, |
||
| const float | partialsDecayExpRate = 0.88f, |
||
| const std::function< float(std::vector< float >)> | dissCallback = nullptr |
||
| ) | const |
Calculates the total Sethares dissonance for the chord.
Aggregates the dissonance values for all dyads, optionally using a custom aggregation function.
| numPartialsPerNote | Number of partials per note. |
| useMinModel | If true, uses the minimum amplitude model; otherwise, uses the product. |
| amplCallback | Optional: function to modify amplitude vector. |
| partialsDecayExpRate | Optional Partials decay exponential rate (default: 0.88). |
| dissCallback | Optional: function to aggregate dissonance values (e.g., mean, max). |
| SetharesDissonanceTable Chord::getSetharesDyadsDissonanceValue | ( | const int | numPartials = 6, |
| const bool | useMinModel = true, |
||
| const std::function< std::vector< float >(std::vector< float >)> | amplCallback = nullptr, |
||
| const float | partialsDecayExpRate = 0.88f |
||
| ) | const |
Calculates the Sethares dissonance value for all dyads in the chord.
| numPartials | Number of partials per note. |
| useMinModel | If true, uses the minimum amplitude model; otherwise, uses the product. |
| amplCallback | Optional: function to modify amplitude vector. |
| partialsDecayExpRate | Optional Partials decay exponential rate (default: 0.88). |
Computes psychoacoustic sensory dissonance using the Sethares spectral dissonance model, which quantifies roughness perception arising from critical band interactions between harmonic partials. The model calculates dissonance for all unique dyads (note pairs) in the chord by analyzing beating patterns and frequency proximity effects.
Dissonance Calculation Process:
Parameters:
numPartials: Higher values increase spectral accuracy but computational cost. Typical range: 6-10 for realistic timbral modeling.useMinModel: Amplitude weighting strategyamplCallback: Custom spectral envelope shaping (e.g., formant filtering, instrument-specific harmonic rolloff). Input/output: vector of partial amplitudes.partialsDecayExpRate: Exponential decay rate for overtone amplitudes. Default 0.88 models typical harmonic decay (~-1.5 dB per partial).Return Value: SetharesDissonanceTable containing per-dyad dissonance values, enabling:
Applications:
| std::vector< HeapData > Chord::getStackedHeaps | ( | const bool | enharmonyNotes = false | ) |
Get all possible stacked heaps (enharmonic variants) for the chord.
| enharmonyNotes | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveAugmentedFifth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains an augmented fifth interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms an augmented fifth interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting altered harmonies in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveAugmentedFourth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains an augmented fourth interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms an augmented fourth (tritone) interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting tritones in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveAugmentedOctave | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains an augmented octave interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms an augmented octave interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting rare or microtonal relationships in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveDiminishedFifth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a diminished fifth interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a diminished fifth (tritone) interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting tritones in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveDiminishedOctave | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a diminished octave interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a diminished octave interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting rare or microtonal relationships in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveDiminishedSeventh | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a diminished seventh interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a diminished seventh interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting diminished harmonies in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveFifth | ( | ) | const |
Checks if the chord contains a generic fifth interval (perfect, augmented, or diminished, any octave).
Useful for identifying quintal relationships between any two notes, regardless of octave.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveFourth | ( | ) | const |
Checks if the chord contains a generic fourth interval (perfect, augmented, or diminished, any octave).
Useful for identifying quartal relationships between any two notes, regardless of octave.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveMajorSecond | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a major second interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a major second interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting stepwise motion or clusters in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveMajorSeventh | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a major seventh interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a major seventh interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting major seventh chords in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveMajorSixth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a major sixth interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a major sixth interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting extended tertian harmonies in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveMajorThird | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a major third interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a major third interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting tertian relationships in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveMinorSecond | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a minor second interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a minor second interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting clusters or dissonant relationships in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveMinorSeventh | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a minor seventh interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a minor seventh interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting seventh chords in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveMinorSixth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a minor sixth interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a minor sixth interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting extended tertian harmonies in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveMinorThird | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a minor third interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a minor third interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting tertian relationships in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveOctave | ( | ) | const |
Checks if the chord contains a generic octave interval (perfect, augmented, or diminished, any octave).
Useful for identifying doubled notes or octave relationships.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctavePerfectFifth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a perfect fifth interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a perfect fifth interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting quintal harmonies in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctavePerfectFourth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a perfect fourth interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a perfect fourth interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting quartal harmonies in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctavePerfectOctave | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a perfect octave interval between any two notes, ignoring octave differences.
Returns true if any pair of notes forms a perfect octave interval, regardless of their octave placement. This method abstracts away octave information and considers only pitch class relationships. Useful for detecting doubled notes in any register.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveSecond | ( | ) | const |
Checks if the chord contains a generic second interval (major or minor, any octave).
Useful for identifying stepwise relationships between any two notes, regardless of octave.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveSeventh | ( | ) | const |
Checks if the chord contains a generic seventh interval (major, minor, or diminished, any octave).
Useful for identifying seventh chords or complex harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveSixth | ( | ) | const |
Checks if the chord contains a generic sixth interval (major or minor, any octave).
Useful for identifying extended tertian or added-sixth harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAnyOctaveThird | ( | ) | const |
Checks if the chord contains a generic third interval (major or minor, any octave).
Useful for identifying tertian relationships between any two notes, regardless of octave.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAugmentedFifth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains an augmented fifth interval (e.g., C and G#).
Indicates the presence of augmented chords or altered dominants.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAugmentedFourth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains an augmented fourth interval (tritone, e.g., C and F#).
The tritone is a key interval in dominant and diminished harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAugmentedInterval | ( | const bool | useEnharmony = false | ) | const |
Check if the chord contains at least one augmented interval.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAugmentedOctave | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains an augmented octave interval (e.g., C and C# an octave apart).
Rare, but may occur in complex or microtonal harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveAugmentedUnisson | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains an augmented unison interval (e.g., C and C#).
Useful for detecting chromatic clusters or extended harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveDiminishedFifth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a diminished fifth interval (tritone, e.g., C and Gb).
The tritone is a key interval in dominant and diminished harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveDiminishedInterval | ( | const bool | useEnharmony = false | ) | const |
Check if the chord contains at least one diminished interval.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveDiminishedOctave | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a diminished octave interval (e.g., C and Cb an octave apart).
Rare, but may occur in complex or microtonal harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveDiminishedSeventh | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a diminished seventh interval (e.g., C and Bbb).
Characteristic of diminished seventh chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveDiminishedUnisson | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a diminished unison interval (e.g., C and Cb).
Useful for identifying chromatic clusters or microtonal chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveEleventh | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any eleventh interval (perfect or sharp) between its notes.
Returns true if there is at least one interval of an eleventh (perfect or sharp) between any two notes in the chord. Useful for identifying 11th chords and complex extensions.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveFifth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any fifth interval (perfect, augmented, or diminished) between its notes.
Returns true if there is at least one interval of a fifth (of any quality) between any two notes in the chord, regardless of octave. Useful for identifying quintal harmonies or power chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveFourth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any fourth interval (perfect, augmented, or diminished) between its notes.
Returns true if there is at least one interval of a fourth (of any quality) between any two notes in the chord, regardless of octave. Useful for identifying quartal harmonies or sus chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMajorInterval | ( | const bool | useEnharmony = false | ) | const |
Check if the chord contains at least one major interval.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMajorNinth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a major ninth interval (e.g., C and D an octave apart).
Useful for identifying extended harmonies (e.g., 9th chords).
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMajorSecond | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a major second interval (e.g., C and D).
Useful for analyzing stepwise motion or clusters.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMajorSeventh | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a major seventh interval (e.g., C and B).
Essential for major seventh chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMajorSixth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a major sixth interval (e.g., C and A).
Useful for identifying extended harmonies and voice leading.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMajorThird | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a major third interval (e.g., C and E).
Essential for identifying major triads and seventh chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMajorThirdteenth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a major thirteenth interval (e.g., C and A two octaves plus a sixth apart).
Useful for identifying 13th chords and complex extensions.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMinorInterval | ( | const bool | useEnharmony = false | ) | const |
Check if the chord contains at least one minor interval.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMinorNinth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a minor ninth interval (e.g., C and Db an octave apart).
Useful for identifying extended harmonies (e.g., 9th chords).
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMinorSecond | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a minor second interval (e.g., C and Db).
Identifies the presence of the smallest diatonic interval, often associated with dissonance.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMinorSeventh | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a minor seventh interval (e.g., C and Bb).
Essential for minor seventh and dominant seventh chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMinorSixth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a minor sixth interval (e.g., C and Ab).
Useful for identifying extended harmonies and voice leading.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMinorThird | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a minor third interval (e.g., C and Eb).
Essential for identifying minor triads and seventh chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveMinorThirdteenth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a minor thirteenth interval (e.g., C and Ab two octaves plus a sixth apart).
Useful for identifying 13th chords and complex extensions.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveNinth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any ninth interval (major or minor) between its notes.
Returns true if there is at least one interval of a ninth (major or minor) between any two notes in the chord. Useful for identifying extended harmonies such as 9th chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveOctave | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any octave interval (perfect, augmented, or diminished) between its notes.
Returns true if there is at least one interval of an octave (of any quality) between any two notes in the chord. Useful for identifying doubled notes or octave relationships.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::havePerfectEleventh | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a perfect eleventh interval (e.g., C and F two octaves apart).
Useful for identifying 11th chords and complex extensions.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::havePerfectFifth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a perfect fifth interval (e.g., C and G).
The perfect fifth is fundamental to tonal harmony and chord structure.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::havePerfectFourth | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a perfect fourth interval (e.g., C and F).
Useful for quartal harmonies and sus chords.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::havePerfectInterval | ( | const bool | useEnharmony = false | ) | const |
Check if the chord contains at least one perfect interval.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::havePerfectOctave | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a perfect octave interval (e.g., C4 and C5).
Indicates the presence of doubled notes in different octaves.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::havePerfectUnisson | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains a perfect unison interval (e.g., two notes with the same pitch).
Indicates the presence of doubled notes in the chord.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveSecond | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any second interval (major or minor) between its notes.
Returns true if there is at least one interval of a second (major or minor) between any two notes in the chord, regardless of octave. This is useful for identifying stepwise relationships within the chord's structure.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveSeventh | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any seventh interval (major, minor, or diminished) between its notes.
Returns true if there is at least one interval of a seventh (of any quality) between any two notes in the chord, regardless of octave. Useful for identifying seventh chords and complex harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveSharpEleventh | ( | const bool | useEnharmony = false | ) |
Checks if the chord contains a sharp eleventh interval (e.g., C and F# two octaves apart).
Useful for identifying altered dominants and Lydian harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveSixth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any sixth interval (major or minor) between its notes.
Returns true if there is at least one interval of a sixth (major or minor) between any two notes in the chord, regardless of octave. Useful for identifying extended tertian harmonies.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveThird | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any third interval (major or minor) between its notes.
Returns true if there is at least one interval of a third (major or minor) between any two notes in the chord, regardless of octave. This is useful for identifying tertian (third-based) relationships within the chord.
| useEnharmony | If true, considers enharmonic equivalents. |
| bool Chord::haveThirdteenth | ( | const bool | useEnharmony = false | ) | const |
Checks if the chord contains any thirteenth interval (major or minor) between its notes.
Returns true if there is at least one interval of a thirteenth (major or minor) between any two notes in the chord. Useful for identifying 13th chords and complex extensions.
| useEnharmony | If true, considers enharmonic equivalents. |
| void Chord::info | ( | ) |
Prints detailed information about the chord, including name, size, notes, and stack.
Useful for analysis and debugging.
| void Chord::insertNote | ( | Note & | insertNote, |
| int | positionNote = 0 |
||
| ) |
Insert a note at a specific position in the chord.
| insertNote | The note to insert. |
| positionNote | The index at which to insert the note. |
| bool Chord::isAugmentedChord | ( | ) |
Determines if the chord is an augmented triad.
Augmented triads contain a root, major third, and augmented fifth.
| bool Chord::isDiminishedChord | ( | ) |
Determines if the chord is a diminished triad.
Diminished triads contain a root, minor third, and diminished fifth.
| bool Chord::isDominantSeventhChord | ( | ) |
Determines if the chord is a dominant seventh chord.
Dominant sevenths contain a root, major third, perfect fifth, and minor seventh.
| bool Chord::isDyad | ( | ) |
Determines if the chord is a dyad (contains exactly two distinct notes).
Dyads are the simplest harmonic structures, often analyzed as intervals.
| bool Chord::isHalfDiminishedChord | ( | ) |
Determines if the chord is a half-diminished seventh chord.
Half-diminished chords contain a root, minor third, diminished fifth, and minor seventh.
| bool Chord::isInRootPosition | ( | ) |
Checks if the chord is in root position (lowest note is the root).
Compares the pitch class of the lowest note with the root of the closed stack.
| bool Chord::isMajorChord | ( | ) |
Determines if the chord is a major triad.
Major triads contain a root, major third, and perfect fifth.
| bool Chord::isMinorChord | ( | ) |
Determines if the chord is a minor triad.
Minor triads contain a root, minor third, and perfect fifth.
| bool Chord::isSorted | ( | ) | const |
Checks if the notes in the chord are sorted in ascending order by MIDI number.
Useful for ensuring consistent interval calculations and for algorithms that require sorted input.
| bool Chord::isSus | ( | ) |
Determines if the chord is a suspended chord (sus2 or sus4).
Suspended chords replace the third with a second or fourth, creating a characteristic open sound.
| bool Chord::isTonal | ( | std::function< bool(const Chord &chord)> | model = nullptr | ) |
Determines if the chord is tonal according to a given model or default rules.
| model | Optional: a function that takes a Chord and returns true if it is tonal. |
Evaluates whether the chord conforms to tonal harmonic principles based on its intervallic content in closed-stack configuration. Two evaluation modes:
Default Model (model = nullptr): Analyzes all intervals in the closed stack and verifies they belong to the tonal interval inventory:
Returns false if ANY interval is:
Custom Model: Allows user-defined tonality criteria via callback function. Useful for:
Applications:
| bool Chord::isWholeDiminishedChord | ( | ) |
Determines if the chord is a fully diminished seventh chord.
Fully diminished chords contain a root, minor third, diminished fifth, and diminished seventh.
|
inline |
Inequality operator comparing chords by pitch-space note ordering.
| otherChord | Chord to compare against. |
Logical negation of operator==. Returns true if chords are not pitch-wise identical in their original note ordering. Inequality holds if:
This is a strict pitch-space inequality preserving registral distinctions. Does NOT account for:
For functional harmonic analysis, use chord quality/root comparison methods instead.
|
inline |
Equality operator comparing chords by pitch-space note ordering.
| otherChord | Chord to compare against. |
Performs pitch-wise equality comparison using the original (unsorted) note sequence. Two chords are considered equal if and only if:
This is a strict pitch-space comparison that preserves registral and voice-leading relationships. It does NOT compare:
For harmonic function equivalence analysis (e.g., comparing C-E-G vs. E-G-C as both being C major triads), use getPitchClassSet() or getChordName() instead.
|
inline |
Array subscript operator for mutable access to notes in original (unsorted) order.
| index | Zero-based index of the note to retrieve (0 ≤ index < size()). |
| std::out_of_range | if index >= size(). |
Allows modification of notes while preserving their positional order. Changes to individual notes do not automatically update cached harmonic analysis results—those are recomputed on demand. Use for transposition, dynamic modification, articulation changes, or other note-level edits.
|
inline |
Array subscript operator for read-only access to notes in original (unsorted) order.
| index | Zero-based index of the note to retrieve (0 ≤ index < size()). |
| std::out_of_range | if index >= size(). |
Provides direct access to notes in their original input order, preserving the vertical arrangement as specified in MusicXML or programmatic construction. Does not reflect sorted or closed-stack ordering used in harmonic analysis. Useful for voice-leading analysis, pitch-space operations, and preserving registral relationships.
| void Chord::print | ( | ) | const |
Prints the pitches of all notes in the chord to the log.
Useful for debugging and inspection.
| void Chord::printStack | ( | ) | const |
Prints the pitches of all notes in the open stack to the log.
Useful for debugging and inspection of the stacked chord.
| void Chord::removeNote | ( | int | noteIndex | ) |
Remove a note at a specific index from the chord.
| noteIndex | Index of the note to remove. |
| void Chord::setDuration | ( | const Duration & | duration | ) |
Set the duration for all notes in the chord.
| duration | The Duration object to assign. |
| void Chord::setDuration | ( | const float | quarterDuration, |
| const int | divisionsPerQuarterNote = 256 |
||
| ) |
Set the duration for all notes in the chord using quarter note value.
| quarterDuration | Duration in quarter notes. |
| divisionsPerQuarterNote | Divisions per quarter note (default: 256). |
| int Chord::size | ( | ) | const |
Returns the number of notes in the chord.
Equivalent to the size of the original notes vector.
| void Chord::sortNotes | ( | ) |
Sorts the notes in the chord in ascending order by MIDI number.
Useful for ensuring consistent interval calculations and for algorithms that require sorted input.
| int Chord::stackSize | ( | ) |
Returns the number of notes in the open stack (after stacking in thirds).
Triggers stacking if not already performed.
| std::vector< int > Chord::toCents | ( | ) | const |
Returns a vector with the intervals (in cents) between each pair of adjacent notes in the chord.
Useful for microtonal and tuning analysis, as well as for comparing intervallic content.
| void Chord::toInversion | ( | int | inversionNumber | ) |
Invert the chord by moving the lowest note up by one octave, repeated inversionNumber times.
| inversionNumber | Number of inversions to perform. |
| void Chord::transpose | ( | const int | semiTonesNumber | ) |
Transpose all notes in the chord by a number of semitones.
| semiTonesNumber | Number of semitones to transpose. |
| void Chord::transposeStackOnly | ( | const int | semiTonesNumber | ) |
Transpose only the stacked (open) version of the chord by a number of semitones.
| semiTonesNumber | Number of semitones to transpose. |
|
friend |