21 int _divisionsPerQuarterNote;
24 std::string _partName;
25 std::string _shortName;
26 std::vector<Measure> _measure;
27 std::vector<int> _midiUnpitched;
35 void appendNote(
const Note& note,
const int position = -1,
const int staveId = 0);
43 void appendNotes(
const std::vector<Note>& notes,
const int position = -1,
44 const int staveId = 0);
52 void appendChord(
const Chord& chord,
const int position = -1,
const int staveId = 0);
60 void appendChords(
const std::vector<Chord>& chords,
const int position = -1,
61 const int staveId = 0);
71 Part(
const std::string& partName,
const int numStaves = 1,
const bool isPitched =
true,
72 const int divisionsPerQuarterNote = 256);
120 void append(
const std::variant<Note, Chord>& obj,
const int position = -1,
121 const int staveId = 0);
129 void append(
const std::vector<std::variant<Note, Chord>>& objs,
const int position = -1,
130 const int staveId = 0);
263 const std::string
toXML(
const int instrumentId = 1,
const int identSize = 2)
const;
Represents a musical chord.
Definition: chord.h:70
Represents a musical measure (bar) within a score, containing notes, staves, key/time signatures,...
Definition: measure.h:23
Represents a musical note, including pitch, duration, articulation, and MusicXML-related attributes.
Definition: note.h:19
Represents a musical part (instrument or voice) in a score, containing measures, staves,...
Definition: part.h:17
void append(const std::variant< Note, Chord > &obj, const int position=-1, const int staveId=0)
Appends a Note or Chord (variant) to the part at a given position and staff.
void removeMeasure(const int measureStart, const int measureEnd)
Removes a range of measures from the part.
void addStaves(const int numStaves=1)
Adds additional staves to the part.
Measure & getMeasure(const int measureId)
Returns a reference to a measure by its index.
const std::vector< Measure > getMeasures() const
Returns a vector of all measures in the part.
int getNumNotesOff(const int staveId=-1)
Returns the number of rest notes (note off) in the part (optionally for a specific staff).
std::string toJSON() const
Serializes the part to JSON format.
int getNumNotesOn(const int staveId=-1)
Returns the number of sounding notes (note on) in the part (optionally for a specific staff).
int getNumMeasures() const
Returns the number of measures in the part.
int getStaffLines() const
Returns the number of staff lines.
void setNumStaves(const int numStaves)
Sets the number of staves for the part.
Part(const std::string &partName, const int numStaves=1, const bool isPitched=true, const int divisionsPerQuarterNote=256)
Constructs a Part with a given name, number of staves, pitch type, and rhythmic division.
void removeStave(const int staveId)
Removes a staff from the part by its index.
bool isPitched() const
Returns true if the part is pitched (not percussion).
const std::string toXML(const int instrumentId=1, const int identSize=2) const
Serializes the part to MusicXML format.
const Measure & getMeasure(const int measureId) const
Returns a const reference to a measure by its index.
std::vector< int > getMidiUnpitched() const
Returns the MIDI numbers for unpitched percussion instruments.
void info() const
Prints summary information about the part to the log.
void setStaffLines(const int staffLines=5)
Sets the number of staff lines for the part.
void addMidiUnpitched(const int midiUnpitched)
Adds a MIDI number for an unpitched percussion instrument.
void addMeasure(const int numMeasures)
Adds a specified number of measures to the part.
void append(const std::vector< std::variant< Note, Chord > > &objs, const int position=-1, const int staveId=0)
Appends multiple Note or Chord variants to the part at a given position and staff.
void clear()
Removes all measures and resets the part.
int getNumStaves() const
Returns the number of staves in the part.
void setShortName(const std::string &shortName)
Sets the short name (abbreviation) for the part.
const std::string & getName() const
Returns the full name of the part.
int getPartIndex() const
Returns the index of the part in the score.
void setIsPitched(const bool isPitched=true)
Sets whether the part is pitched (true) or unpitched (false).
void setPartIndex(int partIdx)
Sets the index of the part in the score.
const std::string & getShortName() const
Returns the short name (abbreviation) of the part.
int getNumNotes(const int staveId=-1)
Returns the number of notes in the part (optionally for a specific staff).