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 <functional>
25#include <map>
26#include <tuple>
27#include <utility>
28
29#include "musx/util/Fraction.h"
30#include "BaseClasses.h"
31#include "CommonClasses.h"
32 // do not add other dom class dependencies. Use Implementations.h for implementations that need total class access.
33
34namespace music_theory {
35enum class NoteName : int;
36class Transposer;
37} // namespace music_theory
38
39namespace musx {
40namespace utils {
41enum class PseudoTieMode;
42} // namespace utils
43
44namespace dom {
45
46namespace others {
47class Frame;
48class PartVoicing;
49class PercussionNoteInfo;
50class SmartShape;
51class Staff;
52class StaffComposite;
53class StaffUsed;
54} // namespace others
55
56namespace details {
57class TupletDef;
58class GFrameHold;
59
68public:
79 GFrameHoldContext(const DocumentPtr& document, Cmper partId, Cmper staffId, Cmper measureId, util::Fraction timeOffset = 0);
80
86 [[nodiscard]]
87 Cmper getRequestedPartId() const { return m_requestedPartId; }
88
94 [[nodiscard]]
95 MusxInstance<others::PartVoicing> getPartVoicing() const { return m_partVoicing; }
96
102 [[nodiscard]]
104 { return m_honorPartVoicing ? m_partVoicing : nullptr; }
105
111 const GFrameHold* operator->() const { return m_hold.get(); }
112
118 explicit operator bool() const noexcept { return static_cast<bool>(m_hold); }
119
123 [[nodiscard]]
124 ClefIndex calcClefIndexAt(Edu position) const;
125
129 [[nodiscard]]
131 { return calcClefIndexAt(position.calcEduDuration()); }
132
138 [[nodiscard]]
139 std::shared_ptr<const EntryFrame> createEntryFrame(LayerIndex layerIndex) const;
140
148 bool iterateEntries(LayerIndex layerIndex, std::function<bool(const EntryInfoPtr&)> iterator) const;
149
155 bool iterateEntries(std::function<bool(const EntryInfoPtr&)> iterator) const;
156
160 [[nodiscard]]
161 std::map<LayerIndex, int> calcVoices(bool excludeHidden = false) const;
162
165 [[nodiscard]]
166 bool calcIsCuesOnly(bool includeVisibleInScore = false) const;
167
175 [[nodiscard]]
176 EntryInfoPtr calcNearestEntry(util::Fraction position, bool findExact = true, std::optional<LayerIndex> matchLayer = std::nullopt,
177 std::optional<bool> matchVoice2 = std::nullopt, util::Fraction atGraceNoteDuration = 0) const;
178
184 [[nodiscard]]
186
191 [[nodiscard]]
192 bool calcVoicingIncludesLayer(LayerIndex layerIndex) const;
193
195 [[nodiscard]]
197 { return !m_honorPartVoicing || calcVoicingIncludesLayer(layerIndex); }
198
201 [[nodiscard]]
202 util::Fraction getTimeOffset() const { return m_timeOffset; }
203
204private:
206 Cmper m_requestedPartId{};
207 util::Fraction m_timeOffset;
209 bool m_honorPartVoicing{};
210};
211
212} // namespace details
213
224
230unsigned calcNumberOfBeamsInEdu(Edu duration);
231
238class Note : public Base
239{
240public:
242 explicit Note(const DocumentWeakPtr& document, NoteNumber noteId)
243 : Base(document, 0, ShareMode::All), m_noteId(noteId)
244 {
245 }
246
248 static constexpr NoteNumber RESTID = 31;
249
257 using NoteProperties = std::tuple<music_theory::NoteName, int, int, int>;
258
259 int harmLev{};
260 int harmAlt{};
261 bool isValid{};
262 bool tieStart{};
263 bool tieEnd{};
264 bool crossStaff{};
269 bool upSplitStem{};
271 bool showAcci{};
272 bool parenAcci{};
273 bool noPlayback{};
274 bool noSpacing{};
275 bool freezeAcci{};
277
280 [[nodiscard]]
281 NoteNumber getNoteId() const { return m_noteId; }
282
293 [[nodiscard]]
294 std::pair<int, int> calcDefaultEnharmonic(const MusxInstance<KeySignature>& key) const;
295
321 [[nodiscard]]
323 const MusxInstance<others::PercussionNoteInfo>& percNoteInfo, const MusxInstance<others::Staff>& staff = nullptr, bool respellEnharmonic = false) const;
324
326
327private:
328 NoteNumber m_noteId{};
329};
330
337class Entry : public Base
338{
339public:
344 explicit Entry(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, EntryNumber entnum, EntryNumber prev, EntryNumber next)
345 : Base(document, partId, shareMode), m_entnum(entnum), m_prev(prev), m_next(next)
346 {
347 }
348
358 int numNotes{};
360 bool isValid{};
361 bool isNote{};
362 bool v2Launch{};
363 bool voice2{};
364 bool createdByHP{};
366 bool graceNote{};
367 bool noteDetail{};
368 bool articDetail{};
369 bool lyricDetail{};
370 bool tupletStart{};
371 bool splitRest{};
373 bool floatRest{};
374 bool isHidden{};
375 bool beamExt{};
376 bool flipTie{};
377 bool dotTieAlt{};
378 bool beam{};
379 bool secBeam{};
381 bool stemDetail{};
382 bool crossStaff{};
385 bool doubleStem{};
386 bool splitStem{};
388 bool upStemScore{};
389 bool checkAccis{};
390 bool dummy{};
393 bool noLeger{};
394 bool sorted{};
395 bool slashGrace{};
398 bool flatBeam{};
399 bool noPlayback{};
400 bool noSpacing{};
401 bool freezeBeam{};
402
404 std::vector<std::shared_ptr<Note>> notes;
405
412 {
416 size_t entryIndex{};
417
419 bool found() const { return staffId != 0 && measureId != 0; }
421 void clear() { *this = {}; }
423
425 [[nodiscard]]
426 EntryNumber getEntryNumber() const { return m_entnum; }
427
431 [[nodiscard]]
433
437 [[nodiscard]]
439
443 [[nodiscard]]
445
449 [[nodiscard]]
451
454 [[nodiscard]]
455 bool hasStem() const { return duration < Edu(NoteType::Whole); }
456
461 [[nodiscard]]
463 { return !isNote && !isHidden && duration == Edu(NoteType::Whole); }
464
465 void integrityCheck(const std::shared_ptr<Base>& ptrToThis) override
466 {
467 this->Base::integrityCheck(ptrToThis);
468 if (size_t(numNotes) != notes.size()) {
469 MUSX_INTEGRITY_ERROR("Entry " + std::to_string(m_entnum) + " has an incorrect number of notes.");
470 }
471 }
472
475 static void calcLocations(const DocumentPtr& document);
476
477 constexpr static std::string_view XmlNodeName = "entry";
479
480private:
481 EntryNumber m_entnum{};
482 EntryNumber m_prev{};
483 EntryNumber m_next{};
484};
485
486class EntryInfo;
487class EntryFrame;
488class NoteInfoPtr;
489
494{
495public:
499 {
500 Normal,
501 IncludeAll,
507 };
508
509 class InterpretedIterator;
510
512 EntryInfoPtr() : m_entryFrame(nullptr), m_indexInFrame(0) {}
513
519 explicit EntryInfoPtr(const std::shared_ptr<const EntryFrame>& entryFrame, size_t index = 0)
520 : m_entryFrame(entryFrame), m_indexInFrame(index) {}
521
532 [[nodiscard]]
533 static EntryInfoPtr fromEntryNumber(const DocumentPtr& document, Cmper partId, EntryNumber entryNumber, util::Fraction timeOffset = 0);
534
536 const std::shared_ptr<const EntryInfo> operator->() const;
537
539 operator bool() const noexcept;
540
542 [[nodiscard]] int getVoice() const;
543
546 [[nodiscard]] bool isSameEntry(const EntryInfoPtr& src) const;
547
556 [[nodiscard]] bool calcIsSamePitchContent(const EntryInfoPtr& src, bool compareConcert = true) const;
557
570 [[nodiscard]]
571 bool calcIsSamePitchContentAndDuration(const EntryInfoPtr& src, bool compareConcert = true, bool requireSameVoice = true, bool requireSameGraceElapsedDura = false) const;
572
585 [[nodiscard]]
586 bool calcContainsPitchContent(const EntryInfoPtr& src, bool compareConcert = true) const;
587
589 [[nodiscard]] std::shared_ptr<const EntryFrame> getFrame() const { return m_entryFrame; }
590
592 [[nodiscard]] size_t getIndexInFrame() const { return m_indexInFrame; }
593
595 [[nodiscard]] LayerIndex getLayerIndex() const;
596
598 [[nodiscard]] StaffCmper getStaff() const;
599
602 [[nodiscard]] MusxInstance<others::StaffComposite> createCurrentStaff(const std::optional<StaffCmper>& forStaffId = std::nullopt) const;
603
605 [[nodiscard]] MeasCmper getMeasure() const;
606
608 [[nodiscard]] MusxInstance<KeySignature> getKeySignature() const;
609
612
615 [[nodiscard]] Evpu calcManuaOffset() const;
616
618 [[nodiscard]] unsigned calcReverseGraceIndex() const;
619
623 [[nodiscard]] util::Fraction calcGraceElapsedDuration() const;
624
626 [[nodiscard]] std::optional<size_t> calcNextTupletIndex(std::optional<size_t> currentIndex = 0) const;
627
629 [[nodiscard]] EntryInfoPtr getNextInFrame() const;
630
634 [[nodiscard]] EntryInfoPtr getNextInLayer(std::optional<MeasCmper> targetMeasure = std::nullopt) const;
635
639 [[nodiscard]] EntryInfoPtr getNextSameV() const;
640
643 [[nodiscard]] EntryInfoPtr getNextSameVNoGrace() const;
644
648 [[nodiscard]] EntryInfoPtr getPreviousInLayer(std::optional<MeasCmper> targetMeasure = std::nullopt) const;
649
651 [[nodiscard]] EntryInfoPtr getPreviousInFrame() const;
652
656 [[nodiscard]] EntryInfoPtr getPreviousSameV() const;
657
660 [[nodiscard]] EntryInfoPtr getPreviousSameVNoGrace() const;
661
667 [[nodiscard]] EntryInfoPtr getNextInVoice(int voice) const;
668
674 [[nodiscard]] EntryInfoPtr getPreviousInVoice(int voice) const;
675
678 [[nodiscard]] InterpretedIterator asInterpretedIterator(bool remapBeamOverBarlineEntries = true) const;
679
681 [[nodiscard]]
683 { return iterateBeamGroup<&EntryInfoPtr::nextPotentialInBeam, &EntryInfoPtr::previousPotentialInBeam>(beamIterationMode); }
684
686 [[nodiscard]]
688 { return iterateBeamGroup<&EntryInfoPtr::previousPotentialInBeam, &EntryInfoPtr::nextPotentialInBeam>(beamIterationMode); }
689
694
699
703 [[nodiscard]] bool calcDisplaysAsRest() const;
704
708 [[nodiscard]] std::pair<int, int> calcTopBottomStaffPositions() const;
709
715 [[nodiscard]] std::pair<bool, bool> calcEntryStemSettings() const;
716
720 [[nodiscard]] bool calcUpStemDefault() const;
721
736 [[nodiscard]] bool calcUpStem() const
737 {
738 if (m_upStem.has_value()) {
739 return m_upStem.value();
740 }
741 m_upStem = calcUpStemImpl();
742 return m_upStem.value();
743 }
744
747 [[nodiscard]] bool calcUnbeamed() const;
748
750 [[nodiscard]] bool calcIsBeamStart(BeamIterationMode beamIterationMode = BeamIterationMode::Normal) const;
751
754 [[nodiscard]] bool calcCreatesSingletonBeamLeft() const;
755
758 [[nodiscard]] bool calcCreatesSingletonBeamRight() const;
759
768
777
782 [[nodiscard]] bool calcIsFeatheredBeamStart(Evpu& outLeftY, Evpu& outRightY) const;
783
788 [[nodiscard]] EntryInfoPtr findBeamStartOrCurrent() const;
789
792 [[nodiscard]] EntryInfoPtr findBeamEnd() const;
793
795 [[nodiscard]] unsigned calcNumberOfBeams() const;
796
800 [[nodiscard]] unsigned calcLowestBeamStart(bool considerBeamOverBarlines = false) const;
801
804 [[nodiscard]] unsigned calcLowestBeamEnd() const;
805
809 [[nodiscard]] unsigned calcLowestBeamEndAcrossBarlines() const;
810
813 [[nodiscard]] unsigned calcLowestBeamStub() const;
814
820 [[nodiscard]] bool calcBeamStubIsLeft() const;
821
823 [[nodiscard]] util::Fraction calcGlobalElapsedDuration() const;
824
826 [[nodiscard]] util::Fraction calcGlobalActualDuration() const;
827
829 [[nodiscard]] bool calcCanBeBeamed() const;
830
832 [[nodiscard]] bool calcBeamMustStartHere() const;
833
836 [[nodiscard]] int calcEntrySize() const;
837
843 [[nodiscard]] bool calcIsCue(bool includeVisibleInScore = false) const;
844
847 [[nodiscard]] bool calcIsFullMeasureRest() const;
848
852 [[nodiscard]] bool calcIsBeamedRestWorkaroundHiddenRest() const;
853
857 [[nodiscard]] bool calcIsBeamedRestWorkaroundVisibleRest() const;
858
861 [[nodiscard]] std::vector<size_t> findTupletInfo() const;
862
866 [[nodiscard]] bool calcIfLayerSettingsApply() const;
867
878
882 [[nodiscard]] std::optional<StaffCmper> calcCrossedStaffForAll() const;
883
885 [[nodiscard]] bool calcIsSingletonGrace() const;
886
892 [[nodiscard]] int calcIsAuxiliaryPitchMarker() const;
893
904 [[nodiscard]] bool calcIsTrillToGraceEntry() const;
905
913 [[nodiscard]] bool calcIsGlissToGraceEntry() const;
914
920
927
933 [[nodiscard]] EntryInfoPtr findMainEntryForGraceNote(bool ignoreRests = false) const;
934
951 bool iterateStartingSmartShapes(std::function<bool(const MusxInstance<others::SmartShape>&)> callback, bool findExact = false) const;
952
954 bool operator<(const EntryInfoPtr& other) const
955 {
956 if (m_entryFrame != other.m_entryFrame)
957 return m_entryFrame < other.m_entryFrame;
958 return m_indexInFrame < other.m_indexInFrame;
959 }
960
961private:
962 [[nodiscard]] unsigned calcVisibleBeams() const;
963
964 [[nodiscard]] bool calcUpStemImpl() const;
965
966 template<EntryInfoPtr(EntryInfoPtr::* Iterator)() const>
967 [[nodiscard]] std::optional<unsigned> iterateFindRestsInSecondaryBeam(const EntryInfoPtr nextOrPrevInBeam) const;
968
969 template<EntryInfoPtr(EntryInfoPtr::* Iterator)() const>
970 [[nodiscard]] EntryInfoPtr iteratePotentialEntryInBeam() const;
971
972 template<EntryInfoPtr(EntryInfoPtr::* Iterator)() const>
973 [[nodiscard]] bool iterateNotesExistLeftOrRight() const;
974
975 [[nodiscard]] EntryInfoPtr nextPotentialInBeam(BeamIterationMode beamIterationMode) const;
976
977 [[nodiscard]] EntryInfoPtr previousPotentialInBeam(BeamIterationMode beamIterationMode) const;
978
979 using BeamIteratorFn = EntryInfoPtr (EntryInfoPtr::*)(BeamIterationMode) const;
980 template<BeamIteratorFn Iterator, BeamIteratorFn ReverseIterator>
981 [[nodiscard]] EntryInfoPtr iterateBeamGroup(BeamIterationMode beamIterationMode) const;
982
986 [[nodiscard]] EntryInfoPtr findLeftBeamAnchorForBeamOverBarline() const;
987
991 [[nodiscard]] EntryInfoPtr findRightBeamAnchorForBeamOverBarline() const;
992
993 std::shared_ptr<const EntryFrame> m_entryFrame;
994 size_t m_indexInFrame{};
995
997 mutable MusxInstance<others::StaffComposite> m_cachedStaff;
998
1000 mutable std::optional<bool> m_upStem;
1001};
1002
1017// the the caller should use for calculating elapsed time.
1049{
1050 EntryInfoPtr m_entry;
1051 bool m_effectiveHidden{};
1052 // --------
1053 // internal
1054 // --------
1055 EntryInfoPtr m_iteratedEntry;
1056 bool m_useIteratedForBackLaunch{};
1057 bool m_remapBeamOverBarlineEntries{};
1058
1059 [[nodiscard]] const EntryInfoPtr& getIteratedEntry() const noexcept
1060 { return m_iteratedEntry ? m_iteratedEntry : m_entry; }
1061
1062 [[nodiscard]] const EntryInfoPtr& getForwardLaunchEntry() const noexcept
1063 { return getIteratedEntry(); }
1064
1065 [[nodiscard]] const EntryInfoPtr& getBackwardLaunchEntry() const noexcept
1066 { return m_useIteratedForBackLaunch ? getIteratedEntry() : m_entry; }
1067
1071 InterpretedIterator(EntryInfoPtr entry, bool remapBeamOverBarlineEntries);
1072
1073 friend class EntryFrame;
1074 friend class EntryInfoPtr;
1075
1076public:
1079
1082 [[nodiscard]] const EntryInfoPtr& getEntryInfo() const noexcept { return m_entry; }
1083
1087 [[nodiscard]] bool getEffectiveHidden() const noexcept { return m_effectiveHidden; }
1088
1092 [[nodiscard]] util::Fraction getEffectiveActualDuration(bool global = false) const;
1093
1097 [[nodiscard]] util::Fraction getEffectiveElapsedDuration(bool global = false) const;
1098
1102
1105 [[nodiscard]] bool calcIsPastLogicalEndOfFrame() const;
1106
1114 [[nodiscard]] InterpretedIterator getNext() const;
1115
1123 [[nodiscard]] InterpretedIterator getPrevious() const;
1124
1128 explicit operator bool() const noexcept
1129 {
1130 return static_cast<bool>(m_entry);
1131 }
1132};
1133
1140class EntryFrame : public std::enable_shared_from_this<EntryFrame>
1141{
1142public:
1150 explicit EntryFrame(const details::GFrameHoldContext& gfhold, LayerIndex layerIndex, util::Fraction timeStretch, const MusxInstance<others::StaffComposite>& startStaff) :
1151 m_context(gfhold),
1152 m_layerIndex(layerIndex),
1153 m_timeStretch(timeStretch),
1154 m_startStaff(startStaff)
1155 {
1156 }
1157
1160 {
1162 size_t startIndex;
1163 size_t endIndex;
1166 bool voice2;
1167
1169 TupletInfo(const std::weak_ptr<const EntryFrame>& parent, const MusxInstance<details::TupletDef>& tup, size_t index, util::Fraction start, bool forVoice2)
1170 : tuplet(tup), startIndex(index), endIndex((std::numeric_limits<size_t>::max)()),
1171 startDura(start), endDura(-1), voice2(forVoice2), m_parent(parent)
1172 {}
1173
1175 [[nodiscard]]
1176 size_t numEntries() const
1177 {
1178 MUSX_ASSERT_IF(startIndex > endIndex) {
1179 throw std::logic_error("TupletInfo has invalid start and end indices.");
1180 }
1181 return endIndex - startIndex + 1;
1182 }
1183
1186 [[nodiscard]]
1187 bool includesEntry(const EntryInfoPtr& entryInfo) const
1188 {
1189 const size_t x = entryInfo.getIndexInFrame();
1190 return (x >= startIndex && x <= endIndex);
1191 }
1192
1204 [[nodiscard]]
1205 bool calcIsTremolo() const;
1206
1220 [[nodiscard]]
1221 bool calcCreatesSingletonBeamRight() const { return calcCreatesSingleton(false); }
1222
1232 [[nodiscard]]
1233 bool calcCreatesSingletonBeamLeft() const { return calcCreatesSingleton(true); }
1234
1245 // - the independent display time signature matches the tuplet's total display duration
1246 [[nodiscard]]
1247 bool calcCreatesTimeStretch() const;
1248
1249 private:
1250 [[nodiscard]]
1251 bool calcCreatesSingleton(bool left) const;
1252
1253 [[nodiscard]]
1254 const std::shared_ptr<const EntryFrame> getParent() const
1255 {
1256 auto result = m_parent.lock();
1257 MUSX_ASSERT_IF(!result) {
1258 throw std::logic_error("Unable to obtain lock on parent entry frame.");
1259 }
1260 return result;
1261 }
1262
1263 const std::weak_ptr<const EntryFrame> m_parent;
1264 };
1265
1272 std::vector<TupletInfo> tupletInfo;
1277
1279 [[nodiscard]]
1280 DocumentPtr getDocument() const;
1281
1283 [[nodiscard]]
1284 const details::GFrameHoldContext& getContext() const { return m_context; }
1285
1287 [[nodiscard]]
1288 Cmper getRequestedPartId() const { return m_context.getRequestedPartId(); }
1289
1291 [[nodiscard]]
1292 StaffCmper getStaff() const;
1293
1295 [[nodiscard]]
1296 MeasCmper getMeasure() const;
1297
1299 [[nodiscard]]
1300 LayerIndex getLayerIndex() const { return m_layerIndex; }
1301
1303 [[nodiscard]]
1305
1308 [[nodiscard]]
1309 util::Fraction getTimeStretch() const { return m_timeStretch; }
1310
1312 [[nodiscard]]
1313 const std::vector<std::shared_ptr<const EntryInfo>>& getEntries() const
1314 { return m_entries; }
1315
1319 [[nodiscard]]
1320 EntryInfoPtr getFirstInVoice(int voice) const;
1321
1325 [[nodiscard]]
1326 EntryInfoPtr getLastInVoice(int voice) const;
1327
1380 [[nodiscard]]
1381 EntryInfoPtr::InterpretedIterator getFirstInterpretedIterator(int voice, bool remapBeamOverBarlineEntries = true) const;
1382
1384 void addEntry(const std::shared_ptr<const EntryInfo>& entry)
1385 { m_entries.emplace_back(entry); }
1386
1390 [[nodiscard]]
1391 std::shared_ptr<const EntryFrame> getNext(std::optional<MeasCmper> targetMeasure = std::nullopt) const;
1392
1396 [[nodiscard]]
1397 std::shared_ptr<const EntryFrame> getPrevious(std::optional<MeasCmper> targetMeasure = std::nullopt) const;
1398
1400 [[nodiscard]]
1403
1407 [[nodiscard]]
1408 MusxInstance<others::StaffComposite> createCurrentStaff(Edu eduPosition, const std::optional<StaffCmper>& forStaffId = std::nullopt) const;
1409
1411 [[nodiscard]]
1413
1419 [[nodiscard]]
1420 bool calcIsCueFrame(bool includeVisibleInScore = false) const;
1421
1427 [[nodiscard]]
1428 bool calcAreAllEntriesHiddenInFrame() const;
1429
1436 [[nodiscard]]
1437 EntryInfoPtr calcNearestEntry(util::Fraction position, bool findExact = true, std::optional<bool> matchVoice2 = std::nullopt,
1438 util::Fraction atGraceNoteDuration = 0) const;
1439
1444 bool iterateEntries(std::function<bool(const EntryInfoPtr&)> iterator) const;
1445
1446private:
1448 LayerIndex m_layerIndex;
1449 util::Fraction m_timeStretch;
1450
1451 std::vector<std::shared_ptr<const EntryInfo>> m_entries;
1452
1455
1457 mutable MusxInstance<others::LayerAttributes> m_cachedLayerAttributes;
1458};
1459
1460namespace details {
1461class GFrameHold;
1462} // namespace details
1463
1473{
1478 explicit EntryInfo(const MusxInstance<Entry>& entry)
1479 : m_entry(entry) {}
1480
1481#ifndef DOXYGEN_SHOULD_IGNORE_THIS
1483#endif
1484
1485public:
1492 unsigned graceIndex{};
1496
1499 [[nodiscard]]
1501 {
1502 auto retval = m_entry.lock();
1503 if (!retval) {
1504 throw std::logic_error("Entry pointer is no longer valid");
1505 }
1506 return retval;
1507 }
1508
1510 [[nodiscard]]
1513
1514private:
1516};
1517
1520{
1521public:
1523 NoteInfoPtr() : m_entry(), m_noteIndex(0) {}
1524
1528 NoteInfoPtr(const EntryInfoPtr& entryInfo, size_t noteIndex)
1529 : m_entry(entryInfo), m_noteIndex(noteIndex)
1530 {}
1531
1533 explicit operator bool() const noexcept
1534 { return m_entry && m_noteIndex < m_entry->getEntry()->notes.size(); }
1535
1538 [[nodiscard]]
1539 bool isSameNote(const NoteInfoPtr& src) const
1540 { return m_entry.isSameEntry(src.m_entry) && m_noteIndex == src.m_noteIndex; }
1541
1545 [[nodiscard]]
1546 NoteInfoPtr findEqualPitch(const EntryInfoPtr& entry) const;
1547
1549 [[nodiscard]]
1551 {
1552 MUSX_ASSERT_IF(m_noteIndex >= m_entry->getEntry()->notes.size()) {
1553 throw std::logic_error("Note index is too large for notes array.");
1554 }
1555 return m_entry->getEntry()->notes[m_noteIndex];
1556 }
1557
1559 [[nodiscard]]
1561 { return m_entry; }
1562
1564 [[nodiscard]]
1565 size_t getNoteIndex() const
1566 { return m_noteIndex; }
1567
1580 [[nodiscard]]
1581 Note::NoteProperties calcNoteProperties(const std::optional<bool>& enharmonicRespell = std::nullopt, bool alwaysUseEntryStaff = false) const;
1582
1590 [[nodiscard]]
1591 Note::NoteProperties calcNotePropertiesConcert(bool alwaysUseEntryStaff = false) const;
1592
1601 [[nodiscard]]
1602 Note::NoteProperties calcNotePropertiesInView(bool alwaysUseEntryStaff = false) const;
1603
1606 [[nodiscard]]
1608
1611 [[nodiscard]]
1613
1617 [[nodiscard]]
1618 NoteInfoPtr calcTieTo() const;
1619
1624 [[nodiscard]]
1625 NoteInfoPtr calcTieFrom(bool requireTie = true) const;
1626
1628 [[nodiscard]]
1629 StaffCmper calcStaff() const;
1630
1633 [[nodiscard]]
1634 std::unique_ptr<music_theory::Transposer> createTransposer() const;
1635
1638 [[nodiscard]]
1640 {
1641 if (m_noteIndex >= m_entry->getEntry()->notes.size()) {
1642 return NoteInfoPtr();
1643 }
1644 return NoteInfoPtr(m_entry, m_noteIndex + 1);
1645 }
1646
1649 [[nodiscard]]
1651 {
1652 if (m_noteIndex <= 0) {
1653 return NoteInfoPtr();
1654 }
1655 return NoteInfoPtr(m_entry, m_noteIndex - 1);
1656 }
1657
1659 [[nodiscard]]
1660 bool calcIsEnharmonicRespell() const;
1661
1671 [[nodiscard]]
1672 std::pair<int, int> calcDefaultEnharmonic() const
1673 { return (*this)->calcDefaultEnharmonic(m_entry.getKeySignature()); }
1674
1677 [[nodiscard]]
1679
1689 [[nodiscard]]
1691
1694 [[nodiscard]]
1695 bool calcIsIncludedInVoicing() const;
1696
1703 [[nodiscard]]
1704 NoteInfoPtr calcArpeggiatedTieToNote(CurveContourDirection* tieDirection = nullptr) const;
1705
1713 [[nodiscard]]
1714 bool calcHasPseudoLvTie(CurveContourDirection* tieDirection = nullptr) const;
1715
1723 [[nodiscard]]
1724 bool calcHasPseudoTieEnd(CurveContourDirection* tieDirection = nullptr) const;
1725
1732 [[nodiscard]]
1733 std::vector<std::pair<NoteInfoPtr, CurveContourDirection>> calcJumpTieContinuationsFrom() const;
1734
1735private:
1736 enum class TieFromSearchAction {
1737 Continue,
1738 Accept,
1739 Stop,
1740 };
1741
1742 static NoteInfoPtr findTieFromCandidate(const NoteInfoPtr& note, Cmper previousMeasure,
1743 const std::function<TieFromSearchAction(const NoteInfoPtr&, bool)>& decide);
1744
1748 [[nodiscard]]
1749 bool calcPseudoTieInternal(utils::PseudoTieMode mode, CurveContourDirection* tieDirection) const;
1750
1754 [[nodiscard]]
1755 bool selectPseudoTieDirection(CurveContourDirection* tieDirection,
1756 std::vector<CurveContourDirection>& directions,
1757 const std::vector<size_t>* eligibleNoteIndices = nullptr) const;
1758
1762 [[nodiscard]]
1763 bool isSamePitch(const NoteInfoPtr& src) const;
1764
1768 [[nodiscard]]
1769 bool isSamePitchValues(const NoteInfoPtr& src) const;
1770
1773 [[nodiscard]]
1774 NoteInfoPtr calcTieToWithNextMeasure(Cmper nextMeasure) const;
1775
1779 [[nodiscard]]
1780 NoteInfoPtr calcTieFromWithPreviousMeasure(Cmper previousMeasure, bool requireTie) const;
1781
1782 EntryInfoPtr m_entry;
1783 size_t m_noteIndex;
1784};
1785
1786} // namespace dom
1787} // 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:1141
util::Fraction getTimeStretch() const
Get the time stretch in this frame. Rather than accessing this value directly, consider using EntryIn...
Definition Entries.h:1309
util::Fraction maxElapsedStaffDuration
Definition Entries.h:1275
EntryFrame(const details::GFrameHoldContext &gfhold, LayerIndex layerIndex, util::Fraction timeStretch, const MusxInstance< others::StaffComposite > &startStaff)
Constructor function.
Definition Entries.h:1150
util::Fraction measureStaffDuration
The duration of the measure in staff duration units.
Definition Entries.h:1274
EntryInfoPtr getLastInVoice(int voice) const
Returns the last entry in the specified v1/v2 or null if none.
Definition Entries.cpp:157
MusxInstance< others::StaffComposite > getStartStaffInstance() const
Gets the staff at eduPosition 0 without needing to create it again.
Definition Entries.h:1401
bool calcAreAllEntriesHiddenInFrame() const
Calculates if this all notes in the frame are hidden. This routine only checks that entries are indiv...
Definition Entries.cpp:231
MeasCmper getMeasure() const
Get the measure for the entry frame.
Definition Entries.cpp:131
MusxInstance< others::Measure > getMeasureInstance() const
Get the measure instance.
Definition Entries.cpp:210
EntryInfoPtr calcNearestEntry(util::Fraction position, bool findExact=true, std::optional< bool > matchVoice2=std::nullopt, util::Fraction atGraceNoteDuration=0) const
Calculates the nearest non-grace-note entry at the given position.
Definition Entries.cpp:242
void addEntry(const std::shared_ptr< const EntryInfo > &entry)
Add an entry to the list.
Definition Entries.h:1384
const std::vector< std::shared_ptr< const EntryInfo > > & getEntries() const
Get the entry list.
Definition Entries.h:1313
EntryInfoPtr getFirstInVoice(int voice) const
Returns the first entry in the specified v1/v2 or null if none.
Definition Entries.cpp:141
StaffCmper getStaff() const
Get the staff for the entry.
Definition Entries.cpp:129
Cmper getRequestedPartId() const
Get the requested part ID for the entry frame.
Definition Entries.h:1288
std::shared_ptr< const EntryFrame > getNext(std::optional< MeasCmper > targetMeasure=std::nullopt) const
Gets the entry frame for the next measure with the same staff and layer.
Definition Entries.cpp:180
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:201
MusxInstance< KeySignature > keySignature
This can be different than the measure key sig if the staff has independent key signatures.
Definition Entries.h:1273
MusxInstance< others::LayerAttributes > getLayerAttributes() const
Get the LayerAttributes for this entry frame.
Definition Entries.cpp:133
const details::GFrameHoldContext & getContext() const
Get the frame context for this frame.
Definition Entries.h:1284
LayerIndex getLayerIndex() const
Get the layer index (0..3) of the entry frame.
Definition Entries.h:1300
bool iterateEntries(std::function< bool(const EntryInfoPtr &)> iterator) const
Iterates the entries for the specified layer in this EntryFrame from left to right.
Definition Entries.cpp:271
DocumentPtr getDocument() const
Get the document for the entry frame.
Definition Entries.cpp:127
std::shared_ptr< const EntryFrame > getPrevious(std::optional< MeasCmper > targetMeasure=std::nullopt) const
Gets the entry frame for the previous measure with the same staff and layer.
Definition Entries.cpp:189
std::vector< TupletInfo > tupletInfo
A list of the tuplets in the frame and their calculated starting and ending information.
Definition Entries.h:1272
EntryInfoPtr::InterpretedIterator getFirstInterpretedIterator(int voice, bool remapBeamOverBarlineEntries=true) const
Returns a workaround-aware iterator at the first entry in the specified voice.
Definition Entries.cpp:167
bool calcIsCueFrame(bool includeVisibleInScore=false) const
Calculates if this entry frame is part of a cue.
Definition Entries.cpp:215
Iterator-style wrapper for workaround-aware voice traversal.
Definition Entries.h:1049
const EntryInfoPtr & getEntryInfo() const noexcept
Returns the entry at the current iterator position.
Definition Entries.h:1082
bool calcIsPastLogicalEndOfFrame() const
Returns true is this entry is past the logical end of the frame, as defined by the length of the meas...
Definition Entries.cpp:2190
InterpretedIterator getNext() const
Returns an iterator advanced to the next usable entry in this voice.
Definition Entries.cpp:2225
util::Fraction getEffectiveMeasureStaffDuration() const
Return the effective measure staff duration of the entry. Calling code using InterpretedIterator shou...
Definition Entries.cpp:2185
InterpretedIterator getPrevious() const
Returns an iterator advanced to the previous usable entry in this voice.
Definition Entries.cpp:2237
bool getEffectiveHidden() const noexcept
Returns whether the entry should be treated as hidden.
Definition Entries.h:1087
InterpretedIterator()=default
Default constructor allows null return values by caller.
util::Fraction getEffectiveActualDuration(bool global=false) const
Return the effective actual duration of the entry. Calling code using InterpretedIterator should use ...
Definition Entries.cpp:2169
util::Fraction getEffectiveElapsedDuration(bool global=false) const
Return the effective elapsed duration of the entry. Calling code using InterpretedIterator should use...
Definition Entries.cpp:2177
Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ow...
Definition Entries.h:494
bool calcUpStemDefault() const
Calculates if the entry is upstem by default, without considering voices, layers, staff options,...
Definition Entries.cpp:915
EntryInfoPtr getNextInFrame() const
Get the next entry in the frame.
Definition Entries.cpp:735
EntryInfoPtr getPreviousInBeamGroupAcrossBars(BeamIterationMode beamIterationMode=BeamIterationMode::Normal) 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.cpp:856
bool calcIsBeamStart(BeamIterationMode beamIterationMode=BeamIterationMode::Normal) const
Returns whether this is the start of a primary beam.
Definition Entries.cpp:1070
bool calcBeamMustStartHere() const
Determines if a beam must start on this entry.
Definition Entries.cpp:1065
EntryInfoPtr(const std::shared_ptr< const EntryFrame > &entryFrame, size_t index=0)
Constructor function.
Definition Entries.h:519
EntryInfoPtr getNextSameV() const
Get the next entry in the frame in the same voice.
Definition Entries.cpp:743
bool calcCanBeBeamed() const
Determines if this entry can be beamed.
Definition Entries.cpp:1052
EntryInfoPtr findMainEntryForGraceNote(bool ignoreRests=false) const
Finds the main entry for a grace note, taking into account hidden entries for beams over barlines.
Definition Entries.cpp:1318
size_t getIndexInFrame() const
Returns the index within the frame.
Definition Entries.h:592
util::Fraction calcGlobalElapsedDuration() const
Calculates the elapsed duration in global edu, removing any time stretch due to independent time sign...
Definition Entries.cpp:1673
std::pair< bool, bool > calcEntryStemSettings() const
Returns the Entry stem settings for the current requested part. This function encapsulates handling o...
Definition Entries.cpp:661
EntryInfoPtr calcBeamContinuesLeftOverBarline() const
Determines if this entry continues a beam across a barline from the previous measure.
Definition Entries.cpp:1353
EntryInfoPtr getNextInBeamGroup(BeamIterationMode beamIterationMode=BeamIterationMode::Normal) 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:682
bool calcIfLayerSettingsApply() const
Calculates whether the conditions are met for the layer attributes dependent on others::LayerAttribut...
Definition Entries.cpp:1948
EntryInfoPtr getPreviousInVoice(int voice) const
Returns the previous entry in the frame in the specified v1/v2 or null if none.
Definition Entries.cpp:824
bool iterateStartingSmartShapes(std::function< bool(const MusxInstance< others::SmartShape > &)> callback, bool findExact=false) const
Iterates all smart shapes whose start anchor resolves to this entry.
Definition Entries.cpp:2107
unsigned calcReverseGraceIndex() const
Caclulates the grace index counting leftward (used by other standards such as MNX)
Definition Entries.cpp:678
static EntryInfoPtr fromEntryNumber(const DocumentPtr &document, Cmper partId, EntryNumber entryNumber, util::Fraction timeOffset=0)
Returns an EntryInfoPtr for the entry specified by entryNumber.
Definition Entries.cpp:461
EntryInfoPtr getPreviousSameVNoGrace() const
Get the previous entry in the frame in the same voice, skipping grace notes.
Definition Entries.cpp:805
MusxInstance< details::EntryPartFieldDetail > getPartFieldData() const
Gets the applicable part data for the entry, or nullptr if none.
Definition Entries.cpp:638
BeamIterationMode
Controls which entries are included when iterating over beams.
Definition Entries.h:499
@ Normal
Skip hidden entries. This is how Finale displays beams.
@ IncludeAll
Include all entries, even if they are hidden.
bool calcContainsPitchContent(const EntryInfoPtr &src, bool compareConcert=true) const
Returns whether src represent the same notated value.
Definition Entries.cpp:515
Evpu calcManuaOffset() const
Returns the manual offset of the entry for the current requested part. This function encapsulates han...
Definition Entries.cpp:653
EntryInfoPtr getNextInLayer(std::optional< MeasCmper > targetMeasure=std::nullopt) const
Get the next entry in the same layer and staff. This can be in the next measure.
Definition Entries.cpp:724
unsigned calcLowestBeamStart(bool considerBeamOverBarlines=false) const
Returns the lowest beam number starting at this entry, where 1 = 8th note beam, 2 = 16th note beam,...
Definition Entries.cpp:1528
bool isSameEntry(const EntryInfoPtr &src) const
Returns whether the input and the current instance refer to the same entry.
Definition Entries.cpp:502
EntryInfoPtr findHiddenSourceForBeamOverBarline() const
Find the hidden source entry for a mid-system beam created by the Beam Over Barline plugin....
Definition Entries.cpp:1191
unsigned calcLowestBeamStub() const
Returns the lowest beam stub at this entry, where 2 = 16th note stub, 3 = 32nd note stub,...
Definition Entries.cpp:1614
bool calcIsBeamedRestWorkaroundVisibleRest() 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:1914
bool calcIsSamePitchContent(const EntryInfoPtr &src, bool compareConcert=true) const
Returns whether this entry and src contain the same pitch content or rest value.
Definition Entries.cpp:566
util::Fraction calcGraceElapsedDuration() const
Calculates a grace note's symbolic starting duration as a negative offset from the main note....
Definition Entries.cpp:690
unsigned calcLowestBeamEnd() const
Returns the lowest beam number ending at this entry, where 1 = 8th note beam, 2 = 16th note beam,...
Definition Entries.cpp:1570
LayerIndex getLayerIndex() const
Get the layer index (0..3) of the entry.
Definition Entries.cpp:630
bool calcIsSingletonGrace() const
Return true if this entry is a grace note and the only grace in the sequence at this location.
Definition Entries.cpp:2034
unsigned calcLowestBeamEndAcrossBarlines() const
Returns the lowest beam number ending at this entry, where 1 = 8th note beam, 2 = 16th note beam,...
Definition Entries.cpp:1593
unsigned calcNumberOfBeams() const
Calculates the number of beams or flags on the entry.
Definition Entries.cpp:1477
EntryInfoPtr getNextInBeamGroupAcrossBars(BeamIterationMode beamIterationMode=BeamIterationMode::Normal) const
Gets the next entry in a beamed group, or nullptr if the entry is not beamed or is the last in the gr...
Definition Entries.cpp:840
EntryInfoPtr getPreviousInFrame() const
Get the previous entry in the frame.
Definition Entries.cpp:782
std::shared_ptr< const EntryFrame > getFrame() const
Returns the frame.
Definition Entries.h:589
bool calcUpStem() const
Determines the effective stem direction of the entry, taking into account voices, layers,...
Definition Entries.h:736
bool calcIsBeamedRestWorkaroundHiddenRest() 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:1894
int getVoice() const
Gets the voice as integer value 1 or 2.
Definition Entries.cpp:510
bool calcIsSamePitchContentAndDuration(const EntryInfoPtr &src, bool compareConcert=true, bool requireSameVoice=true, bool requireSameGraceElapsedDura=false) const
Returns whether this entry and src represent the same notated value.
Definition Entries.cpp:602
EntryInfoPtr findBeamStartOrCurrent() const
Finds the first entry of a beamed group or returns the current entry if it is not beams.
Definition Entries.cpp:1442
bool calcDisplaysAsRest() const
Calculates if an entry displays as a rest.
Definition Entries.cpp:872
MusxInstance< KeySignature > getKeySignature() const
Get the key signature of the entry.
Definition Entries.cpp:636
bool calcIsCue(bool includeVisibleInScore=false) const
Calculates if this entry is part of a cue.
Definition Entries.cpp:1844
EntryInfoPtr getPreviousInBeamGroup(BeamIterationMode beamIterationMode=BeamIterationMode::Normal) 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:687
InterpretedIterator asInterpretedIterator(bool remapBeamOverBarlineEntries=true) const
Returns this EntryInfoPtr in a InterpretedIterator instance.
Definition Entries.cpp:834
bool calcCreatesSingletonBeamLeft() const
Determines if this entry contains a tuplet that creates a singleton beam left. See EntryFrame::Tuplet...
Definition Entries.cpp:1082
bool operator<(const EntryInfoPtr &other) const
Explicit operator< for std::map.
Definition Entries.h:954
EntryInfoPtr getPreviousInLayer(std::optional< MeasCmper > targetMeasure=std::nullopt) const
Get the previous entry in the same layer and staff. This can be in the previous measure.
Definition Entries.cpp:771
std::optional< size_t > calcNextTupletIndex(std::optional< size_t > currentIndex=0) const
Returns the next higher tuplet index that this entry starts, or std::nullopt if none.
Definition Entries.cpp:703
std::pair< int, int > calcTopBottomStaffPositions() const
Calculates the top and bottom staff positions of the entry, taking into account percussion notes....
Definition Entries.cpp:890
StaffCmper getStaff() const
Get the staff cmper.
Definition Entries.cpp:632
EntryInfoPtr findBeamEnd() const
Finds the end entry of a beamed group.
Definition Entries.cpp:1459
int calcEntrySize() const
Returns the entry size as a percentage, taking into account the beaming.
Definition Entries.cpp:1830
EntryInfoPtr getPreviousSameV() const
Get the previous entry in the frame in the same voice.
Definition Entries.cpp:790
int calcCrossStaffDirectionForAll(DeferredReference< MusxInstanceList< others::StaffUsed > > staffList={}) const
Calculates if this entry has cross-staffed notes all in a single direction.
Definition Entries.cpp:1989
MusxInstance< others::StaffComposite > createCurrentStaff(const std::optional< StaffCmper > &forStaffId=std::nullopt) const
Creates the current StaffComposite for the entry.
Definition Entries.cpp:670
EntryInfoPtr findDisplayEntryForBeamOverBarline() const
Find the display entry for a hidden source entry. The display entry is one or more bars previous to t...
Definition Entries.cpp:1266
bool calcIsTrillToGraceEntry() const
Calculates if this entry is a trill-to entry as created by the Parenthesize Trill-To Notes plugin.
Definition Entries.cpp:2057
int calcIsAuxiliaryPitchMarker() const
Return true if this entry is an auxiliary pitch marker (specifically, a trill-to or gliss-to pitch ma...
Definition Entries.cpp:2046
EntryInfoPtr getNextInVoice(int voice) const
Returns the next entry in the frame in the specified v1/v2 or null if none.
Definition Entries.cpp:814
EntryInfoPtr calcBeamContinuesRightOverBarline() const
Determines if this entry continues a beam across a barline to the next measure.
Definition Entries.cpp:1397
std::optional< StaffCmper > calcCrossedStaffForAll() const
Calculates all the notes in this entry are crossed to the same staff.
Definition Entries.cpp:2013
const std::shared_ptr< const EntryInfo > operator->() const
Allows -> access to the underlying EntryInfo instance.
Definition Entries.cpp:486
bool calcUnbeamed() const
Returns whether this is an unbeamed entry.
Definition Entries.cpp:1043
EntryInfoPtr()
Default constructor.
Definition Entries.h:512
bool calcCreatesSingletonBeamRight() const
Determines if this entry contains a tuplet that creates a singleton beam right. See EntryFrame::Tuple...
Definition Entries.cpp:1093
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:1624
bool calcIsGlissToGraceEntry() const
Calculates if this entry is a gliss-to entry as created by the Parenthesize Trill-To Notes plugin.
Definition Entries.cpp:2080
bool calcIsFullMeasureRest() const
Returns whether this is a full measure rest.
Definition Entries.cpp:1870
util::Fraction calcGlobalActualDuration() const
Calculates the actual duration in global edu, removing any time stretch due to independent time signa...
Definition Entries.cpp:1678
MeasCmper getMeasure() const
Get the measure cmper.
Definition Entries.cpp:634
EntryInfoPtr getNextSameVNoGrace() const
Get the next entry in the frame in the same voice, skipping grace notes.
Definition Entries.cpp:761
std::vector< size_t > findTupletInfo() const
Finds the tuplet info for tuplets that include this entry.
Definition Entries.cpp:1934
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:1795
Information an entry along with the entry.
Definition Entries.h:1473
unsigned graceIndex
Definition Entries.h:1492
ClefIndex clefIndex
the clef index in effect for the entry.
Definition Entries.h:1494
util::Fraction calcNextElapsedDuration() const
Calculates the next duration position after this entry.
Definition Entries.h:1511
util::Fraction cumulativeRatio
Definition Entries.h:1490
util::Fraction elapsedDuration
Definition Entries.h:1486
ClefIndex clefIndexConcert
the concert clef index in effect for the entry.
Definition Entries.h:1495
util::Fraction actualDuration
Definition Entries.h:1488
MusxInstance< Entry > getEntry() const
Get the entry.
Definition Entries.h:1500
Represents an entry containing metadata and notes.
Definition Entries.h:338
bool splitStem
Definition Entries.h:386
Entry(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, EntryNumber entnum, EntryNumber prev, EntryNumber next)
Constructor function.
Definition Entries.h:344
EntryNumber getEntryNumber() const
Gets the entry number for this entry.
Definition Entries.h:426
bool articDetail
Indicates there is an articulation on the entry.
Definition Entries.h:368
bool upStemScore
Whether a stem is up or down as set in the score. (Only reliable when freezeStemScore is true....
Definition Entries.h:388
bool isNote
If this value is false, the entry is a rest.
Definition Entries.h:361
bool noLeger
Hide ledger lines.
Definition Entries.h:393
MusxInstance< Entry > getNext() const
Gets the next entry in this list or nullptr if none.
Definition Entries.cpp:49
bool noPlayback
Indicates that the entry should not be played back.
Definition Entries.h:399
bool voice2
This is a V2 note. (xml node <v2>)
Definition Entries.h:363
bool splitRest
Indicates that rests in different layers are not combined on this entry.
Definition Entries.h:371
bool beamExt
Indicates that there is a beam extension on the entry.
Definition Entries.h:375
bool createdByHP
Indicates the entry was created by Finale's smart playback engine.
Definition Entries.h:364
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Entries.h:477
MusxInstance< Entry > getPrevious() const
Gets the previous entry in this list or nullptr if none.
Definition Entries.cpp:59
bool secBeam
Signifies a secondary beam break occurs on the entry.
Definition Entries.h:379
bool stemDetail
Indicates there are stem modifications.
Definition Entries.h:381
bool slashGrace
Definition Entries.h:395
bool isValid
Should always be true but otherwise appears to be used internally by Finale.
Definition Entries.h:360
bool playDisabledByHP
Used by Finale's smart playback engine.
Definition Entries.h:365
bool flipTie
Indicates the existence of a flipped tie, either in Speedy Entry or Layer Attributes.
Definition Entries.h:376
bool flatBeam
Forces any beam that starts on this entry to be flat by default.
Definition Entries.h:398
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:404
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:465
bool dummy
Definition Entries.h:390
Evpu hOffsetScore
Manual offset created with the Note Position Tool in the score. (xml node is <posi>....
Definition Entries.h:359
bool checkAccis
Used by Finale to convert pre-2014 .mus files. May never be saved in .musx.
Definition Entries.h:389
bool noteDetail
Indicates there is a note detail or EntrySize record for the entry.
Definition Entries.h:367
util::Fraction calcFraction() const
Calculates the duration as a util::Fraction of a whole note.
Definition Entries.h:450
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:455
bool crossStaff
Signifies that at least one note in the entry has been cross staffed.
Definition Entries.h:382
bool floatRest
Is floating rest. If false, the first note element gives the staff position of the rest.
Definition Entries.h:373
bool smartShapeDetail
Indicates this entry has a smart shape assignment.
Definition Entries.h:392
Edu duration
Duration of the entry, not taking into account tuplets.
Definition Entries.h:357
bool isHidden
Indicates the entry is hidden, (xml node is <ignore>)
Definition Entries.h:374
bool tupletStart
Indicates that a tuplet start on the entry.
Definition Entries.h:370
bool lyricDetail
Indicates there is a lyric assignment on the entry.
Definition Entries.h:369
int numNotes
Number of notes in the entry. There is an error if this is not the same as notes.size().
Definition Entries.h:358
bool sorted
Sorted flag.
Definition Entries.h:394
bool reverseDownStem
Indicates that a stem normally down is reversed.
Definition Entries.h:384
bool reverseUpStem
Indicates that a stem normally up is reversed.
Definition Entries.h:383
bool v2Launch
Indicates if this entry (which is voice1) launches a voice2 sequence. (xml node is <controller>)
Definition Entries.h:362
bool doubleStem
Creates a double stem on the entry. (Appears to be exclusive with splitStem.)
Definition Entries.h:385
bool isPossibleFullMeasureRest() const
Returns true if the entry could be a full-measure rest.
Definition Entries.h:462
bool beam
Signifies the start of a beam or singleton entry. (That is, any beam breaks at this entry....
Definition Entries.h:378
bool freezeStemScore
Freeze stem flag in the score. (upStemScore gives the direction.)
Definition Entries.h:380
bool performanceData
Indicates there is performance data on the entry.
Definition Entries.h:372
bool noSpacing
Indicates that the entry should be ignored when calculating music spacing.
Definition Entries.h:400
bool dotTieAlt
Indicates dot or tie alterations are present.
Definition Entries.h:377
bool freezeBeam
Freeze beam flag (Derived from the presence of <freezeBeam> node.)
Definition Entries.h:401
struct musx::dom::Entry::EntryLocation location
The location of this entry.
bool graceNote
Indicate the entry is a grace note.
Definition Entries.h:366
Duration calcDurationInfo() const
Calculates the NoteType and number of augmentation dots. (See calcDurationInfoFromEdu....
Definition Entries.h:444
static void calcLocations(const DocumentPtr &document)
Calculates the locations for all entries in the document. This function is normally only called by th...
Definition Entries.cpp:104
KeyContext
Indicates whether to compute key signature values in concert or written pitch.
Definition CommonClasses.h:203
Provides optional per-type extension methods for MusxInstanceList.
Definition MusxInstance.h:103
Wraps an EntryInfo instance and a note index.
Definition Entries.h:1520
size_t getNoteIndex() const
Gets the note index for this note.
Definition Entries.h:1565
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:2820
EntryInfoPtr getEntryInfo() const
Gets the entry info for this note.
Definition Entries.h:1560
MusxInstance< others::PercussionNoteInfo > calcPercussionNoteInfo() const
Calculates the percussion note info for this note, if any.
Definition Entries.cpp:2862
MusxInstance< Note > operator->() const
Allows -> access to the underlying Note instance.
Definition Entries.h:1550
std::vector< std::pair< NoteInfoPtr, CurveContourDirection > > calcJumpTieContinuationsFrom() const
Calculates the notes in prior measures that continue a "jump" tie into this note.
Definition Entries.cpp:3126
bool isSameNote(const NoteInfoPtr &src) const
Returns whether the input and the current instance refer to the same note.
Definition Entries.h:1539
StaffCmper calcStaff() const
Calculates the staff number, taking into account cross staffing.
Definition Entries.cpp:2805
NoteInfoPtr getPrevious() const
Gets the next note in a chord on the same entry.
Definition Entries.h:1650
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:2836
bool calcIsEnharmonicRespellInAnyPart() const
Calculates if any linked part has this note enharmonically respelled.
Definition Entries.cpp:2899
NoteInfoPtr calcArpeggiatedTieToNote(CurveContourDirection *tieDirection=nullptr) const
If this note has a smart shape acting as an arpeggio tie, return the tied-to note....
Definition Entries.cpp:2976
bool calcHasPseudoLvTie(CurveContourDirection *tieDirection=nullptr) const
Calculates if this note has a smart shape, shape expression, or shape articulation acting as a laisse...
Definition Entries.cpp:2999
NoteInfoPtr calcTieFrom(bool requireTie=true) const
Calculates the note that this note could tie from.
Definition Entries.cpp:2800
bool calcIsIncludedInVoicing() const
Returns true if this note is included in the part voicing. This function returns the correct value ev...
Definition Entries.cpp:2968
bool calcIsEnharmonicRespell() const
Returns if this note is enharmonically respelled in the current part view.
Definition Entries.cpp:2888
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:1672
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:2852
int calcCrossStaffDirection(DeferredReference< MusxInstanceList< others::StaffUsed > > staffList={}) const
Calculates if this note is cross-staffed and if so, which direction.
Definition Entries.cpp:2945
NoteInfoPtr(const EntryInfoPtr &entryInfo, size_t noteIndex)
Constructor.
Definition Entries.h:1528
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:2795
NoteInfoPtr findEqualPitch(const EntryInfoPtr &entry) const
Finds a note with the same pitch in the supplied entry.
Definition Entries.cpp:2654
NoteInfoPtr getNext() const
Gets the next note in a chord on the same entry.
Definition Entries.h:1639
NoteInfoPtr()
Default constructor.
Definition Entries.h:1523
std::unique_ptr< music_theory::Transposer > createTransposer() const
Creates a transposer for this Note instance.
Definition Entries.cpp:2883
bool calcHasPseudoTieEnd(CurveContourDirection *tieDirection=nullptr) const
Calculates if this note has a smart shape, shape expression, or shape articulation acting as a tie en...
Definition Entries.cpp:3004
Represents a single note element in an entry.
Definition Entries.h:239
bool upStemSecond
When the entry is upstem, it is drawn on the "wrong" side of the stem.
Definition Entries.h:265
bool isValid
Should always be true but otherwise appears to be used internally by Finale.
Definition Entries.h:261
bool playDisabledByHP
Used by Finale's smart playback engine.
Definition Entries.h:276
static constexpr NoteNumber RESTID
Non floating rests have a note with this noteId that defines their staff positions.
Definition Entries.h:248
int harmAlt
Chromatic alteration relative to the key signature. Never has a magnitude greater than +/-7.
Definition Entries.h:260
bool upSplitStem
Definition Entries.h:269
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:281
bool tieEnd
Indicates a tie ends on this note.
Definition Entries.h:263
Note(const DocumentWeakPtr &document, NoteNumber noteId)
Constructor function.
Definition Entries.h:242
bool tieStart
Indicates a tie starts on this note.
Definition Entries.h:262
bool crossStaff
Signifies that the note has a details::CrossStaff note detail.
Definition Entries.h:264
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:2573
int harmLev
Diatonic displacement relative to middle C or to the tonic in the middle C octave (if the key signatu...
Definition Entries.h:259
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:267
std::tuple< music_theory::NoteName, int, int, int > NoteProperties
Note properites. A tuple containing:
Definition Entries.h:257
bool noPlayback
Indicates that this note should not be played back.
Definition Entries.h:273
bool parenAcci
True if the accidental has parentheses.
Definition Entries.h:272
bool noSpacing
Indicates that this note should ignored when calculating spacing.
Definition Entries.h:274
bool showAcci
True if the note has an accidental. (Dynamically changed by Finale unless freezeAcci is set....
Definition Entries.h:271
bool freezeAcci
True if the accidental should be forced on or off (based on showAcci.)
Definition Entries.h:275
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:2608
A context wrapper for GFrameHold associated with a specific part and location.
Definition Entries.h:67
const GFrameHold * operator->() const
Provides const pointer-style access to the underlying GFrameHold.
Definition Entries.h:111
MusxInstance< others::PartVoicing > getPolicyPartVoicing() const
Returns the part voicing for the requested part, based on the document's PartVoicingPolicy.
Definition Entries.h:103
MusxInstance< others::PartVoicing > getPartVoicing() const
Returns the part voicing for the requested part.
Definition Entries.h:95
std::map< LayerIndex, int > calcVoices(bool excludeHidden=false) const
Calculates the number of voices used by the GFrameHold instance.
Definition Entries.cpp:2432
EntryInfoPtr calcNearestEntry(util::Fraction position, bool findExact=true, std::optional< LayerIndex > matchLayer=std::nullopt, std::optional< bool > matchVoice2=std::nullopt, util::Fraction atGraceNoteDuration=0) const
Calculates the nearest non-grace-note entry at the given position.
Definition Entries.cpp:2512
std::shared_ptr< const EntryFrame > createEntryFrame(LayerIndex layerIndex) const
Returns the EntryFrame for all entries in the given layer.
Definition Entries.cpp:2295
util::Fraction getTimeOffset() const
Return the time offset applied to entries in this instance. One reason this might be non-zero is if t...
Definition Entries.h:202
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:130
util::Fraction calcMinLegacyPickupSpacer() const
Calculates the minimum legacy pickup spacer, if any.
Definition Entries.cpp:2544
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:2413
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:2487
bool calcVoicingIncludesLayer(LayerIndex layerIndex) const
Calculates if the part voicing for the current requested part includes the specified layer....
Definition Entries.cpp:2561
bool calcPolicyVoicingIncludesLayer(LayerIndex layerIndex) const
Similar to calcVoicingIncludesLayer, but honoring the document's part voicing policy.
Definition Entries.h:196
Cmper getRequestedPartId() const
Returns the requested part ID associated with this context.
Definition Entries.h:87
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:2461
Represents the attributes of a Finale frame holder.
Definition Details.h:1096
A class to represent fractions with integer m_numerator and m_denominator, automatically reduced to s...
Definition Fraction.h:38
static constexpr Fraction fromEdu(dom::Edu edu)
Constructs a Fraction from edu.
Definition Fraction.h:93
constexpr dom::Edu calcEduDuration() const
Calculates duration as a fraction of a whole note. The result is rounded to the nearest integer Edu v...
Definition Fraction.h:142
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
CurveContourDirection
Curve contour direction for ties and slurs.
Definition EnumClasses.h:62
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 > Duration
Expresses a duration as a NoteType and a number of dots (unsigned)
Definition CommonClasses.h:54
unsigned calcNumberOfBeamsInEdu(Edu duration)
Returns the number of beams implied by an EDU duration.
Definition Entries.cpp:91
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
Duration calcDurationInfoFromEdu(Edu duration)
Calculates the NoteType and number of dots in an Edu value.
Definition Entries.cpp:69
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:1160
size_t startIndex
the index of the first entry in the tuplet
Definition Entries.h:1162
bool calcCreatesSingletonBeamRight() const
Calculates if this tuplet is being used to create a singleton beam to the right.
Definition Entries.h:1221
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:1169
bool calcIsTremolo() const
Calculates if this tuplet represents a tremolo based on the following criteria.
Definition Entries.cpp:281
size_t endIndex
the index of the last entry in the tuplet
Definition Entries.h:1163
bool includesEntry(const EntryInfoPtr &entryInfo) const
Return true if the entry is part of this tuplet.
Definition Entries.h:1187
util::Fraction endDura
the actual duration where the tuplet ends
Definition Entries.h:1165
size_t numEntries() const
Return the number of entries in the tuplet.
Definition Entries.h:1176
util::Fraction startDura
the actual duration where the tuplet starts
Definition Entries.h:1164
bool calcCreatesSingletonBeamLeft() const
Calculates if this tuplet is being used to create a singleton beam to the left.
Definition Entries.h:1233
MusxInstance< details::TupletDef > tuplet
the tuplet
Definition Entries.h:1161
bool voice2
whether this tuplet is for voice2
Definition Entries.h:1166
bool calcCreatesTimeStretch() const
Detects tuplets being used to create time stretch in an independent time signature.
Definition Entries.cpp:427
The location of this entry as calculated by calcLocations, which is called by the factory.
Definition Entries.h:412
void clear()
Clears the entry location. (Mainly used for benchmarking.)
Definition Entries.h:421
size_t entryIndex
The 0-based index of this entry within its layer.
Definition Entries.h:416
bool found() const
Returns if this entry has been found.
Definition Entries.h:419
MeasCmper measureId
The measure containing this entry.
Definition Entries.h:414
LayerIndex layerIndex
The layer containing this entry within the measure.
Definition Entries.h:415
StaffCmper staffId
The staff containing this entry.
Definition Entries.h:413