7#include "maiacore/barline.h"
8#include "maiacore/clef.h"
9#include "maiacore/constants.h"
10#include "maiacore/key.h"
11#include "maiacore/time-signature.h"
27 std::string _metronomeFigure;
29 bool _isKeySignatureChanged;
30 bool _isTimeSignatureChanged;
31 bool _isMetronomeChanged;
32 bool _isDivisionsPerQuarterNoteChanged;
34 int _divisionsPerQuarterNote;
37 std::vector<std::vector<Note>> _note;
38 std::vector<Clef> _clef;
48 Measure(
const int numStaves = 1,
const int divisionsPerQuarterNote = 256);
60 void setKey(
int fifthCircle,
bool isMajorMode =
true);
104 void setMetronome(
const int bpm,
const RhythmFigure duration = RhythmFigure::QUARTER);
156 void addNote(
const Note& note,
const int staveId = 0,
int position = -1);
164 void addNote(
const std::vector<Note>& noteVec,
const int staveId = 0,
int position = -1);
172 void addNote(
const std::string& pitchClass,
const int staveId = 0,
int position = -1);
180 void addNote(
const std::vector<std::string>& pitchClassVec,
const int staveId = 0,
360 const Note&
getNote(
const int noteId,
const int staveId = 0)
const;
495 const std::string
toXML(
const int instrumentId = 1,
const int identSize = 2)
const;
Represents a barline in a musical score, including style, direction, and location.
Definition: barline.h:12
Represents a musical clef for a staff, including sign, line, and change status.
Definition: clef.h:19
Represents a musical key signature (tonality), including circle of fifths and mode (major/minor).
Definition: key.h:11
Represents a musical measure (bar) within a score, containing notes, staves, key/time signatures,...
Definition: measure.h:23
int getFreeDurationTicks(const int staveId=0) const
Returns the free (remaining) duration in ticks for a staff.
void removeRepeatStart()
Removes the repeat start from the left barline.
void removeRepeatEnd()
Removes the repeat end from the right barline.
int getDurationTicks() const
Returns the total duration of the measure in ticks.
int getNumNotesOff(const int staveId) const
Returns the number of rest notes (note off) in a specific staff.
bool timeSignatureChanged() const
Returns true if the time signature changes in this measure.
bool isClefChanged() const
Returns true if any clef changes in this measure.
bool metronomeChanged() const
Returns true if the metronome mark changes in this measure.
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.
void setRepeatEnd()
Sets the right barline as a repeat end.
void setRepeatStart()
Sets the left barline as a repeat start.
void clear()
Removes all notes and resets measure state.
bool keySignatureChanged() const
Returns true if the key signature changes in this measure.
bool isMajorKeyMode() const
Returns true if the key mode is major.
bool isEmpty() const
Returns true if the measure contains no notes in any staff.
void setIsDivisionsPerQuarterNoteChanged(bool isDivisionsPerQuarterNoteChanged=false)
Sets whether the divisions per quarter note changes in this measure.
const std::string getKeySignature() const
Returns the key signature as a string (e.g., "C", "Gm").
const std::string toJSON() const
Serializes the measure to JSON format.
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.
void setIsKeySignatureChanged(bool isKeySignatureChanged=false)
Sets whether the key signature changes in this measure.
void setKeyMode(const bool isMajorKeyMode)
Sets the key mode (major or minor) for the measure.
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.
const Note & getNote(const int noteId, const int staveId=0) const
Returns a const reference to a note in a specific staff and position.
int getNumNotesOff() const
Returns the number of rest notes (note off) in the measure (all staves).
void addNote(const Note ¬e, const int staveId=0, int position=-1)
Adds a note to a specific staff and position in the measure.
Measure(const int numStaves=1, const int divisionsPerQuarterNote=256)
Constructs a Measure with a given number of staves and rhythmic division.
void setTimeSignature(const int upper, const int lower)
Sets the time signature for the measure.
void setNumStaves(const int numStaves)
Sets the number of staves in the measure.
Clef & getClef(const int clefId=0)
Returns the clef for a specific staff (modifiable).
void setKeySignature(const int fifthCircle, const bool isMajorMode=true)
Sets the key signature for the measure.
const std::string toXML(const int instrumentId=1, const int identSize=2) const
Serializes the measure to MusicXML format.
const Barline & getBarlineLeft() const
Returns the left barline object.
Barline & getBarlineRight()
Returns the right barline object (modifiable).
Fraction getFractionDuration() const
Returns the duration of the measure as a Fraction object.
void info() const
Prints summary information about the measure to the log.
int getFilledDurationTicks(const int staveId=0) const
Returns the filled duration (sum of note durations) in ticks for a staff.
void setDivisionsPerQuarterNote(const int divisionsPerQuarterNote)
Sets the divisions per quarter note for the measure.
const TimeSignature & getTimeSignature() const
Returns the TimeSignature object for the measure.
Key getKey() const
Returns the Key object for the measure.
Note & getNoteOff(const int noteOffId, const int staveId=0)
Returns a reference to a rest note (note off) by index and staff.
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.
void setIsMetronomeChanged(bool isMetronomeChanged=false)
Sets whether the metronome mark changes in this measure.
int getEmptyDurationTicks() const
Returns the empty (unfilled) duration in ticks for the measure.
int getNumNotesOn() const
Returns the number of sounding notes (note on) in the measure (all staves).
int getNumNotesOn(const int staveId) const
Returns the number of sounding notes (note on) in a specific staff.
void setKey(int fifthCircle, bool isMajorMode=true)
Sets the key signature for the measure.
int getNumber() const
Returns the measure number.
int getNumNotes() const
Returns the total number of notes in the measure (all staves).
void setNumber(const int measureNumber)
Sets the measure number.
const Clef & getClef(const int clefId=0) const
Returns the clef for a specific staff.
void setMetronome(const int bpm, const RhythmFigure duration=RhythmFigure::QUARTER)
Sets the metronome mark (BPM and rhythm figure) for the measure.
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.
int getNumStaves() const
Returns the number of staves in the measure.
std::vector< Clef > & getClefs()
Returns the clefs for all staves in the measure (modifiable).
int getFifthCircle() const
Returns the number of accidentals in the circle of fifths for the key signature.
int getDivisionsPerQuarterNote() const
Returns the divisions per quarter note for the measure.
Note & getNoteOn(const int noteOnId, const int staveId=0)
Returns a reference to a sounding note (note on) by index and staff.
const std::vector< Clef > & getClefs() const
Returns the clefs for all staves in the measure.
const Barline & getBarlineRight() const
Returns the right barline object.
Note & getNote(const int noteId, const int staveId=0)
Returns a reference to a note in a specific staff and position.
void setIsTimeSignatureChanged(bool isTimeSignatureChanged=false)
Sets whether the time signature changes in this measure.
float getFilledQuarterDuration(const int staveId=0) const
Returns the filled duration (sum of note durations) in quarter notes for a staff.
Barline & getBarlineLeft()
Returns the left barline object (modifiable).
void removeNote(const int noteId, const int staveId=0)
Removes a note from a specific staff and position.
float getQuarterDuration() const
Returns the total duration of the measure in quarter notes.
int getNumNotes(const int staveId) const
Returns the number of notes in a specific staff.
float getFreeQuarterDuration(const int staveId=0) const
Returns the free (remaining) duration in quarter notes for a staff.
bool divisionsPerQuarterNoteChanged() const
Returns true if the divisions per quarter note changes in this measure.
std::string getKeyName() const
Returns the key name (e.g., "C major", "G minor").
std::pair< std::string, int > getMetronome() const
Returns the metronome mark as a pair (figure, value).
Represents a musical note, including pitch, duration, articulation, and MusicXML-related attributes.
Definition: note.h:19
Represents a musical time signature (meter) for a measure.
Definition: time-signature.h:20