|
maiacore 1.10.1
Music analisys library
|
Represents a musical measure (bar) within a score, containing notes, staves, key/time signatures, and barlines. More...
#include <measure.h>
Public Member Functions | |
| Measure (const int numStaves=1, const int divisionsPerQuarterNote=256) | |
| Constructs a Measure with a given number of staves and rhythmic division. More... | |
| ~Measure () | |
| Destructor. | |
| void | setKey (int fifthCircle, bool isMajorMode=true) |
| Sets the key signature for the measure. More... | |
| Key | getKey () const |
| Returns the Key object for the measure. More... | |
| std::string | getKeyName () const |
| Returns the key name (e.g., "C major", "G minor"). More... | |
| void | clear () |
| Removes all notes and resets measure state. | |
| void | setNumber (const int measureNumber) |
| Sets the measure number. More... | |
| void | setKeySignature (const int fifthCircle, const bool isMajorMode=true) |
| Sets the key signature for the measure. More... | |
| void | setTimeSignature (const int upper, const int lower) |
| Sets the time signature for the measure. More... | |
| void | setMetronome (const int bpm, const RhythmFigure duration=RhythmFigure::QUARTER) |
| Sets the metronome mark (BPM and rhythm figure) for the measure. More... | |
| void | setKeyMode (const bool isMajorKeyMode) |
| Sets the key mode (major or minor) for the measure. More... | |
| void | setIsKeySignatureChanged (bool isKeySignatureChanged=false) |
| Sets whether the key signature changes in this measure. More... | |
| void | setIsTimeSignatureChanged (bool isTimeSignatureChanged=false) |
| Sets whether the time signature changes in this measure. More... | |
| void | setIsMetronomeChanged (bool isMetronomeChanged=false) |
| Sets whether the metronome mark changes in this measure. More... | |
| void | setIsDivisionsPerQuarterNoteChanged (bool isDivisionsPerQuarterNoteChanged=false) |
| Sets whether the divisions per quarter note changes in this measure. More... | |
| void | setNumStaves (const int numStaves) |
| Sets the number of staves in the measure. More... | |
| void | setDivisionsPerQuarterNote (const int divisionsPerQuarterNote) |
| Sets the divisions per quarter note for the measure. More... | |
| void | addNote (const Note ¬e, const int staveId=0, int position=-1) |
| Adds a note to a specific staff and position in the measure. More... | |
| void | addNote (const std::vector< Note > ¬eVec, const int staveId=0, int position=-1) |
| Adds multiple notes to a specific staff and position in the measure. More... | |
| void | addNote (const std::string &pitchClass, const int staveId=0, int position=-1) |
| Adds a note by pitch string to a specific staff and position. More... | |
| void | addNote (const std::vector< std::string > &pitchClassVec, const int staveId=0, int position=-1) |
| Adds multiple notes by pitch string to a specific staff and position. More... | |
| void | removeNote (const int noteId, const int staveId=0) |
| Removes a note from a specific staff and position. More... | |
| int | getNumber () const |
| Returns the measure number. More... | |
| float | getQuarterDuration () const |
| Returns the total duration of the measure in quarter notes. More... | |
| float | getFilledQuarterDuration (const int staveId=0) const |
| Returns the filled duration (sum of note durations) in quarter notes for a staff. More... | |
| float | getFreeQuarterDuration (const int staveId=0) const |
| Returns the free (remaining) duration in quarter notes for a staff. More... | |
| Fraction | getFractionDuration () const |
| Returns the duration of the measure as a Fraction object. More... | |
| int | getDurationTicks () const |
| Returns the total duration of the measure in ticks. More... | |
| int | getFilledDurationTicks (const int staveId=0) const |
| Returns the filled duration (sum of note durations) in ticks for a staff. More... | |
| int | getFreeDurationTicks (const int staveId=0) const |
| Returns the free (remaining) duration in ticks for a staff. More... | |
| const std::vector< Clef > & | getClefs () const |
| Returns the clefs for all staves in the measure. More... | |
| std::vector< Clef > & | getClefs () |
| Returns the clefs for all staves in the measure (modifiable). More... | |
| const Clef & | getClef (const int clefId=0) const |
| Returns the clef for a specific staff. More... | |
| Clef & | getClef (const int clefId=0) |
| Returns the clef for a specific staff (modifiable). More... | |
| int | getNumStaves () const |
| Returns the number of staves in the measure. More... | |
| const Barline & | getBarlineLeft () const |
| Returns the left barline object. More... | |
| Barline & | getBarlineLeft () |
| Returns the left barline object (modifiable). More... | |
| const Barline & | getBarlineRight () const |
| Returns the right barline object. More... | |
| Barline & | getBarlineRight () |
| Returns the right barline object (modifiable). More... | |
| void | setRepeatStart () |
| Sets the left barline as a repeat start. | |
| void | setRepeatEnd () |
| Sets the right barline as a repeat end. | |
| void | removeRepeatStart () |
| Removes the repeat start from the left barline. | |
| void | removeRepeatEnd () |
| Removes the repeat end from the right barline. | |
| bool | isClefChanged () const |
| Returns true if any clef changes in this measure. More... | |
| bool | timeSignatureChanged () const |
| Returns true if the time signature changes in this measure. More... | |
| bool | keySignatureChanged () const |
| Returns true if the key signature changes in this measure. More... | |
| bool | metronomeChanged () const |
| Returns true if the metronome mark changes in this measure. More... | |
| bool | divisionsPerQuarterNoteChanged () const |
| Returns true if the divisions per quarter note changes in this measure. More... | |
| bool | isMajorKeyMode () const |
| Returns true if the key mode is major. More... | |
| const Note & | getNote (const int noteId, const int staveId=0) const |
| Returns a const reference to a note in a specific staff and position. More... | |
| Note & | getNote (const int noteId, const int staveId=0) |
| Returns a reference to a note in a specific staff and position. More... | |
| const Note & | getNoteOn (const int noteOnId, const int staveId=0) const |
| Returns a const reference to a sounding note (note on) by index and staff. More... | |
| Note & | getNoteOn (const int noteOnId, const int staveId=0) |
| Returns a reference to a sounding note (note on) by index and staff. More... | |
| const Note & | getNoteOff (const int noteOffId, const int staveId=0) const |
| Returns a const reference to a rest note (note off) by index and staff. More... | |
| Note & | getNoteOff (const int noteOffId, const int staveId=0) |
| Returns a reference to a rest note (note off) by index and staff. More... | |
| int | getNumNotesOn () const |
| Returns the number of sounding notes (note on) in the measure (all staves). More... | |
| int | getNumNotesOn (const int staveId) const |
| Returns the number of sounding notes (note on) in a specific staff. More... | |
| int | getNumNotesOff () const |
| Returns the number of rest notes (note off) in the measure (all staves). More... | |
| int | getNumNotesOff (const int staveId) const |
| Returns the number of rest notes (note off) in a specific staff. More... | |
| int | getNumNotes () const |
| Returns the total number of notes in the measure (all staves). More... | |
| int | getNumNotes (const int staveId) const |
| Returns the number of notes in a specific staff. More... | |
| int | getDivisionsPerQuarterNote () const |
| Returns the divisions per quarter note for the measure. More... | |
| int | getFifthCircle () const |
| Returns the number of accidentals in the circle of fifths for the key signature. More... | |
| const std::string | getKeySignature () const |
| Returns the key signature as a string (e.g., "C", "Gm"). More... | |
| const TimeSignature & | getTimeSignature () const |
| Returns the TimeSignature object for the measure. More... | |
| std::pair< std::string, int > | getMetronome () const |
| Returns the metronome mark as a pair (figure, value). More... | |
| void | info () const |
| Prints summary information about the measure to the log. More... | |
| bool | isEmpty () const |
| Returns true if the measure contains no notes in any staff. More... | |
| int | getEmptyDurationTicks () const |
| Returns the empty (unfilled) duration in ticks for the measure. More... | |
| const std::string | toXML (const int instrumentId=1, const int identSize=2) const |
| Serializes the measure to MusicXML format. More... | |
| const std::string | toJSON () const |
| Serializes the measure to JSON format. More... | |
Represents a musical measure (bar) within a score, containing notes, staves, key/time signatures, and barlines.
The Measure class provides methods for managing notes, staves, key and time signatures, metronome marks, and barlines. It supports MusicXML serialization and is designed for music analysis, computational musicology, and MusicXML processing.
| Measure::Measure | ( | const int | numStaves = 1, |
| const int | divisionsPerQuarterNote = 256 |
||
| ) |
Constructs a Measure with a given number of staves and rhythmic division.
| numStaves | Number of staves (default: 1). |
| divisionsPerQuarterNote | Divisions per quarter note (default: 256). |
| void Measure::addNote | ( | const Note & | note, |
| const int | staveId = 0, |
||
| int | position = -1 |
||
| ) |
Adds a note to a specific staff and position in the measure.
| note | Note to add. |
| staveId | Staff index (default: 0). |
| position | Position in the staff (-1 for append). |
| void Measure::addNote | ( | const std::string & | pitchClass, |
| const int | staveId = 0, |
||
| int | position = -1 |
||
| ) |
Adds a note by pitch string to a specific staff and position.
| pitchClass | Pitch string (e.g., "C4"). |
| staveId | Staff index (default: 0). |
| position | Position in the staff (-1 for append). |
| void Measure::addNote | ( | const std::vector< Note > & | noteVec, |
| const int | staveId = 0, |
||
| int | position = -1 |
||
| ) |
Adds multiple notes to a specific staff and position in the measure.
| noteVec | Vector of notes to add. |
| staveId | Staff index (default: 0). |
| position | Position in the staff (-1 for append). |
| void Measure::addNote | ( | const std::vector< std::string > & | pitchClassVec, |
| const int | staveId = 0, |
||
| int | position = -1 |
||
| ) |
Adds multiple notes by pitch string to a specific staff and position.
| pitchClassVec | Vector of pitch strings. |
| staveId | Staff index (default: 0). |
| position | Position in the staff (-1 for append). |
| bool Measure::divisionsPerQuarterNoteChanged | ( | ) | const |
Returns true if the divisions per quarter note changes in this measure.
| Barline & Measure::getBarlineLeft | ( | ) |
Returns the left barline object (modifiable).
| const Barline & Measure::getBarlineLeft | ( | ) | const |
Returns the left barline object.
| Barline & Measure::getBarlineRight | ( | ) |
Returns the right barline object (modifiable).
| const Barline & Measure::getBarlineRight | ( | ) | const |
Returns the right barline object.
| Clef & Measure::getClef | ( | const int | clefId = 0 | ) |
| const Clef & Measure::getClef | ( | const int | clefId = 0 | ) | const |
| std::vector< Clef > & Measure::getClefs | ( | ) |
Returns the clefs for all staves in the measure (modifiable).
| const std::vector< Clef > & Measure::getClefs | ( | ) | const |
Returns the clefs for all staves in the measure.
| int Measure::getDivisionsPerQuarterNote | ( | ) | const |
Returns the divisions per quarter note for the measure.
| int Measure::getDurationTicks | ( | ) | const |
Returns the total duration of the measure in ticks.
| int Measure::getEmptyDurationTicks | ( | ) | const |
Returns the empty (unfilled) duration in ticks for the measure.
| int Measure::getFifthCircle | ( | ) | const |
Returns the number of accidentals in the circle of fifths for the key signature.
| int Measure::getFilledDurationTicks | ( | const int | staveId = 0 | ) | const |
Returns the filled duration (sum of note durations) in ticks for a staff.
| staveId | Staff index (default: 0). |
| float Measure::getFilledQuarterDuration | ( | const int | staveId = 0 | ) | const |
Returns the filled duration (sum of note durations) in quarter notes for a staff.
| staveId | Staff index (default: 0). |
| Fraction Measure::getFractionDuration | ( | ) | const |
Returns the duration of the measure as a Fraction object.
| int Measure::getFreeDurationTicks | ( | const int | staveId = 0 | ) | const |
Returns the free (remaining) duration in ticks for a staff.
| staveId | Staff index (default: 0). |
| float Measure::getFreeQuarterDuration | ( | const int | staveId = 0 | ) | const |
Returns the free (remaining) duration in quarter notes for a staff.
| staveId | Staff index (default: 0). |
| std::string Measure::getKeyName | ( | ) | const |
Returns the key name (e.g., "C major", "G minor").
| const std::string Measure::getKeySignature | ( | ) | const |
Returns the key signature as a string (e.g., "C", "Gm").
| std::pair< std::string, int > Measure::getMetronome | ( | ) | const |
Returns the metronome mark as a pair (figure, value).
| Note & Measure::getNote | ( | const int | noteId, |
| const int | staveId = 0 |
||
| ) |
| const Note & Measure::getNote | ( | const int | noteId, |
| const int | staveId = 0 |
||
| ) | const |
| Note & Measure::getNoteOff | ( | const int | noteOffId, |
| const int | staveId = 0 |
||
| ) |
| const Note & Measure::getNoteOff | ( | const int | noteOffId, |
| const int | staveId = 0 |
||
| ) | const |
| Note & Measure::getNoteOn | ( | const int | noteOnId, |
| const int | staveId = 0 |
||
| ) |
| const Note & Measure::getNoteOn | ( | const int | noteOnId, |
| const int | staveId = 0 |
||
| ) | const |
| int Measure::getNumber | ( | ) | const |
Returns the measure number.
| int Measure::getNumNotes | ( | ) | const |
Returns the total number of notes in the measure (all staves).
| int Measure::getNumNotes | ( | const int | staveId | ) | const |
Returns the number of notes in a specific staff.
| staveId | Staff index. |
| int Measure::getNumNotesOff | ( | ) | const |
Returns the number of rest notes (note off) in the measure (all staves).
| int Measure::getNumNotesOff | ( | const int | staveId | ) | const |
Returns the number of rest notes (note off) in a specific staff.
| staveId | Staff index. |
| int Measure::getNumNotesOn | ( | ) | const |
Returns the number of sounding notes (note on) in the measure (all staves).
| int Measure::getNumNotesOn | ( | const int | staveId | ) | const |
Returns the number of sounding notes (note on) in a specific staff.
| staveId | Staff index. |
| int Measure::getNumStaves | ( | ) | const |
Returns the number of staves in the measure.
| float Measure::getQuarterDuration | ( | ) | const |
Returns the total duration of the measure in quarter notes.
| const TimeSignature & Measure::getTimeSignature | ( | ) | const |
Returns the TimeSignature object for the measure.
| void Measure::info | ( | ) | const |
Prints summary information about the measure to the log.
Includes measure number, key, time signature, and note count.
| bool Measure::isClefChanged | ( | ) | const |
Returns true if any clef changes in this measure.
| bool Measure::isEmpty | ( | ) | const |
Returns true if the measure contains no notes in any staff.
| bool Measure::isMajorKeyMode | ( | ) | const |
Returns true if the key mode is major.
| bool Measure::keySignatureChanged | ( | ) | const |
Returns true if the key signature changes in this measure.
| bool Measure::metronomeChanged | ( | ) | const |
Returns true if the metronome mark changes in this measure.
| void Measure::removeNote | ( | const int | noteId, |
| const int | staveId = 0 |
||
| ) |
Removes a note from a specific staff and position.
| noteId | Note index. |
| staveId | Staff index (default: 0). |
| void Measure::setDivisionsPerQuarterNote | ( | const int | divisionsPerQuarterNote | ) |
Sets the divisions per quarter note for the measure.
| divisionsPerQuarterNote | New divisions per quarter note. |
| void Measure::setIsDivisionsPerQuarterNoteChanged | ( | bool | isDivisionsPerQuarterNoteChanged = false | ) |
Sets whether the divisions per quarter note changes in this measure.
| isDivisionsPerQuarterNoteChanged | True if changed. |
| void Measure::setIsKeySignatureChanged | ( | bool | isKeySignatureChanged = false | ) |
Sets whether the key signature changes in this measure.
| isKeySignatureChanged | True if changed. |
| void Measure::setIsMetronomeChanged | ( | bool | isMetronomeChanged = false | ) |
Sets whether the metronome mark changes in this measure.
| isMetronomeChanged | True if changed. |
| void Measure::setIsTimeSignatureChanged | ( | bool | isTimeSignatureChanged = false | ) |
Sets whether the time signature changes in this measure.
| isTimeSignatureChanged | True if changed. |
| void Measure::setKey | ( | int | fifthCircle, |
| bool | isMajorMode = true |
||
| ) |
Sets the key signature for the measure.
| fifthCircle | Number of accidentals in the circle of fifths. |
| isMajorMode | True for major, false for minor. |
| void Measure::setKeyMode | ( | const bool | isMajorKeyMode | ) |
Sets the key mode (major or minor) for the measure.
| isMajorKeyMode | True for major, false for minor. |
| void Measure::setKeySignature | ( | const int | fifthCircle, |
| const bool | isMajorMode = true |
||
| ) |
Sets the key signature for the measure.
| fifthCircle | Number of accidentals. |
| isMajorMode | True for major, false for minor. |
| void Measure::setMetronome | ( | const int | bpm, |
| const RhythmFigure | duration = RhythmFigure::QUARTER |
||
| ) |
Sets the metronome mark (BPM and rhythm figure) for the measure.
| bpm | Beats per minute. |
| duration | Rhythm figure (default: QUARTER). |
| void Measure::setNumber | ( | const int | measureNumber | ) |
Sets the measure number.
| measureNumber | New measure number. |
| void Measure::setNumStaves | ( | const int | numStaves | ) |
Sets the number of staves in the measure.
| numStaves | New number of staves. |
| void Measure::setTimeSignature | ( | const int | upper, |
| const int | lower | ||
| ) |
Sets the time signature for the measure.
| upper | Numerator. |
| lower | Denominator. |
| bool Measure::timeSignatureChanged | ( | ) | const |
Returns true if the time signature changes in this measure.
| const std::string Measure::toJSON | ( | ) | const |
Serializes the measure to JSON format.
| const std::string Measure::toXML | ( | const int | instrumentId = 1, |
| const int | identSize = 2 |
||
| ) | const |
Serializes the measure to MusicXML format.
| instrumentId | Instrument index (default: 1). |
| identSize | Indentation size (default: 2). |