20 #ifndef SCORE_ELEMENTS_H 21 #define SCORE_ELEMENTS_H 28 #include <csutil/hash.h> 43 #define MEAS_ELEM_NOTES_CAPACITY_GROWTH 4 44 #define UNDEFINED_MEASURE_ATTRIBUTE -100 107 csHash<csHash<psMusic::Accidental, char>,
int> prevAccidentals;
263 bool IsRest()
const {
return notes.GetSize() == 0; }
271 bool RemoveNote(
char name,
int octave);
288 typedef csArrayCapacityFixedGrow<MEAS_ELEM_NOTES_CAPACITY_GROWTH> NotesArrayCapacity;
289 csArray<Note, csArrayElementHandler<Note>, CS::Container::ArrayAllocDefault,
290 NotesArrayCapacity> notes;
298 template<
typename MeasureElementType>
351 bool IsUndefined()
const;
435 void Fit(
const MeasureAttributes*
const attributes);
450 MeasureElementType &
GetElement(
size_t n) {
return elements[n]; }
455 const MeasureElementType &
GetElement(
size_t n)
const {
return elements[n]; }
479 void InsertElement(
size_t n,
const MeasureElementType &element);
486 bool IsEmpty()
const {
return elements.GetSize() == 0; }
517 return elements.Push(element);
527 void SetBeat(
int beats,
int beatType);
534 void SetEnding(
bool isEnding);
539 void SetFifths(
int fifths);
547 void SetNEndRepeat(
int nEndRepeat);
554 void SetStartRepeat(
bool isStartRepeat);
559 void SetTempo(
int tempo);
565 csArray<MeasureElementType> elements;
571 MeasureAttributes* attributes;
576 void CreateAttributes();
581 void DeleteAttributes();
586 void UpdateAttributes();
621 int GetNPerformedRepeats(
int measureID)
const;
630 int RestoreLastStartRepeat();
650 int lastStartRepeatID;
662 csHash<int, int> repeatsDone;
665 #include "scoreelements.hpp" 669 #endif // SCORE_ELEMENTS_H A measure containing measure elements.
int GetBeats() const
Get the numerator of the time signature.
bool IsEnding() const
Return true if this is an ending measure.
bool IsStartRepeat() const
Return true if this measure starts a repeat section.
void SetBeatType(int beatType)
Set the denominator of the time signature.
psMusic::Accidental GetPlayedAccidental(const ScoreContext &context) const
Get the accidental of the played note.
Measure< MeasureElement >::MeasureAttributes measureAttributes
Attributes specified in the score up to now.
Note()
Default constructor.
void SetBeats(int beats)
Set the numerator of the time signature.
bool IsRest() const
Return whether this element is a rest or not.
bool IsEmpty() const
Check if the measure has at least one element.
A single note in a musical score.
int GetTempo() const
Get the tempo.
const Note & GetNote(size_t n) const
int GetBeatType() const
Get the denominator of the time signature.
void UpdateContext(const MeasureElement &element)
Update the list of previous accidental with all the notes in the given measure element.
void SetRest()
Set this element to be a rest.
Duration
The number associated to each duration is the number of quarter divisions as specified in DURATION_QU...
psMusic::Accidental GetPreviousAccidental(const Note ¬e) const
Get an eventual accidental that previously appeared in the same measure.
Note & GetNote(size_t n)
Return the n-th note in the element.
bool operator==(const Note ¬e) const
Equal operator.
bool IsEndRepeat() const
Return true if this measure ends a repeat section.
void SetDuration(psMusic::Duration duration)
Set the duration of this element.
Note::NoteContext noteContext
Used to keep track of previous accidentals in the same measure.
MeasureElementType & GetElement(size_t n)
Get the element at position n.
int GetNEndRepeat() const
Get the number of time the repeat at the end of this measure must be performed.
int GetOctave() const
Get the note octave number.
size_t PushElement(const MeasureElementType &element)
Push a copy of the given element after all the elements currently in the measure. ...
size_t GetNNotes() const
Get the number of notes in this chord.
size_t GetNElements() const
Get the number of elements in this measure.
void DeleteAllElements()
Delete all elements from the measure.
This is used to keep track of everything needed to play a score and provide some utility functions fo...
void SetOctave(int octave)
Set the note octave number.
int GetFifths() const
Get the tonality as the number of accidentals in the key signature.
bool GetAttributes(iDocument *musicalScore, int &quarterDivisions, int &fifths, int &beats, int &beatType, int &tempo)
Gets the attributes in the first measure of the given score.
psMusic::Accidental GetWrittenAccidental() const
Get the written accidental.
void SetTempo(int tempo)
Set the tempo.
void SetWrittenAccidental(psMusic::Accidental accidental)
Set the written accidental.
const MeasureElementType & GetElement(size_t n) const
Get the element at position n.
void SetFifths(int fifths)
Set the key signature as the number of accidentals.
Used to keep track of previous altered notes in the current measure.
psMusic::Duration GetDuration()
Get the duration of this element.
NoteContext()
Constructor.
void DeleteElement(size_t n)
Delete the element in position n.
An element of a measure with a given duration.
void SetName(char name)
Set the note name.
char GetName() const
Get the note name.
Keep general attributes that can change from a measure to another like key signature, beats and tempo.
void ResetContext()
Empty the list of previously altered note.