|
maiacore 1.10.1
Music analisys library
|
Represents a musical note, including pitch, duration, articulation, and MusicXML-related attributes. More...
#include <note.h>
Public Member Functions | |
| Note () | |
| Default constructor. Initializes a note as "A4" (MIDI 69). | |
| Note (const std::string &pitch, const RhythmFigure rhythmFigure=RhythmFigure::QUARTER, bool isNoteOn=true, bool inChord=false, const int transposeDiatonic=0, const int transposeChromatic=0, const int divisionsPerQuarterNote=256) | |
| Constructs a Note from a pitch string and rhythm figure. More... | |
| Note (const int midiNumber, const std::string &accType="", const RhythmFigure rhythmFigure=RhythmFigure::QUARTER, bool isNoteOn=true, bool inChord=false, const int transposeDiatonic=0, const int transposeChromatic=0, const int divisionsPerQuarterNote=256) | |
| Constructs a Note from a MIDI number, accidental type, and rhythm figure. More... | |
| ~Note () | |
| Destructor. | |
| void | setPitchClass (const std::string &pitchClass) |
| Sets the pitch class (e.g., "C", "D#", "Bb") for the note. More... | |
| void | setOctave (int octave) |
| Sets the octave for the note. More... | |
| void | setDuration (const Duration &duration) |
| Sets the duration for the note. More... | |
| void | setDuration (const float quarterDuration, const int divisionsPerQuarterNote=256) |
| Sets the duration for the note using quarter note value. More... | |
| void | setDuration (const int durationTicks, const int divisionsPerQuarterNote) |
| Sets the duration for the note using tick values. More... | |
| void | setIsNoteOn (bool isNoteOn) |
| Sets whether the note is sounding (note on) or a rest (note off). More... | |
| void | setPitch (const std::string &pitch) |
| Sets the pitch (e.g., "C4", "G#3") for the note. More... | |
| void | setIsInChord (bool inChord) |
| Sets whether the note is part of a chord. More... | |
| void | setTransposingInterval (const int diatonicInterval, const int chromaticInterval) |
| Sets the transposing interval for the note. More... | |
| void | setVoice (const int voice) |
| Sets the voice number for the note. More... | |
| void | setStaff (const int staff) |
| Sets the staff number for the note. More... | |
| void | setIsGraceNote (const bool isGraceNote=false) |
| Sets whether the note is a grace note. More... | |
| void | setStem (const std::string &stem) |
| Sets the stem direction for the note. More... | |
| void | setIsTuplet (const bool isTuplet=false) |
| Sets the note as part of a tuplet. More... | |
| void | setTupleValues (const int actualNotes, const int normalNotes, const std::string &normalType="eighth") |
| Sets the tuplet values for the note. More... | |
| void | setIsPitched (const bool isPitched=true) |
| Sets whether the note is pitched (true) or unpitched (false). More... | |
| void | setUnpitchedIndex (const int unpitchedIndex) |
| Sets the unpitched index for percussion notes. More... | |
| void | setTieStart () |
| Sets the note as tied at the start. | |
| void | setTieStop () |
| Sets the note as tied at the stop. | |
| void | setTieStopStart () |
| Sets the note as tied at both start and stop. | |
| void | addTie (const std::string &tieType) |
| Adds a tie type to the note. More... | |
| void | addSlur (const std::string &slurType, const std::string &slurOrientation) |
| Adds a slur to the note. More... | |
| void | addArticulation (const std::string &articulation) |
| Adds an articulation mark to the note. More... | |
| void | addBeam (const std::string &beam) |
| Adds a beam type to the note. More... | |
| const std::string | getSoundingPitchClass () const |
| Returns the sounding pitch class (after transposition). More... | |
| const std::string | getSoundingPitch () const |
| Returns the full sounding pitch (after transposition). More... | |
| const std::string | getWrittenPitchClass () const |
| Returns the written pitch class (as notated). More... | |
| const std::string | getWrittenPitch () const |
| Returns the full written pitch (as notated). More... | |
| const std::string | getDiatonicWrittenPitchClass () const |
| Returns the diatonic written pitch class (e.g., "C", "D"). More... | |
| const std::string | getDiatonicSoundingPitchClass () const |
| Returns the diatonic sounding pitch class (e.g., "C", "D"). More... | |
| int | getSoundingOctave () const |
| Returns the sounding octave (after transposition). More... | |
| int | getWrittenOctave () const |
| Returns the written octave (as notated). More... | |
| int | getOctave () const |
| Returns the octave (sounding). More... | |
| std::string | getPitchClass () const |
| Returns the pitch class (sounding). More... | |
| std::string | getWrittenPitchStep () const |
| Returns the written pitch step (e.g., "C", "D"). More... | |
| std::string | getSoundingPitchStep () const |
| Returns the sounding pitch step (e.g., "C", "D"). More... | |
| std::string | getPitchStep () const |
| Returns the pitch step (sounding). More... | |
| std::string | getType () const |
| Returns the note type as a string (e.g., "quarter", "eighth-dot"). More... | |
| std::string | getLongType () const |
| Returns the long note type string (e.g., "quarter-dot"). More... | |
| std::string | getShortType () const |
| Returns the short note type string (e.g., "quarter"). More... | |
| int | getDurationTicks () const |
| Returns the duration in ticks. More... | |
| int | getNumDots () const |
| Returns the number of dots for the note. More... | |
| bool | isDotted () const |
| Returns true if the note is dotted. More... | |
| bool | isDoubleDotted () const |
| Returns true if the note is double-dotted. More... | |
| int | getDivisionsPerQuarterNote () const |
| Returns the divisions per quarter note for the note. More... | |
| const Duration & | getDuration () const |
| Returns the Duration object for the note. More... | |
| float | getQuarterDuration () const |
| Returns the duration in quarter notes as a float. More... | |
| bool | isGraceNote () const |
| Returns true if the note is a grace note. More... | |
| bool | isNoteOn () const |
| Returns true if the note is a sounding note (note on). More... | |
| bool | isNoteOff () const |
| Returns true if the note is a rest (note off). More... | |
| std::string | getPitch () const |
| Returns the full pitch string (sounding). More... | |
| int | getMidiNumber () const |
| Returns the MIDI note number. More... | |
| int | getVoice () const |
| Returns the voice number. More... | |
| int | getStaff () const |
| Returns the staff number. More... | |
| std::string | getStem () const |
| Returns the stem direction. More... | |
| std::vector< std::string > | getTie () const |
| Returns the tie types for the note. More... | |
| void | removeTies () |
| Removes all ties from the note. | |
| std::pair< std::string, std::string > | getSlur () const |
| Returns the slur information (type and orientation). More... | |
| std::vector< std::string > | getArticulation () const |
| Returns the articulation marks for the note. More... | |
| std::vector< std::string > | getBeam () const |
| Returns the beam types for the note. More... | |
| bool | isTuplet () const |
| Returns true if the note is part of a tuplet. More... | |
| bool | isPitched () const |
| Returns true if the note is pitched. More... | |
| int | getUnpitchedIndex () const |
| Returns the unpitched index for percussion notes. More... | |
| std::string | getAlterSymbol () const |
| Returns the accidental symbol for the note (e.g., "#", "b"). More... | |
| bool | inChord () const |
| Returns true if the note is part of a chord. More... | |
| int | getTransposeDiatonic () const |
| Returns the diatonic transposition interval. More... | |
| int | getTransposeChromatic () const |
| Returns the chromatic transposition interval. More... | |
| bool | isTransposed () const |
| Returns true if the note is transposed. More... | |
| std::string | getEnharmonicPitch (const bool alternativeEnhamonicPitch=false) const |
| Returns an enharmonic equivalent pitch string. More... | |
| std::vector< std::string > | getEnharmonicPitches (const bool includeCurrentPitch=false) const |
| Returns all enharmonic pitch strings for the note. More... | |
| Note | getEnharmonicNote (const bool alternativeEnhamonicPitch=false) const |
| Returns an enharmonic equivalent Note object. More... | |
| std::vector< Note > | getEnharmonicNotes (const bool includeCurrentPitch=false) const |
| Returns all enharmonic Note objects for the note. More... | |
| int | getScaleDegree (const Key &key) const |
| Returns the scale degree of the note in a given key. More... | |
| void | toEnharmonicPitch (const bool alternativeEnhamonicPitch=false) |
| Converts the note to its enharmonic equivalent. More... | |
| float | getFrequency (const float freqA4=440.0f) const |
| Returns the frequency of the note in Hz. More... | |
| std::pair< std::vector< float >, std::vector< float > > | getHarmonicSpectrum (const int numPartials=6, const std::function< std::vector< float >(std::vector< float >)> amplCallback=nullptr, const float partialsDecayExpRate=0.88f, const float freqA4=440.0f) const |
| Returns the harmonic spectrum of the note (partials and amplitudes). More... | |
| void | transpose (const int semitones, const std::string &accType=MUSIC_XML::ACCIDENT::NONE) |
| Transposes the note by a number of semitones and optional accidental type. More... | |
| const std::string | toXML (const size_t instrumentId=1, const int identSize=2) const |
| Serializes the note to MusicXML format. More... | |
| void | info () const |
| Prints detailed information about the note to the log. | |
| bool | operator< (const Note &otherNote) const |
| Less-than operator for comparing notes by MIDI number. | |
| bool | operator> (const Note &otherNote) const |
| Greater-than operator for comparing notes by MIDI number. | |
| bool | operator<= (const Note &otherNote) const |
| Less-than-or-equal operator for comparing notes by MIDI number. | |
| bool | operator>= (const Note &otherNote) const |
| Greater-than-or-equal operator for comparing notes by MIDI number. | |
| bool | operator== (const Note &otherNote) const |
| Equality operator for comparing notes by pitch. | |
| bool | operator!= (const Note &otherNote) const |
| Inequality operator for comparing notes by pitch. | |
Represents a musical note, including pitch, duration, articulation, and MusicXML-related attributes.
The Note class provides methods for manipulating and querying musical notes, including pitch and octave handling, duration and rhythm, articulations, ties, beams, transposition, enharmonic equivalents, and MusicXML serialization. Designed for music analysis, computational musicology, and MusicXML processing.
|
explicit |
Constructs a Note from a pitch string and rhythm figure.
| pitch | Pitch string (e.g., "C4", "G#3"). |
| rhythmFigure | Rhythm figure (default: QUARTER). |
| isNoteOn | True if sounding note, false for rest. |
| inChord | True if part of a chord. |
| transposeDiatonic | Diatonic transposition interval. |
| transposeChromatic | Chromatic transposition interval. |
| divisionsPerQuarterNote | Divisions per quarter note (default: 256). |
|
explicit |
Constructs a Note from a MIDI number, accidental type, and rhythm figure.
| midiNumber | MIDI note number. |
| accType | Accidental type (e.g., "#", "b"). |
| rhythmFigure | Rhythm figure (default: QUARTER). |
| isNoteOn | True if sounding note, false for rest. |
| inChord | True if part of a chord. |
| transposeDiatonic | Diatonic transposition interval. |
| transposeChromatic | Chromatic transposition interval. |
| divisionsPerQuarterNote | Divisions per quarter note (default: 256). |
| void Note::addArticulation | ( | const std::string & | articulation | ) |
Adds an articulation mark to the note.
| articulation | Articulation string. |
| void Note::addBeam | ( | const std::string & | beam | ) |
Adds a beam type to the note.
| beam | Beam type string. |
| void Note::addSlur | ( | const std::string & | slurType, |
| const std::string & | slurOrientation | ||
| ) |
Adds a slur to the note.
| slurType | Slur type ("start", "stop"). |
| slurOrientation | Slur orientation ("above", "below"). |
| void Note::addTie | ( | const std::string & | tieType | ) |
Adds a tie type to the note.
| tieType | Tie type ("start", "stop"). |
| std::string Note::getAlterSymbol | ( | ) | const |
Returns the accidental symbol for the note (e.g., "#", "b").
| std::vector< std::string > Note::getArticulation | ( | ) | const |
Returns the articulation marks for the note.
| std::vector< std::string > Note::getBeam | ( | ) | const |
Returns the beam types for the note.
| const std::string Note::getDiatonicSoundingPitchClass | ( | ) | const |
Returns the diatonic sounding pitch class (e.g., "C", "D").
| const std::string Note::getDiatonicWrittenPitchClass | ( | ) | const |
Returns the diatonic written pitch class (e.g., "C", "D").
| int Note::getDivisionsPerQuarterNote | ( | ) | const |
Returns the divisions per quarter note for the note.
| const Duration & Note::getDuration | ( | ) | const |
| int Note::getDurationTicks | ( | ) | const |
Returns the duration in ticks.
| Note Note::getEnharmonicNote | ( | const bool | alternativeEnhamonicPitch = false | ) | const |
| std::vector< Note > Note::getEnharmonicNotes | ( | const bool | includeCurrentPitch = false | ) | const |
| std::string Note::getEnharmonicPitch | ( | const bool | alternativeEnhamonicPitch = false | ) | const |
Returns an enharmonic equivalent pitch string.
| alternativeEnhamonicPitch | If true, returns an alternative enharmonic. |
| std::vector< std::string > Note::getEnharmonicPitches | ( | const bool | includeCurrentPitch = false | ) | const |
Returns all enharmonic pitch strings for the note.
| includeCurrentPitch | If true, includes the current pitch. |
| float Note::getFrequency | ( | const float | freqA4 = 440.0f | ) | const |
Returns the frequency of the note in Hz.
| freqA4 | Reference frequency for A4 (default: 440.0 Hz). |
| std::pair< std::vector< float >, std::vector< float > > Note::getHarmonicSpectrum | ( | const int | numPartials = 6, |
| const std::function< std::vector< float >(std::vector< float >)> | amplCallback = nullptr, |
||
| const float | partialsDecayExpRate = 0.88f, |
||
| const float | freqA4 = 440.0f |
||
| ) | const |
Returns the harmonic spectrum of the note (partials and amplitudes).
| numPartials | Number of partials. |
| amplCallback | Optional amplitude callback. |
| partialsDecayExpRate | Optional Partials decay exponential rate (default: 0.88). |
| freqA4 | Reference frequency for A4 (default: 440.0 Hz). |
| std::string Note::getLongType | ( | ) | const |
Returns the long note type string (e.g., "quarter-dot").
| int Note::getMidiNumber | ( | ) | const |
Returns the MIDI note number.
| int Note::getNumDots | ( | ) | const |
Returns the number of dots for the note.
| int Note::getOctave | ( | ) | const |
Returns the octave (sounding).
| std::string Note::getPitch | ( | ) | const |
Returns the full pitch string (sounding).
| std::string Note::getPitchClass | ( | ) | const |
Returns the pitch class (sounding).
| std::string Note::getPitchStep | ( | ) | const |
Returns the pitch step (sounding).
| float Note::getQuarterDuration | ( | ) | const |
Returns the duration in quarter notes as a float.
| int Note::getScaleDegree | ( | const Key & | key | ) | const |
Returns the scale degree of the note in a given key.
| key | Key object for reference. |
| std::string Note::getShortType | ( | ) | const |
Returns the short note type string (e.g., "quarter").
| std::pair< std::string, std::string > Note::getSlur | ( | ) | const |
Returns the slur information (type and orientation).
| int Note::getSoundingOctave | ( | ) | const |
Returns the sounding octave (after transposition).
| const std::string Note::getSoundingPitch | ( | ) | const |
Returns the full sounding pitch (after transposition).
| const std::string Note::getSoundingPitchClass | ( | ) | const |
Returns the sounding pitch class (after transposition).
| std::string Note::getSoundingPitchStep | ( | ) | const |
Returns the sounding pitch step (e.g., "C", "D").
| int Note::getStaff | ( | ) | const |
Returns the staff number.
| std::string Note::getStem | ( | ) | const |
Returns the stem direction.
| std::vector< std::string > Note::getTie | ( | ) | const |
Returns the tie types for the note.
| int Note::getTransposeChromatic | ( | ) | const |
Returns the chromatic transposition interval.
| int Note::getTransposeDiatonic | ( | ) | const |
Returns the diatonic transposition interval.
| std::string Note::getType | ( | ) | const |
Returns the note type as a string (e.g., "quarter", "eighth-dot").
| int Note::getUnpitchedIndex | ( | ) | const |
Returns the unpitched index for percussion notes.
| int Note::getVoice | ( | ) | const |
Returns the voice number.
| int Note::getWrittenOctave | ( | ) | const |
Returns the written octave (as notated).
| const std::string Note::getWrittenPitch | ( | ) | const |
Returns the full written pitch (as notated).
| const std::string Note::getWrittenPitchClass | ( | ) | const |
Returns the written pitch class (as notated).
| std::string Note::getWrittenPitchStep | ( | ) | const |
Returns the written pitch step (e.g., "C", "D").
| bool Note::inChord | ( | ) | const |
Returns true if the note is part of a chord.
| bool Note::isDotted | ( | ) | const |
Returns true if the note is dotted.
| bool Note::isDoubleDotted | ( | ) | const |
Returns true if the note is double-dotted.
| bool Note::isGraceNote | ( | ) | const |
Returns true if the note is a grace note.
| bool Note::isNoteOff | ( | ) | const |
Returns true if the note is a rest (note off).
| bool Note::isNoteOn | ( | ) | const |
Returns true if the note is a sounding note (note on).
| bool Note::isPitched | ( | ) | const |
Returns true if the note is pitched.
| bool Note::isTransposed | ( | ) | const |
Returns true if the note is transposed.
| bool Note::isTuplet | ( | ) | const |
Returns true if the note is part of a tuplet.
| void Note::setDuration | ( | const Duration & | duration | ) |
Sets the duration for the note.
| duration | Duration object. |
| void Note::setDuration | ( | const float | quarterDuration, |
| const int | divisionsPerQuarterNote = 256 |
||
| ) |
Sets the duration for the note using quarter note value.
| quarterDuration | Duration in quarter notes. |
| divisionsPerQuarterNote | Divisions per quarter note (default: 256). |
| void Note::setDuration | ( | const int | durationTicks, |
| const int | divisionsPerQuarterNote | ||
| ) |
Sets the duration for the note using tick values.
| durationTicks | Duration in ticks. |
| divisionsPerQuarterNote | Divisions per quarter note (default: 256). |
| void Note::setIsGraceNote | ( | const bool | isGraceNote = false | ) |
Sets whether the note is a grace note.
| isGraceNote | True if grace note. |
| void Note::setIsInChord | ( | bool | inChord | ) |
Sets whether the note is part of a chord.
| inChord | True if in chord. |
| void Note::setIsNoteOn | ( | bool | isNoteOn | ) |
Sets whether the note is sounding (note on) or a rest (note off).
| isNoteOn | True for sounding note, false for rest. |
| void Note::setIsPitched | ( | const bool | isPitched = true | ) |
Sets whether the note is pitched (true) or unpitched (false).
| isPitched | True if pitched. |
| void Note::setIsTuplet | ( | const bool | isTuplet = false | ) |
Sets the note as part of a tuplet.
| isTuplet | True if part of a tuplet. |
| void Note::setOctave | ( | int | octave | ) |
Sets the octave for the note.
| octave | Octave number. |
| void Note::setPitch | ( | const std::string & | pitch | ) |
Sets the pitch (e.g., "C4", "G#3") for the note.
| pitch | Pitch string. |
| void Note::setPitchClass | ( | const std::string & | pitchClass | ) |
Sets the pitch class (e.g., "C", "D#", "Bb") for the note.
| pitchClass | The pitch class string. |
| void Note::setStaff | ( | const int | staff | ) |
Sets the staff number for the note.
| staff | Staff number. |
| void Note::setStem | ( | const std::string & | stem | ) |
Sets the stem direction for the note.
| stem | Stem direction ("up", "down", etc.). |
| void Note::setTransposingInterval | ( | const int | diatonicInterval, |
| const int | chromaticInterval | ||
| ) |
Sets the transposing interval for the note.
| diatonicInterval | Diatonic interval. |
| chromaticInterval | Chromatic interval. |
| void Note::setTupleValues | ( | const int | actualNotes, |
| const int | normalNotes, | ||
| const std::string & | normalType = "eighth" |
||
| ) |
Sets the tuplet values for the note.
| actualNotes | Number of actual notes in tuplet. |
| normalNotes | Number of normal notes in tuplet. |
| normalType | Note type for normal notes (default: "eighth"). |
| void Note::setUnpitchedIndex | ( | const int | unpitchedIndex | ) |
Sets the unpitched index for percussion notes.
| unpitchedIndex | Index for unpitched note. |
| void Note::setVoice | ( | const int | voice | ) |
Sets the voice number for the note.
| voice | Voice number. |
| void Note::toEnharmonicPitch | ( | const bool | alternativeEnhamonicPitch = false | ) |
Converts the note to its enharmonic equivalent.
| alternativeEnhamonicPitch | If true, uses alternative enharmonic. |
| const std::string Note::toXML | ( | const size_t | instrumentId = 1, |
| const int | identSize = 2 |
||
| ) | const |
Serializes the note to MusicXML format.
| instrumentId | Instrument index (default: 1). |
| identSize | Indentation size (default: 2). |
| void Note::transpose | ( | const int | semitones, |
| const std::string & | accType = MUSIC_XML::ACCIDENT::NONE |
||
| ) |
Transposes the note by a number of semitones and optional accidental type.
| semitones | Number of semitones. |
| accType | Accidental type (e.g., "#", "b"). |