MUSX Document Model
Loading...
Searching...
No Matches
Entries.h
1/*
2 * Copyright (C) 2025, Robert Patterson
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22#pragma once
23
24#include <tuple>
25#include <map>
26
27#include "musx/util/Fraction.h"
28#include "BaseClasses.h"
29#include "CommonClasses.h"
30 // do not add other dom class dependencies. Use Implementations.h for implementations that need total class access.
31
32namespace music_theory {
33enum class NoteName : int;
34class Transposer;
35} // namespace music_theory
36
37namespace musx {
38namespace dom {
39
40namespace others {
41class Frame;
42class PercussionNoteInfo;
43class Staff;
44class StaffComposite;
45class StaffUsed;
46} // namespace others
47
48namespace details {
49class TupletDef;
50class GFrameHold;
51
60public:
69 GFrameHoldContext(const DocumentPtr& document, Cmper partId, Cmper staffId, Cmper meas);
70
76 Cmper getRequestedPartId() const { return m_requestedPartId; }
77
83 const GFrameHold* operator->() const { return m_hold.get(); }
84
90 explicit operator bool() const { return static_cast<bool>(m_hold); }
91
95 ClefIndex calcClefIndexAt(Edu position) const;
96
101 { return calcClefIndexAt(position.calcEduDuration()); }
102
108 std::shared_ptr<const EntryFrame> createEntryFrame(LayerIndex layerIndex) const;
109
117 bool iterateEntries(LayerIndex layerIndex, std::function<bool(const EntryInfoPtr&)> iterator) const;
118
124 bool iterateEntries(std::function<bool(const EntryInfoPtr&)> iterator) const;
125
128 std::map<LayerIndex, bool> calcVoices() const;
129
132 bool calcIsCuesOnly(bool includeVisibleInScore = false) const;
133
140 EntryInfoPtr calcNearestEntry(Edu eduPosition, bool findExact = true, std::optional<LayerIndex> matchLayer = std::nullopt, std::optional<bool> matchVoice2 = std::nullopt) const;
141
142private:
146 std::pair<MusxInstance<others::Frame>, Edu> findLayerFrame(LayerIndex layerIndex) const;
147
149 Cmper m_requestedPartId;
150};
151
152} // namespace details
153
163std::pair<NoteType, unsigned> calcNoteInfoFromEdu(Edu duration);
164
166unsigned calcNumberOfBeamsInEdu(Edu duration);
167
174class Note : public Base
175{
176public:
178 explicit Note(const DocumentWeakPtr& document, NoteNumber noteId)
179 : Base(document, 0, ShareMode::All), m_noteId(noteId)
180 {
181 }
182
184 static constexpr NoteNumber RESTID = 31;
185
193 using NoteProperties = std::tuple<music_theory::NoteName, int, int, int>;
194
195 int harmLev{};
196 int harmAlt{};
197 bool isValid{};
198 bool tieStart{};
199 bool tieEnd{};
200 bool crossStaff{};
205 bool upSplitStem{};
207 bool showAcci{};
208 bool parenAcci{};
209 bool noPlayback{};
210 bool noSpacing{};
211 bool freezeAcci{};
213
216 NoteNumber getNoteId() const { return m_noteId; }
217
228 std::pair<int, int> calcDefaultEnharmonic(const MusxInstance<KeySignature>& key) const;
229
256 const MusxInstance<others::PercussionNoteInfo>& percNoteInfo, const MusxInstance<others::Staff>& staff = nullptr, bool respellEnharmonic = false) const;
257
259
260private:
261 NoteNumber m_noteId{};
262};
263
270class Entry : public Base
271{
272public:
277 explicit Entry(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, EntryNumber entnum, EntryNumber prev, EntryNumber next)
278 : Base(document, partId, shareMode), m_entnum(entnum), m_prev(prev), m_next(next)
279 {
280 }
281
291 int numNotes{};
293 bool isValid{};
294 bool isNote{};
295 bool v2Launch{};
296 bool voice2{};
297 bool createdByHP{};
299 bool graceNote{};
300 bool noteDetail{};
301 bool articDetail{};
302 bool lyricDetail{};
303 bool tupletStart{};
304 bool splitRest{};
306 bool floatRest{};
307 bool isHidden{};
308 bool beamExt{};
309 bool flipTie{};
310 bool dotTieAlt{};
311 bool beam{};
312 bool secBeam{};
313 bool freezeStem{};
314 bool stemDetail{};
315 bool crossStaff{};
318 bool doubleStem{};
319 bool splitStem{};
321 bool upStem{};
322 bool checkAccis{};
323 bool dummy{};
326 bool noLeger{};
327 bool sorted{};
328 bool slashGrace{};
331 bool flatBeam{};
332 bool noPlayback{};
333 bool noSpacing{};
334 bool freezeBeam{};
335
337 std::vector<std::shared_ptr<Note>> notes;
338
340 EntryNumber getEntryNumber() const { return m_entnum; }
341
346
351
355 std::pair<NoteType, unsigned> calcNoteInfo() const { return calcNoteInfoFromEdu(duration); }
356
361
364 bool hasStem() const { return duration < Edu(NoteType::Whole); }
365
371 { return !isNote && !isHidden && !voice2 && duration == Edu(NoteType::Whole); }
372
373 void integrityCheck(const std::shared_ptr<Base>& ptrToThis) override
374 {
375 this->Base::integrityCheck(ptrToThis);
376 if (size_t(numNotes) != notes.size()) {
377 MUSX_INTEGRITY_ERROR("Entry " + std::to_string(m_entnum) + " has an incorrect number of notes.");
378 }
379 }
380
381 constexpr static std::string_view XmlNodeName = "entry";
383
384private:
385 EntryNumber m_entnum;
386 EntryNumber m_prev;
387 EntryNumber m_next;
388};
389
390class EntryInfo;
391class EntryFrame;
392class NoteInfoPtr;
393
398{
399public:
401 EntryInfoPtr() : m_entryFrame(nullptr), m_indexInFrame(0) {}
402
408 explicit EntryInfoPtr(const std::shared_ptr<const EntryFrame>& entryFrame, size_t index = 0)
409 : m_entryFrame(entryFrame), m_indexInFrame(index) {}
410
418 static EntryInfoPtr fromPositionOrNull(const DocumentPtr& document, Cmper partId, StaffCmper staffId, MeasCmper measureId, EntryNumber entryNumber);
419
421 const std::shared_ptr<const EntryInfo> operator->() const;
422
424 operator bool() const;
425
428 bool isSameEntry(const EntryInfoPtr& src) const;
429
431 std::shared_ptr<const EntryFrame> getFrame() const { return m_entryFrame; }
432
434 size_t getIndexInFrame() const { return m_indexInFrame; }
435
438
440 StaffCmper getStaff() const;
441
444 MusxInstance<others::StaffComposite> createCurrentStaff(const std::optional<StaffCmper>& forStaffId = std::nullopt) const;
445
447 MeasCmper getMeasure() const;
448
451
453 unsigned calcReverseGraceIndex() const;
454
456 std::optional<size_t> calcNextTupletIndex(std::optional<size_t> currentIndex) const;
457
460
464
469
473
476
481
487 EntryInfoPtr getNextInVoice(int voice) const;
488
494 EntryInfoPtr getPreviousInVoice(int voice) const;
495
497 EntryInfoPtr getNextInBeamGroup(bool includeHiddenEntries = false) const
498 { return iterateBeamGroup<&EntryInfoPtr::nextPotentialInBeam, &EntryInfoPtr::previousPotentialInBeam>(includeHiddenEntries); }
499
501 EntryInfoPtr getPreviousInBeamGroup(bool includeHiddenEntries = false) const
502 { return iterateBeamGroup<&EntryInfoPtr::previousPotentialInBeam, &EntryInfoPtr::nextPotentialInBeam>(includeHiddenEntries); }
503
506 bool calcDisplaysAsRest() const;
507
511 std::pair<int, int> calcTopBottomStaffPositions() const;
512
516 bool calcUpStemDefault() const;
517
532 bool calcUpStem() const;
533
536 bool calcUnbeamed() const;
537
539 bool calcIsBeamStart() const;
540
545 bool calcIsFeatheredBeamStart(Evpu& outLeftY, Evpu& outRightY) const;
546
552
556
558 unsigned calcNumberOfBeams() const;
559
562 unsigned calcLowestBeamStart() const;
563
566 unsigned calcLowestBeamEnd() const;
567
570 unsigned calcLowestBeamStub() const;
571
577 bool calcBeamStubIsLeft() const;
578
581
584
586 bool canBeBeamed() const;
587
590 int calcEntrySize() const;
591
597 bool calcIsCue(bool includeVisibleInScore = false) const;
598
601 bool calcIsFullMeasureRest() const;
602
606 bool calcIsBeamedRestWorkaroud() const;
607
610 std::vector<size_t> findTupletInfo() const;
611
615 bool calcIfLayerSettingsApply() const;
616
627
629 bool operator<(const EntryInfoPtr& other) const
630 {
631 if (m_entryFrame != other.m_entryFrame)
632 return m_entryFrame < other.m_entryFrame;
633 return m_indexInFrame < other.m_indexInFrame;
634 }
635
636private:
637 unsigned calcVisibleBeams() const;
638
639 template<EntryInfoPtr(EntryInfoPtr::* Iterator)() const>
640 std::optional<unsigned> iterateFindRestsInSecondaryBeam(const EntryInfoPtr nextOrPrevInBeam) const;
641
642 template<EntryInfoPtr(EntryInfoPtr::* Iterator)() const>
643 EntryInfoPtr iteratePotentialEntryInBeam() const;
644
645 template<EntryInfoPtr(EntryInfoPtr::* Iterator)() const>
646 bool iterateNotesExistLeftOrRight() const;
647
648 EntryInfoPtr nextPotentialInBeam(bool includeHiddenEntries) const;
649
650 EntryInfoPtr previousPotentialInBeam(bool includeHiddenEntries) const;
651
652 template<EntryInfoPtr(EntryInfoPtr::* Iterator)(bool) const, EntryInfoPtr(EntryInfoPtr::* ReverseIterator)(bool) const>
653 EntryInfoPtr iterateBeamGroup(bool includeHiddenEntries) const;
654
655 std::shared_ptr<const EntryFrame> m_entryFrame;
656 size_t m_indexInFrame{};
657
659 mutable MusxInstance<others::StaffComposite> m_cachedStaff;
660};
661
668class EntryFrame : public std::enable_shared_from_this<EntryFrame>
669{
670public:
678 explicit EntryFrame(const details::GFrameHoldContext& gfhold, LayerIndex layerIndex, util::Fraction timeStretch, const MusxInstance<others::StaffComposite>& startStaff) :
679 m_context(gfhold),
680 m_layerIndex(layerIndex),
681 m_timeStretch(timeStretch),
682 m_startStaff(startStaff)
683 {
684 }
685
688 {
690 size_t startIndex;
691 size_t endIndex;
694 bool voice2;
695
697 TupletInfo(const std::weak_ptr<const EntryFrame>& parent, const MusxInstance<details::TupletDef>& tup, size_t index, util::Fraction start, bool forVoice2)
698 : tuplet(tup), startIndex(index), endIndex((std::numeric_limits<size_t>::max)()),
699 startDura(start), endDura(-1), voice2(forVoice2), m_parent(parent)
700 {}
701
703 size_t numEntries() const
704 {
705 MUSX_ASSERT_IF(startIndex > endIndex) {
706 throw std::logic_error("TupletInfo has invalid start and end indices.");
707 }
708 return endIndex - startIndex + 1;
709 }
710
713 bool includesEntry(const EntryInfoPtr& entryInfo) const
714 {
715 const size_t x = entryInfo.getIndexInFrame();
716 return (x >= startIndex && x <= endIndex);
717 }
718
730 bool calcIsTremolo() const;
731
745 bool calcCreatesSingletonRight() const { return calcCreatesSingleton(false); }
746
756 bool calcCreatesSingletonLeft() const { return calcCreatesSingleton(true); }
757
767
777
788 // - the independent display time signature matches the tuplet's total display duration
789 bool calcCreatesTimeStretch() const;
790
791 private:
792 bool calcCreatesSingleton(bool left) const;
793
794 const std::shared_ptr<const EntryFrame> getParent() const
795 {
796 auto result = m_parent.lock();
797 MUSX_ASSERT_IF(!result) {
798 throw std::logic_error("Unable to obtain lock on parent entry frame.");
799 }
800 return result;
801 }
802
803 const std::weak_ptr<const EntryFrame> m_parent;
804 };
805
812 std::vector<TupletInfo> tupletInfo;
814
816 DocumentPtr getDocument() const;
817
819 const details::GFrameHoldContext& getContext() const { return m_context; }
820
822 Cmper getRequestedPartId() const { return m_context.getRequestedPartId(); }
823
825 StaffCmper getStaff() const;
826
828 MeasCmper getMeasure() const;
829
831 LayerIndex getLayerIndex() const { return m_layerIndex; }
832
835
838 util::Fraction getTimeStretch() const { return m_timeStretch; }
839
841 const std::vector<std::shared_ptr<const EntryInfo>>& getEntries() const
842 { return m_entries; }
843
847 EntryInfoPtr getFirstInVoice(int voice) const;
848
852 EntryInfoPtr getLastInVoice(int voice) const;
853
855 void addEntry(const std::shared_ptr<const EntryInfo>& entry)
856 { m_entries.emplace_back(entry); }
857
860 std::shared_ptr<const EntryFrame> getNext() const;
861
864 std::shared_ptr<const EntryFrame> getPrevious() const;
865
869
873 MusxInstance<others::StaffComposite> createCurrentStaff(Edu eduPosition, const std::optional<StaffCmper>& forStaffId = std::nullopt) const;
874
877
883 bool calcIsCueFrame(bool includeVisibleInScore = false) const;
884
891
892private:
894 LayerIndex m_layerIndex;
895 util::Fraction m_timeStretch;
896
897 std::vector<std::shared_ptr<const EntryInfo>> m_entries;
898
901
903 mutable MusxInstance<others::LayerAttributes> m_cachedLayerAttributes;
904};
905
906namespace details {
907class GFrameHold;
908} // namespace details
909
919{
924 explicit EntryInfo(const MusxInstance<Entry>& entry)
925 : m_entry(entry) {}
926
927#ifndef DOXYGEN_SHOULD_IGNORE_THIS
929#endif
930
931public:
936 unsigned graceIndex{};
940
944 {
945 auto retval = m_entry.lock();
946 if (!retval) {
947 throw std::logic_error("Entry pointer is no longer valid");
948 }
949 return retval;
950 }
951
955
956private:
958};
959
962{
963public:
965 NoteInfoPtr() : m_entry(), m_noteIndex(0) {}
966
970 NoteInfoPtr(const EntryInfoPtr& entryInfo, size_t noteIndex)
971 : m_entry(entryInfo), m_noteIndex(noteIndex)
972 {}
973
975 operator bool() const
976 { return m_entry && m_noteIndex < m_entry->getEntry()->notes.size(); }
977
979 bool isSameNote(const NoteInfoPtr& src) const
980 { return m_entry.isSameEntry(src.m_entry) && m_noteIndex == src.m_noteIndex; }
981
985 NoteInfoPtr findEqualPitch(const EntryInfoPtr& entry) const;
986
989 {
990 MUSX_ASSERT_IF(m_noteIndex >= m_entry->getEntry()->notes.size()) {
991 throw std::logic_error("Note index is too large for notes array.");
992 }
993 return m_entry->getEntry()->notes[m_noteIndex];
994 }
995
998 { return m_entry; }
999
1012 Note::NoteProperties calcNoteProperties(const std::optional<bool>& enharmonicRespell = std::nullopt, bool alwaysUseEntryStaff = false) const;
1013
1021 Note::NoteProperties calcNotePropertiesConcert(bool alwaysUseEntryStaff = false) const;
1022
1030 Note::NoteProperties calcNotePropertiesInView(bool alwaysUseEntryStaff = false) const;
1031
1035
1039
1043 NoteInfoPtr calcTieTo() const;
1044
1049 NoteInfoPtr calcTieFrom(bool requireTie = true) const;
1050
1052 StaffCmper calcStaff() const;
1053
1056 std::unique_ptr<music_theory::Transposer> createTransposer() const;
1057
1061 {
1062 if (m_noteIndex >= m_entry->getEntry()->notes.size()) {
1063 return NoteInfoPtr();
1064 }
1065 return NoteInfoPtr(m_entry, m_noteIndex + 1);
1066 }
1067
1071 {
1072 if (m_noteIndex <= 0) {
1073 return NoteInfoPtr();
1074 }
1075 return NoteInfoPtr(m_entry, m_noteIndex - 1);
1076 }
1077
1079 bool calcIsEnharmonicRespell() const;
1080
1090 std::pair<int, int> calcDefaultEnharmonic() const
1091 { return (*this)->calcDefaultEnharmonic(m_entry.getKeySignature()); }
1092
1103
1105 bool operator<(const NoteInfoPtr& other) const
1106 {
1107 if (m_entry != other.m_entry)
1108 return m_entry < other.m_entry;
1109 return m_noteIndex < other.m_noteIndex;
1110 }
1111
1112private:
1116 bool isSamePitch(const NoteInfoPtr& src) const;
1117
1121 bool isSamePitchValues(const NoteInfoPtr& src) const;
1122
1123 EntryInfoPtr m_entry;
1124 size_t m_noteIndex;
1125};
1126
1127} // namespace dom
1128} // namespace entries
Base class to enforce polymorphism across all DOM classes.
Definition BaseClasses.h:83
virtual void integrityCheck(const std::shared_ptr< Base > &ptrToThis)
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition BaseClasses.h:154
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:91
Wraps a reference to an existing object or owns a temporary value if needed.
Definition MusxInstance.h:179
Represents a vector of EntryInfo instances for a given frame, along with computed information.
Definition Entries.h:669
util::Fraction getTimeStretch() const
Get the time stretch in this frame. Rather than accessing this value directly, consider using EntryIn...
Definition Entries.h:838
EntryFrame(const details::GFrameHoldContext &gfhold, LayerIndex layerIndex, util::Fraction timeStretch, const MusxInstance< others::StaffComposite > &startStaff)
Constructor function.
Definition Entries.h:678
EntryInfoPtr getLastInVoice(int voice) const
Returns the last entry in the specified v1/v2 or null if none.
Definition Entries.cpp:112
MusxInstance< others::StaffComposite > getStartStaffInstance() const
Gets the staff at eduPosition 0 without needing to create it again.
Definition Entries.h:867
bool calcAreAllEntriesHiddenInFrame() const
Calculates if this all notes in the frame are hidden. This routine only checks that entries are indiv...
Definition Entries.cpp:170
MeasCmper getMeasure() const
Get the measure for the entry frame.
Definition Entries.cpp:86
MusxInstance< others::Measure > getMeasureInstance() const
Get the measure instance.
Definition Entries.cpp:149
std::shared_ptr< const EntryFrame > getPrevious() const
Gets the entry frame for the previous measure with the same staff and layer.
Definition Entries.cpp:130
void addEntry(const std::shared_ptr< const EntryInfo > &entry)
Add an entry to the list.
Definition Entries.h:855
const std::vector< std::shared_ptr< const EntryInfo > > & getEntries() const
Get the entry list.
Definition Entries.h:841
EntryInfoPtr getFirstInVoice(int voice) const
Returns the first entry in the specified v1/v2 or null if none.
Definition Entries.cpp:96
StaffCmper getStaff() const
Get the staff for the entry.
Definition Entries.cpp:84
Cmper getRequestedPartId() const
Get the requested part ID for the entry frame.
Definition Entries.h:822
MusxInstance< others::StaffComposite > createCurrentStaff(Edu eduPosition, const std::optional< StaffCmper > &forStaffId=std::nullopt) const
Creates a current StaffComposite for the entry frame.
Definition Entries.cpp:140
MusxInstance< KeySignature > keySignature
this can be different than the measure key sig if the staff has independent key signatures
Definition Entries.h:813
MusxInstance< others::LayerAttributes > getLayerAttributes() const
Get the LayerAttributes for this entry frame.
Definition Entries.cpp:88
const details::GFrameHoldContext & getContext() const
Get the frame context for this frame.
Definition Entries.h:819
LayerIndex getLayerIndex() const
Get the layer index (0..3) of the entry frame.
Definition Entries.h:831
DocumentPtr getDocument() const
Get the document for the entry frame.
Definition Entries.cpp:82
std::vector< TupletInfo > tupletInfo
A list of the tuplets in the frame and their calculated starting and ending information.
Definition Entries.h:812
std::shared_ptr< const EntryFrame > getNext() const
Gets the entry frame for the next measure with the same staff and layer.
Definition Entries.cpp:122
bool calcIsCueFrame(bool includeVisibleInScore=false) const
Calculates if this entry frame is part of a cue.
Definition Entries.cpp:154
Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ow...
Definition Entries.h:398
bool calcUpStemDefault() const
Calculates if the entry is upstem by default, without considering voices, layers, staff options,...
Definition Entries.cpp:614
EntryInfoPtr getNextInFrame() const
Get the next entry in the frame.
Definition Entries.cpp:503
EntryInfoPtr(const std::shared_ptr< const EntryFrame > &entryFrame, size_t index=0)
Constructor function.
Definition Entries.h:408
EntryInfoPtr getNextSameV() const
Get the next entry in the frame in the same voice.
Definition Entries.cpp:511
size_t getIndexInFrame() const
Returns the index within the frame.
Definition Entries.h:434
util::Fraction calcGlobalElapsedDuration() const
Calculates the elapsed duration in global edu, removing any time stretch due to independent time sign...
Definition Entries.cpp:983
bool calcIfLayerSettingsApply() const
Calculates whether the conditions are met for the layer attributes dependent on others::LayerAttribut...
Definition Entries.cpp:1208
EntryInfoPtr getPreviousInVoice(int voice) const
Returns the previous entry in the frame in the specified v1/v2 or null if none.
Definition Entries.cpp:573
unsigned calcReverseGraceIndex() const
Caclulates the grace index counting leftward (used by other standards such as MNX)
Definition Entries.cpp:465
bool canBeBeamed() const
Determines if this entry can be beamed.
Definition Entries.cpp:751
bool isSameEntry(const EntryInfoPtr &src) const
Returns whether the input and the current instance refer to the same entry.
Definition Entries.cpp:441
EntryInfoPtr getPreviousInLayer() const
Get the previous entry in the same layer and staff. This can be in the previous measure.
Definition Entries.cpp:529
EntryInfoPtr getNextInLayer() const
Get the next entry in the same layer and staff. This can be in the next measure.
Definition Entries.cpp:492
unsigned calcLowestBeamStub() const
Returns the lowest beam stub at this entry, where 2 = 16th note stub, 3 = 32nd note stub,...
Definition Entries.cpp:924
EntryInfoPtr getNextInBeamGroup(bool includeHiddenEntries=false) const
Gets the next entry in a beamed group or nullptr if the entry is not beamed or is the last in the gro...
Definition Entries.h:497
unsigned calcLowestBeamStart() const
Returns the lowest beam number starting at this entry, where 1 = 8th note beam, 2 = 16th note beam,...
Definition Entries.cpp:871
static EntryInfoPtr fromPositionOrNull(const DocumentPtr &document, Cmper partId, StaffCmper staffId, MeasCmper measureId, EntryNumber entryNumber)
Searches the given position at staffId and measureId for the entryNumber.
Definition Entries.cpp:410
EntryInfoPtr getPreviousInBeamGroup(bool includeHiddenEntries=false) const
Gets the previous entry in a beamed group or nullptr if the entry is not beamed or is the first in th...
Definition Entries.h:501
unsigned calcLowestBeamEnd() const
Returns the lowest beam number ending at this entry, where 1 = 8th note beam, 2 = 16th note beam,...
Definition Entries.cpp:901
LayerIndex getLayerIndex() const
Get the layer index (0..3) of the entry.
Definition Entries.cpp:449
unsigned calcNumberOfBeams() const
Calculates the number of beams or flags on the entry.
Definition Entries.cpp:820
EntryInfoPtr getPreviousInFrame() const
Get the previous entry in the frame.
Definition Entries.cpp:540
std::shared_ptr< const EntryFrame > getFrame() const
Returns the frame.
Definition Entries.h:431
bool calcUpStem() const
Determines the effective stem direction of the entry, taking into account voices, layers,...
Definition Entries.cpp:673
EntryInfoPtr findBeamStartOrCurrent() const
Finds the first entry of a beamed group or returns the current entry if it is not beams.
Definition Entries.cpp:771
bool calcDisplaysAsRest() const
Calculates if an entry displays as a rest.
Definition Entries.cpp:583
MusxInstance< KeySignature > getKeySignature() const
Get the key signature of the entry.
Definition Entries.cpp:455
bool calcIsCue(bool includeVisibleInScore=false) const
Calculates if this entry is part of a cue.
Definition Entries.cpp:1130
bool operator<(const EntryInfoPtr &other) const
Explicit operator< for std::map.
Definition Entries.h:629
std::pair< int, int > calcTopBottomStaffPositions() const
Calculates the top and bottom staff positions of the entry, taking into account percussion notes....
Definition Entries.cpp:589
StaffCmper getStaff() const
Get the staff cmper.
Definition Entries.cpp:451
EntryInfoPtr findBeamEnd() const
Finds the end entry of a beamed group.
Definition Entries.cpp:788
int calcEntrySize() const
Returns the entry size as a percentage, taking into account the beaming.
Definition Entries.cpp:1116
bool calcIsBeamStart() const
Returns whether this is the start of a primary beam.
Definition Entries.cpp:764
EntryInfoPtr getPreviousSameV() const
Get the previous entry in the frame in the same voice.
Definition Entries.cpp:548
int calcCrossStaffDirectionForAll(DeferredReference< MusxInstanceList< others::StaffUsed > > staffList={}) const
Calculates if this entry has cross-staffed notes all in a single direction.
Definition Entries.cpp:1249
MusxInstance< others::StaffComposite > createCurrentStaff(const std::optional< StaffCmper > &forStaffId=std::nullopt) const
Creates the current StaffComposite for the entry.
Definition Entries.cpp:457
EntryInfoPtr getNextInVoice(int voice) const
Returns the next entry in the frame in the specified v1/v2 or null if none.
Definition Entries.cpp:563
const std::shared_ptr< const EntryInfo > operator->() const
Allows -> access to the underlying EntryInfo instance.
Definition Entries.cpp:425
bool calcUnbeamed() const
Returns whether this is an unbeamed entry.
Definition Entries.cpp:742
EntryInfoPtr()
Default constructor.
Definition Entries.h:401
std::optional< size_t > calcNextTupletIndex(std::optional< size_t > currentIndex) const
Returns the next higher tuplet index that this entry starts, or std::nullopt if none.
Definition Entries.cpp:477
bool calcIsBeamedRestWorkaroud() const
A common workaround in Finale is to hide a rest in v1 and supply it in v2. Typically it is used when ...
Definition Entries.cpp:1164
bool calcBeamStubIsLeft() const
Calculates if a beam stub on this entry would go left or right. It does not check that an entry actua...
Definition Entries.cpp:934
bool calcIsFullMeasureRest() const
Returns whether this is a full measure rest.
Definition Entries.cpp:1156
util::Fraction calcGlobalActualDuration() const
Calculates the actual duration in global edu, removing any time stretch due to independent time signa...
Definition Entries.cpp:988
MeasCmper getMeasure() const
Get the measure cmper.
Definition Entries.cpp:453
std::vector< size_t > findTupletInfo() const
Finds the tuplet info for tuplets that include this entry.
Definition Entries.cpp:1194
bool calcIsFeatheredBeamStart(Evpu &outLeftY, Evpu &outRightY) const
Calculates if the entry starts a feathered beam and returns information about it if so.
Definition Entries.cpp:1081
Information an entry along with the entry.
Definition Entries.h:919
unsigned graceIndex
Definition Entries.h:936
ClefIndex clefIndex
the clef index in effect for the entry.
Definition Entries.h:938
util::Fraction calcNextElapsedDuration() const
Calculates the next duration position after this entry.
Definition Entries.h:953
util::Fraction elapsedDuration
Definition Entries.h:932
ClefIndex clefIndexConcert
the concert clef index in effect for the entry.
Definition Entries.h:939
util::Fraction actualDuration
Definition Entries.h:934
MusxInstance< Entry > getEntry() const
Get the entry.
Definition Entries.h:943
Represents an entry containing metadata and notes.
Definition Entries.h:271
bool splitStem
Definition Entries.h:319
bool upStem
Whether a stem is up or down. (Only reliable when freezeStem is true.)
Definition Entries.h:321
Entry(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, EntryNumber entnum, EntryNumber prev, EntryNumber next)
Constructor function.
Definition Entries.h:277
EntryNumber getEntryNumber() const
Gets the entry number for this entry.
Definition Entries.h:340
bool articDetail
Indicates there is an articulation on the entry.
Definition Entries.h:301
std::pair< NoteType, unsigned > calcNoteInfo() const
Calculates the NoteType and number of augmentation dots. (See calcNoteInfoFromEdu....
Definition Entries.h:355
bool isNote
If this value is false, the entry is a rest.
Definition Entries.h:294
bool noLeger
Hide ledger lines.
Definition Entries.h:326
bool freezeStem
Freeze stem flag (upStem gives the direction.)
Definition Entries.h:313
MusxInstance< Entry > getNext() const
Gets the next entry in this list or nullptr if none.
Definition Entries.cpp:36
bool noPlayback
Indicates that the entry should not be played back.
Definition Entries.h:332
bool voice2
This is a V2 note. (xml node <v2>)
Definition Entries.h:296
bool splitRest
Indicates that rests in different layers are not combined on this entry.
Definition Entries.h:304
bool beamExt
Indicates that there is a beam extension on the entry.
Definition Entries.h:308
bool createdByHP
Indicates the entry was created by Finale's smart playback engine.
Definition Entries.h:297
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Entries.h:381
MusxInstance< Entry > getPrevious() const
Gets the previous entry in this list or nullptr if none.
Definition Entries.cpp:46
bool secBeam
Signifies a secondary beam break occurs on the entry.
Definition Entries.h:312
bool stemDetail
Indicates there are stem modifications.
Definition Entries.h:314
bool slashGrace
Definition Entries.h:328
bool isValid
Should always be true but otherwise appears to be used internally by Finale.
Definition Entries.h:293
bool playDisabledByHP
Used by Finale's smart playback engine.
Definition Entries.h:298
bool flipTie
Indicates the existence of a flipped tie, either in Speedy Entry or Layer Attributes.
Definition Entries.h:309
bool flatBeam
Forces any beam that starts on this entry to be flat by default.
Definition Entries.h:331
Evpu hOffset
Manual offset created with the Note Position Tool. (xml node is <posi>.)
Definition Entries.h:292
std::vector< std::shared_ptr< Note > > notes
Collection of notes that comprise the entry. These are in order from lowest to highest.
Definition Entries.h:337
void integrityCheck(const std::shared_ptr< Base > &ptrToThis) override
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition Entries.h:373
bool dummy
Definition Entries.h:323
bool checkAccis
Used by Finale to convert pre-2014 .mus files. May never be saved in .musx.
Definition Entries.h:322
bool noteDetail
Indicates there is a note detail or EntrySize record for the entry.
Definition Entries.h:300
util::Fraction calcFraction() const
Calculates the duration as a util::Fraction of a whole note.
Definition Entries.h:360
static const xml::XmlElementArray< Entry > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool hasStem() const
Returns true if the entry's duration has a stem.
Definition Entries.h:364
bool crossStaff
Signifies that at least one note in the entry has been cross staffed.
Definition Entries.h:315
bool floatRest
Is floating rest. If false, the first note element gives the staff position of the rest.
Definition Entries.h:306
bool smartShapeDetail
Indicates this entry has a smart shape assignment.
Definition Entries.h:325
Edu duration
Duration of the entry, not taking into account tuplets.
Definition Entries.h:290
bool isHidden
Indicates the entry is hidden, (xml node is <ignore>)
Definition Entries.h:307
bool tupletStart
Indicates that a tuplet start on the entry.
Definition Entries.h:303
bool lyricDetail
Indicates there is a lyric assignment on the entry.
Definition Entries.h:302
int numNotes
Number of notes in the entry. There is an error if this is not the same as notes.size().
Definition Entries.h:291
bool sorted
Sorted flag.
Definition Entries.h:327
bool reverseDownStem
Indicates that a stem normally down is reversed.
Definition Entries.h:317
bool reverseUpStem
Indicates that a stem normally up is reversed.
Definition Entries.h:316
bool v2Launch
Indicates if this entry (which is voice1) launches a voice2 sequence. (xml node is <controller>)
Definition Entries.h:295
bool doubleStem
Creates a double stem on the entry. (Appears to be exclusive with splitStem.)
Definition Entries.h:318
bool isPossibleFullMeasureRest() const
Returns true if the entry could be a full-measure rest.
Definition Entries.h:370
bool beam
Signifies the start of a beam or singleton entry. (That is, any beam breaks at this entry....
Definition Entries.h:311
bool performanceData
Indicates there is performance data on the entry.
Definition Entries.h:305
bool noSpacing
Indicates that the entry should be ignored when calculating music spacing.
Definition Entries.h:333
bool dotTieAlt
Indicates dot or tie alterations are present.
Definition Entries.h:310
bool freezeBeam
Freeze beam flag (Derived from the presence of <freezeBeam> node.)
Definition Entries.h:334
bool graceNote
Indicate the entry is a grace note.
Definition Entries.h:299
KeyContext
Indicates whether to compute key signature values in concert or written pitch.
Definition CommonClasses.h:255
Provides optional per-type extension methods for MusxInstanceList.
Definition MusxInstance.h:103
Wraps an EntryInfo instance and a note index.
Definition Entries.h:962
int calcStaffPosition() const
Calculates the staff position for this note, taking into account percussion notes.
Note::NoteProperties calcNoteProperties(const std::optional< bool > &enharmonicRespell=std::nullopt, bool alwaysUseEntryStaff=false) const
Calculates the note name, octave number, actual alteration, and staff position. This function does no...
Definition Entries.cpp:1765
EntryInfoPtr getEntryInfo() const
Gets the entry info for this note.
Definition Entries.h:997
MusxInstance< others::PercussionNoteInfo > calcPercussionNoteInfo() const
Calculates the percussion note info for this note, if any.
Definition Entries.cpp:1807
MusxInstance< Note > operator->() const
Allows -> access to the underlying Note instance.
Definition Entries.h:988
bool operator<(const NoteInfoPtr &other) const
Explicit operator< for std::map.
Definition Entries.h:1105
bool isSameNote(const NoteInfoPtr &src) const
Returns whether the input and the current instance refer to the same note.
Definition Entries.h:979
StaffCmper calcStaff() const
Calculates the staff number, taking into account cross staffing.
Definition Entries.cpp:1751
NoteInfoPtr getPrevious() const
Gets the next note in a chord on the same entry.
Definition Entries.h:1070
Note::NoteProperties calcNotePropertiesConcert(bool alwaysUseEntryStaff=false) const
Calculates the note name, octave number, actual alteration, and staff position for the concert pitch ...
Definition Entries.cpp:1781
NoteInfoPtr calcTieFrom(bool requireTie=true) const
Calculates the note that this note could tie from.
Definition Entries.cpp:1721
bool calcIsEnharmonicRespell() const
Returns if this note is enharmonically respelled in the current part view.
Definition Entries.cpp:1833
std::pair< int, int > calcDefaultEnharmonic() const
Calculates the default enharmonic equivalent of this note. This is the value that Finale uses when de...
Definition Entries.h:1090
Note::NoteProperties calcNotePropertiesInView(bool alwaysUseEntryStaff=false) const
Calculates the note name, octave number, actual alteration, and staff position for the pitch of the n...
Definition Entries.cpp:1797
int calcCrossStaffDirection(DeferredReference< MusxInstanceList< others::StaffUsed > > staffList={}) const
Calculates if this note is cross-staffed and if so, which direction.
Definition Entries.cpp:1872
NoteInfoPtr(const EntryInfoPtr &entryInfo, size_t noteIndex)
Constructor.
Definition Entries.h:970
NoteInfoPtr calcTieTo() const
Calculates the note that this note could tie to. Check the return value's Note::tieEnd to see if ther...
Definition Entries.cpp:1676
NoteInfoPtr findEqualPitch(const EntryInfoPtr &entry) const
Finds a note with the same pitch in the supplied entry.
Definition Entries.cpp:1653
NoteInfoPtr getNext() const
Gets the next note in a chord on the same entry.
Definition Entries.h:1060
NoteInfoPtr()
Default constructor.
Definition Entries.h:965
std::unique_ptr< music_theory::Transposer > createTransposer() const
Creates a transposer for this Note instance.
Definition Entries.cpp:1828
Represents a single note element in an entry.
Definition Entries.h:175
bool upStemSecond
When the entry is upstem, it is drawn on the "wrong" side of the stem.
Definition Entries.h:201
bool isValid
Should always be true but otherwise appears to be used internally by Finale.
Definition Entries.h:197
bool playDisabledByHP
Used by Finale's smart playback engine.
Definition Entries.h:212
static constexpr NoteNumber RESTID
Non floating rests have a note with this noteId that defines their staff positions.
Definition Entries.h:184
int harmAlt
Chromatic alteration relative to the key signature. Never has a magnitude greater than +/-7.
Definition Entries.h:196
bool upSplitStem
Definition Entries.h:205
NoteNumber getNoteId() const
Gets the note id for this note. This value does not change, even if the notes in a chord are rearrang...
Definition Entries.h:216
bool tieEnd
Indicates a tie ends on this note.
Definition Entries.h:199
Note(const DocumentWeakPtr &document, NoteNumber noteId)
Constructor function.
Definition Entries.h:178
bool tieStart
Indicates a tie starts on this note.
Definition Entries.h:198
bool crossStaff
Signifies that the note has a details::CrossStaff note detail.
Definition Entries.h:200
std::pair< int, int > calcDefaultEnharmonic(const MusxInstance< KeySignature > &key) const
Calculates the default enharmonic equivalent of this note. This is the value that Finale uses when de...
Definition Entries.cpp:1572
int harmLev
Diatonic displacement relative to middle C or to the tonic in the middle C octave (if the key signatu...
Definition Entries.h:195
static const xml::XmlElementArray< Note > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool downStemSecond
When the entry is downstem, it is drawn on the "wrong" side of the stem.
Definition Entries.h:203
std::tuple< music_theory::NoteName, int, int, int > NoteProperties
Note properites. A tuple containing:
Definition Entries.h:193
bool noPlayback
Indicates that this note should not be played back.
Definition Entries.h:209
bool parenAcci
True if the accidental has parentheses.
Definition Entries.h:208
bool noSpacing
Indicates that this note should ignored when calculating spacing.
Definition Entries.h:210
bool showAcci
True if the note has an accidental. (Dynamically changed by Finale unless freezeAcci is set....
Definition Entries.h:207
bool freezeAcci
True if the accidental should be forced on or off (based on showAcci.)
Definition Entries.h:211
NoteProperties calcNoteProperties(const MusxInstance< KeySignature > &key, KeySignature::KeyContext ctx, ClefIndex clefIndex, const MusxInstance< others::PercussionNoteInfo > &percNoteInfo, const MusxInstance< others::Staff > &staff=nullptr, bool respellEnharmonic=false) const
Calculates the note name, octave number, actual alteration, and staff position. This function does no...
Definition Entries.cpp:1607
A context wrapper for GFrameHold associated with a specific part and location.
Definition Entries.h:59
const GFrameHold * operator->() const
Provides const pointer-style access to the underlying GFrameHold.
Definition Entries.h:83
EntryInfoPtr calcNearestEntry(Edu eduPosition, bool findExact=true, std::optional< LayerIndex > matchLayer=std::nullopt, std::optional< bool > matchVoice2=std::nullopt) const
Calculates the nearest non-grace-note entry at the given eduPosition.
Definition Entries.cpp:1534
std::map< LayerIndex, bool > calcVoices() const
Calculates the number of voices used by the GFrameHold instance.
Definition Entries.cpp:1462
std::shared_ptr< const EntryFrame > createEntryFrame(LayerIndex layerIndex) const
Returns the EntryFrame for all entries in the given layer.
Definition Entries.cpp:1326
ClefIndex calcClefIndexAt(util::Fraction position) const
Returns the clef index in effect for at the specified util::Fraction position (as a fraction of whole...
Definition Entries.h:100
bool iterateEntries(LayerIndex layerIndex, std::function< bool(const EntryInfoPtr &)> iterator) const
iterates the entries for the specified layer in this GFrameHold from left to right
Definition Entries.cpp:1439
bool calcIsCuesOnly(bool includeVisibleInScore=false) const
Calculates if this staff in this measure contains only a cue layer and full-measure rest layers.
Definition Entries.cpp:1512
Cmper getRequestedPartId() const
Returns the requested part ID associated with this context.
Definition Entries.h:76
ClefIndex calcClefIndexAt(Edu position) const
Returns the clef index in effect for at the specified Edu position. This function does not take into ...
Definition Entries.cpp:1486
Represents the attributes of a Finale frame holder.
Definition Details.h:1018
A class to represent fractions with integer m_numerator and m_denominator, automatically reduced to s...
Definition Fraction.h:38
constexpr dom::Edu calcEduDuration() const
Calculates duration as a fraction of a whole note.
Definition Fraction.h:129
static Fraction fromEdu(dom::Edu edu)
Constructs a Fraction from edu.
Definition Fraction.h:84
A dependency-free, header-only collection of useful functions for music theory.
NoteName
The available note names in array order.
Definition music_theory.hpp:66
int16_t MeasCmper
Enigma meas Cmper (may be negative when not applicable)
Definition Fundamentals.h:64
std::shared_ptr< const T > MusxInstance
Defines the type of a musx instance stored in a pool.
Definition MusxInstance.h:39
unsigned int LayerIndex
Layer index (valid values are 0..3)
Definition Fundamentals.h:71
int32_t Evpu
EVPU value (288 per inch)
Definition Fundamentals.h:57
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
uint16_t ClefIndex
Index into options::ClefOptions::clefDefs.
Definition Fundamentals.h:68
int32_t Edu
"Enigma Durational Units" value (1024 per quarter note)
Definition Fundamentals.h:61
std::pair< NoteType, unsigned > calcNoteInfoFromEdu(Edu duration)
Calculates the NoteType and number of dots in an Edu value.
Definition Entries.cpp:56
unsigned calcNumberOfBeamsInEdu(Edu duration)
Calculates the number of beams or flags in the Edu value.
Definition Entries.cpp:806
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition BaseClasses.h:57
int32_t EntryNumber
Entry identifier.
Definition Fundamentals.h:69
uint16_t NoteNumber
Note identifier.
Definition Fundamentals.h:70
std::shared_ptr< Document > DocumentPtr
Shared Document pointer.
Definition BaseClasses.h:55
int16_t StaffCmper
Enigma staff (staffId) Cmper (may be negative when not applicable)
Definition Fundamentals.h:65
std::weak_ptr< const T > MusxInstanceWeak
Defines a weak ptr to the type of a musx instance stored in a pool.
Definition MusxInstance.h:44
std::vector< XmlElementDescriptor< T > > XmlElementArray
an array type for XmlElementDescriptor instances.
Definition XmlInterface.h:127
object model for musx file (enigmaxml)
Definition BaseClasses.h:36
class to track tuplets in the frame
Definition Entries.h:688
size_t startIndex
the index of the first entry in the tuplet
Definition Entries.h:690
TupletInfo(const std::weak_ptr< const EntryFrame > &parent, const MusxInstance< details::TupletDef > &tup, size_t index, util::Fraction start, bool forVoice2)
Constructor.
Definition Entries.h:697
bool calcIsTremolo() const
Calculates if this tuplet represents a tremolo based on the following criteria.
Definition Entries.cpp:181
bool calcCreatesSingletonLeft() const
Calculates if this tuplet is being used to create a singleton beam to the left.
Definition Entries.h:756
size_t endIndex
the index of the last entry in the tuplet
Definition Entries.h:691
bool includesEntry(const EntryInfoPtr &entryInfo) const
Return true if the entry is part of this tuplet.
Definition Entries.h:713
util::Fraction endDura
the actual duration where the tuplet ends
Definition Entries.h:693
bool calcCreatesBeamContinuationRight() const
Calculates if this tuplet creates a beam continuation over a barline to the right,...
Definition Entries.cpp:328
size_t numEntries() const
Return the number of entries in the tuplet.
Definition Entries.h:703
util::Fraction startDura
the actual duration where the tuplet starts
Definition Entries.h:692
MusxInstance< details::TupletDef > tuplet
the tuplet
Definition Entries.h:689
bool voice2
whether this tuplet is for voice2
Definition Entries.h:694
bool calcCreatesSingletonRight() const
Calculates if this tuplet is being used to create a singleton beam to the right.
Definition Entries.h:745
bool calcCreatesBeamContinuationLeft() const
Calculates if this tuplet creates a beam continuation over a barline to the left, as created by the B...
Definition Entries.cpp:355
bool calcCreatesTimeStretch() const
Detects tuplets being used to create time stretch in an independent time signature.
Definition Entries.cpp:376