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
88 GFrameHoldContext(const MusxInstance<GFrameHold>& gfHold, util::Fraction timeOffset = 0);
89
95 [[nodiscard]]
96 Cmper getRequestedPartId() const { return m_requestedPartId; }
97
103 [[nodiscard]]
104 MusxInstance<others::PartVoicing> getPartVoicing() const { return m_partVoicing; }
105
111 [[nodiscard]]
113 { return m_honorPartVoicing ? m_partVoicing : nullptr; }
114
120 const GFrameHold* operator->() const { return m_hold.get(); }
121
127 explicit operator bool() const noexcept { return static_cast<bool>(m_hold); }
128
132 [[nodiscard]]
133 ClefIndex calcClefIndexAt(Edu position) const;
134
138 [[nodiscard]]
140 { return calcClefIndexAt(position.calcEduDuration()); }
141
147 [[nodiscard]]
148 std::shared_ptr<const EntryFrame> createEntryFrame(LayerIndex layerIndex) const;
149
157 bool iterateEntries(LayerIndex layerIndex, std::function<bool(const EntryInfoPtr&)> iterator) const;
158
164 bool iterateEntries(std::function<bool(const EntryInfoPtr&)> iterator) const;
165
169 [[nodiscard]]
170 std::map<LayerIndex, int> calcVoices(bool excludeHidden = false) const;
171
174 [[nodiscard]]
175 bool calcIsCuesOnly(bool includeVisibleInScore = false) const;
176
185 [[nodiscard]]
186 EntryInfoPtr calcNearestEntry(util::Fraction position, bool findExact = true, std::optional<LayerIndex> matchLayer = std::nullopt,
187 MatchVoice matchVoice = MatchVoice::Any, util::Fraction atGraceNoteDuration = 0) const;
188
195 util::Fraction snapLocationToEntryOrKeep(util::Fraction location, bool findExact = true) const;
196
202 [[nodiscard]]
204
209 [[nodiscard]]
210 bool calcVoicingIncludesLayer(LayerIndex layerIndex) const;
211
213 [[nodiscard]]
215 { return !m_honorPartVoicing || calcVoicingIncludesLayer(layerIndex); }
216
219 [[nodiscard]]
220 util::Fraction getTimeOffset() const { return m_timeOffset; }
221
222private:
224 Cmper m_requestedPartId{};
225 util::Fraction m_timeOffset;
227 bool m_honorPartVoicing{};
228};
229
230} // namespace details
231
242
248unsigned calcNumberOfBeamsInEdu(Edu duration);
249
256class Note : public Base
257{
258public:
260 explicit Note(const DocumentWeakPtr& document, NoteNumber noteId)
261 : Base(document, 0, ShareMode::All), m_noteId(noteId)
262 {
263 }
264
266 static constexpr NoteNumber RESTID = 31;
267
275 using NoteProperties = std::tuple<music_theory::NoteName, int, int, int>;
276
277 int harmLev{};
278 int harmAlt{};
279 bool isValid{};
280 bool tieStart{};
281 bool tieEnd{};
282 bool crossStaff{};
287 bool upSplitStem{};
289 bool showAcci{};
290 bool parenAcci{};
291 bool noPlayback{};
292 bool noSpacing{};
293 bool freezeAcci{};
295
298 [[nodiscard]]
299 NoteNumber getNoteId() const { return m_noteId; }
300
311 [[nodiscard]]
312 std::pair<int, int> calcDefaultEnharmonic(const MusxInstance<KeySignature>& key) const;
313
339 [[nodiscard]]
341 const MusxInstance<others::PercussionNoteInfo>& percNoteInfo, const MusxInstance<others::Staff>& staff = nullptr, bool respellEnharmonic = false) const;
342
344
345private:
346 NoteNumber m_noteId{};
347};
348
355class Entry : public Base
356{
357public:
362 explicit Entry(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, EntryNumber entnum, EntryNumber prev, EntryNumber next)
363 : Base(document, partId, shareMode), m_entnum(entnum), m_prev(prev), m_next(next)
364 {
365 }
366
376 int numNotes{};
378 bool isValid{};
379 bool isNote{};
380 bool v2Launch{};
381 bool voice2{};
382 bool createdByHP{};
384 bool graceNote{};
385 bool noteDetail{};
386 bool articDetail{};
387 bool lyricDetail{};
388 bool tupletStart{};
389 bool splitRest{};
391 bool floatRest{};
392 bool isHidden{};
393 bool beamExt{};
394 bool flipTie{};
395 bool dotTieAlt{};
396 bool beam{};
397 bool secBeam{};
399 bool stemDetail{};
400 bool crossStaff{};
403 bool doubleStem{};
404 bool splitStem{};
406 bool upStemScore{};
407 bool checkAccis{};
408 bool dummy{};
411 bool noLeger{};
412 bool sorted{};
413 bool slashGrace{};
416 bool flatBeam{};
417 bool noPlayback{};
418 bool noSpacing{};
419 bool freezeBeam{};
420
422 std::vector<std::shared_ptr<Note>> notes;
423
430 {
434 size_t entryIndex{};
435
437 bool found() const { return staffId != 0 && measureId != 0; }
439 void clear() { *this = {}; }
441
443 [[nodiscard]]
444 EntryNumber getEntryNumber() const { return m_entnum; }
445
449 [[nodiscard]]
451
455 [[nodiscard]]
457
461 [[nodiscard]]
463
467 [[nodiscard]]
469
472 [[nodiscard]]
473 bool hasStem() const { return duration < Edu(NoteType::Whole); }
474
479 [[nodiscard]]
481 { return !isNote && !isHidden && duration == Edu(NoteType::Whole); }
482
483 void integrityCheck(const std::shared_ptr<Base>& ptrToThis) override
484 {
485 this->Base::integrityCheck(ptrToThis);
486 if (size_t(numNotes) != notes.size()) {
487 MUSX_INTEGRITY_ERROR("Entry " + std::to_string(m_entnum) + " has an incorrect number of notes.");
488 }
489 }
490
493 static void calcLocations(const DocumentPtr& document);
494
495 constexpr static std::string_view XmlNodeName = "entry";
497
498private:
499 EntryNumber m_entnum{};
500 EntryNumber m_prev{};
501 EntryNumber m_next{};
502};
503
504class EntryInfo;
505class EntryFrame;
506class NoteInfoPtr;
507
512{
513public:
517 {
518 Normal,
519 IncludeAll,
525 };
526
527 class InterpretedIterator;
528
530 EntryInfoPtr() : m_entryFrame(nullptr), m_indexInFrame(0) {}
531
537 explicit EntryInfoPtr(const std::shared_ptr<const EntryFrame>& entryFrame, size_t index = 0)
538 : m_entryFrame(entryFrame), m_indexInFrame(index) {}
539
550 [[nodiscard]]
551 static EntryInfoPtr fromEntryNumber(const DocumentPtr& document, Cmper partId, EntryNumber entryNumber, util::Fraction timeOffset = 0);
552
554 const std::shared_ptr<const EntryInfo> operator->() const;
555
557 operator bool() const noexcept;
558
560 [[nodiscard]] int getVoice() const;
561
564 [[nodiscard]] bool isSameEntry(const EntryInfoPtr& src) const;
565
574 [[nodiscard]] bool calcIsSamePitchContent(const EntryInfoPtr& src, bool compareConcert = true) const;
575
588 [[nodiscard]]
589 bool calcIsSamePitchContentAndDuration(const EntryInfoPtr& src, bool compareConcert = true, bool requireSameVoice = true, bool requireSameGraceElapsedDura = false) const;
590
603 [[nodiscard]]
604 bool calcContainsPitchContent(const EntryInfoPtr& src, bool compareConcert = true) const;
605
609 [[nodiscard]]
610 NoteInfoPtr findNoteId(NoteNumber noteId) const;
611
613 [[nodiscard]] std::shared_ptr<const EntryFrame> getFrame() const { return m_entryFrame; }
614
616 [[nodiscard]] size_t getIndexInFrame() const { return m_indexInFrame; }
617
619 [[nodiscard]] LayerIndex getLayerIndex() const;
620
622 [[nodiscard]] StaffCmper getStaff() const;
623
626 [[nodiscard]] MusxInstance<others::StaffComposite> createCurrentStaff(const std::optional<StaffCmper>& forStaffId = std::nullopt) const;
627
629 [[nodiscard]] MeasCmper getMeasure() const;
630
632 [[nodiscard]] MusxInstance<KeySignature> getKeySignature() const;
633
636
639 [[nodiscard]] Evpu calcManuaOffset() const;
640
642 [[nodiscard]] unsigned calcReverseGraceIndex() const;
643
647 [[nodiscard]] util::Fraction calcGraceElapsedDuration() const;
648
650 [[nodiscard]] std::optional<size_t> calcNextTupletIndex(std::optional<size_t> currentIndex = 0) const;
651
653 [[nodiscard]] EntryInfoPtr getNextInFrame() const;
654
658 [[nodiscard]] EntryInfoPtr getNextInLayer(std::optional<MeasCmper> targetMeasure = std::nullopt) const;
659
663 [[nodiscard]] EntryInfoPtr getNextSameV() const;
664
667 [[nodiscard]] EntryInfoPtr getNextSameVNoGrace() const;
668
672 [[nodiscard]] EntryInfoPtr getPreviousInLayer(std::optional<MeasCmper> targetMeasure = std::nullopt) const;
673
675 [[nodiscard]] EntryInfoPtr getPreviousInFrame() const;
676
680 [[nodiscard]] EntryInfoPtr getPreviousSameV() const;
681
684 [[nodiscard]] EntryInfoPtr getPreviousSameVNoGrace() const;
685
691 [[nodiscard]] EntryInfoPtr getNextInVoice(int voice) const;
692
698 [[nodiscard]] EntryInfoPtr getPreviousInVoice(int voice) const;
699
702 [[nodiscard]] InterpretedIterator asInterpretedIterator(bool remapBeamOverBarlineEntries = true) const;
703
705 [[nodiscard]]
707 { return iterateBeamGroup<&EntryInfoPtr::nextPotentialInBeam, &EntryInfoPtr::previousPotentialInBeam>(beamIterationMode); }
708
710 [[nodiscard]]
712 { return iterateBeamGroup<&EntryInfoPtr::previousPotentialInBeam, &EntryInfoPtr::nextPotentialInBeam>(beamIterationMode); }
713
718
723
727 [[nodiscard]] bool calcDisplaysAsRest() const;
728
732 [[nodiscard]] std::pair<int, int> calcTopBottomStaffPositions() const;
733
739 [[nodiscard]] std::pair<bool, bool> calcEntryStemSettings() const;
740
744 [[nodiscard]] bool calcUpStemDefault() const;
745
760 [[nodiscard]] bool calcUpStem() const
761 {
762 if (m_upStem.has_value()) {
763 return m_upStem.value();
764 }
765 m_upStem = calcUpStemImpl();
766 return m_upStem.value();
767 }
768
771 [[nodiscard]] bool calcUnbeamed() const;
772
774 [[nodiscard]] bool calcIsBeamStart(BeamIterationMode beamIterationMode = BeamIterationMode::Normal) const;
775
778 [[nodiscard]] bool calcCreatesSingletonBeamLeft() const;
779
782 [[nodiscard]] bool calcCreatesSingletonBeamRight() const;
783
792
801
806 [[nodiscard]] bool calcIsFeatheredBeamStart(Evpu& outLeftY, Evpu& outRightY) const;
807
812 [[nodiscard]] EntryInfoPtr findBeamStartOrCurrent() const;
813
816 [[nodiscard]] EntryInfoPtr findBeamEnd() const;
817
819 [[nodiscard]] unsigned calcNumberOfBeams() const;
820
824 [[nodiscard]] unsigned calcLowestBeamStart(bool considerBeamOverBarlines = false) const;
825
828 [[nodiscard]] unsigned calcLowestBeamEnd() const;
829
833 [[nodiscard]] unsigned calcLowestBeamEndAcrossBarlines() const;
834
837 [[nodiscard]] unsigned calcLowestBeamStub() const;
838
844 [[nodiscard]] bool calcBeamStubIsLeft() const;
845
847 [[nodiscard]] util::Fraction calcGlobalElapsedDuration() const;
848
850 [[nodiscard]] util::Fraction calcGlobalActualDuration() const;
851
857 [[nodiscard]]
858 bool calcIsImmediatelyFollowedBy(const EntryInfoPtr& nextEntry) const;
859
861 [[nodiscard]] bool calcCanBeBeamed() const;
862
864 [[nodiscard]] bool calcBeamMustStartHere() const;
865
868 [[nodiscard]] int calcEntrySize() const;
869
875 [[nodiscard]] bool calcIsCue(bool includeVisibleInScore = false) const;
876
879 [[nodiscard]] bool calcIsFullMeasureRest() const;
880
884 [[nodiscard]] bool calcIsBeamedRestWorkaroundHiddenRest() const;
885
889 [[nodiscard]] bool calcIsBeamedRestWorkaroundVisibleRest() const;
890
893 [[nodiscard]] std::vector<size_t> findTupletInfo() const;
894
898 [[nodiscard]] bool calcIfLayerSettingsApply() const;
899
910
914 [[nodiscard]] std::optional<StaffCmper> calcCrossedStaffForAll() const;
915
917 [[nodiscard]] bool calcIsSingletonGrace() const;
918
924 [[nodiscard]] int calcIsAuxiliaryPitchMarker() const;
925
936 [[nodiscard]] bool calcIsTrillToGraceEntry() const;
937
945 [[nodiscard]] bool calcIsGlissToGraceEntry() const;
946
952
959
965 [[nodiscard]] EntryInfoPtr findMainEntryForGraceNote(bool ignoreRests = false) const;
966
983 bool iterateStartingSmartShapes(std::function<bool(const MusxInstance<others::SmartShape>&)> callback, bool findExact = false) const;
984
986 bool operator<(const EntryInfoPtr& other) const
987 {
988 if (m_entryFrame != other.m_entryFrame)
989 return m_entryFrame < other.m_entryFrame;
990 return m_indexInFrame < other.m_indexInFrame;
991 }
992
993private:
994 [[nodiscard]] unsigned calcVisibleBeams() const;
995
996 [[nodiscard]] bool calcUpStemImpl() const;
997
998 template<EntryInfoPtr(EntryInfoPtr::* Iterator)() const>
999 [[nodiscard]] std::optional<unsigned> iterateFindRestsInSecondaryBeam(const EntryInfoPtr nextOrPrevInBeam) const;
1000
1001 template<EntryInfoPtr(EntryInfoPtr::* Iterator)() const>
1002 [[nodiscard]] EntryInfoPtr iteratePotentialEntryInBeam() const;
1003
1004 template<EntryInfoPtr(EntryInfoPtr::* Iterator)() const>
1005 [[nodiscard]] bool iterateNotesExistLeftOrRight() const;
1006
1007 [[nodiscard]] EntryInfoPtr nextPotentialInBeam(BeamIterationMode beamIterationMode) const;
1008
1009 [[nodiscard]] EntryInfoPtr previousPotentialInBeam(BeamIterationMode beamIterationMode) const;
1010
1011 using BeamIteratorFn = EntryInfoPtr (EntryInfoPtr::*)(BeamIterationMode) const;
1012 template<BeamIteratorFn Iterator, BeamIteratorFn ReverseIterator>
1013 [[nodiscard]] EntryInfoPtr iterateBeamGroup(BeamIterationMode beamIterationMode) const;
1014
1018 [[nodiscard]] EntryInfoPtr findLeftBeamAnchorForBeamOverBarline() const;
1019
1023 [[nodiscard]] EntryInfoPtr findRightBeamAnchorForBeamOverBarline() const;
1024
1025 std::shared_ptr<const EntryFrame> m_entryFrame;
1026 size_t m_indexInFrame{};
1027
1029 mutable MusxInstance<others::StaffComposite> m_cachedStaff;
1030
1032 mutable std::optional<bool> m_upStem;
1033};
1034
1049// the the caller should use for calculating elapsed time.
1081{
1082 EntryInfoPtr m_entry;
1083 bool m_effectiveHidden{};
1084 // --------
1085 // internal
1086 // --------
1087 EntryInfoPtr m_iteratedEntry;
1088 bool m_useIteratedForBackLaunch{};
1089 bool m_remapBeamOverBarlineEntries{};
1090
1091 [[nodiscard]] const EntryInfoPtr& getIteratedEntry() const noexcept
1092 { return m_iteratedEntry ? m_iteratedEntry : m_entry; }
1093
1094 [[nodiscard]] const EntryInfoPtr& getForwardLaunchEntry() const noexcept
1095 { return getIteratedEntry(); }
1096
1097 [[nodiscard]] const EntryInfoPtr& getBackwardLaunchEntry() const noexcept
1098 { return m_useIteratedForBackLaunch ? getIteratedEntry() : m_entry; }
1099
1103 InterpretedIterator(EntryInfoPtr entry, bool remapBeamOverBarlineEntries);
1104
1105 friend class EntryFrame;
1106 friend class EntryInfoPtr;
1107
1108public:
1111
1114 [[nodiscard]] const EntryInfoPtr& getEntryInfo() const noexcept { return m_entry; }
1115
1119 [[nodiscard]] bool getEffectiveHidden() const noexcept { return m_effectiveHidden; }
1120
1124 [[nodiscard]] util::Fraction getEffectiveActualDuration(bool global = false) const;
1125
1129 [[nodiscard]] util::Fraction getEffectiveElapsedDuration(bool global = false) const;
1130
1134
1137 [[nodiscard]] bool calcIsPastLogicalEndOfFrame() const;
1138
1146 [[nodiscard]] InterpretedIterator getNext() const;
1147
1155 [[nodiscard]] InterpretedIterator getPrevious() const;
1156
1160 explicit operator bool() const noexcept
1161 {
1162 return static_cast<bool>(m_entry);
1163 }
1164};
1165
1172class EntryFrame : public std::enable_shared_from_this<EntryFrame>
1173{
1174public:
1182 explicit EntryFrame(const details::GFrameHoldContext& gfhold, LayerIndex layerIndex, util::Fraction timeStretch, const MusxInstance<others::StaffComposite>& startStaff) :
1183 m_context(gfhold),
1184 m_layerIndex(layerIndex),
1185 m_timeStretch(timeStretch),
1186 m_startStaff(startStaff)
1187 {
1188 }
1189
1192 {
1194 size_t startIndex;
1195 size_t endIndex;
1198 bool voice2;
1199
1201 TupletInfo(const std::weak_ptr<const EntryFrame>& parent, const MusxInstance<details::TupletDef>& tup, size_t index, util::Fraction start, bool forVoice2)
1202 : tuplet(tup), startIndex(index), endIndex((std::numeric_limits<size_t>::max)()),
1203 startDura(start), endDura(-1), voice2(forVoice2), m_parent(parent)
1204 {}
1205
1207 [[nodiscard]]
1208 size_t numEntries() const
1209 {
1210 MUSX_ASSERT_IF(startIndex > endIndex) {
1211 throw std::logic_error("TupletInfo has invalid start and end indices.");
1212 }
1213 return endIndex - startIndex + 1;
1214 }
1215
1218 [[nodiscard]]
1219 bool includesEntry(const EntryInfoPtr& entryInfo) const
1220 {
1221 const size_t x = entryInfo.getIndexInFrame();
1222 return (x >= startIndex && x <= endIndex);
1223 }
1224
1236 [[nodiscard]]
1237 bool calcIsTremolo() const;
1238
1252 [[nodiscard]]
1253 bool calcCreatesSingletonBeamRight() const { return calcCreatesSingleton(false); }
1254
1264 [[nodiscard]]
1265 bool calcCreatesSingletonBeamLeft() const { return calcCreatesSingleton(true); }
1266
1277 // - the independent display time signature matches the tuplet's total display duration
1278 [[nodiscard]]
1279 bool calcCreatesTimeStretch() const;
1280
1281 private:
1282 [[nodiscard]]
1283 bool calcCreatesSingleton(bool left) const;
1284
1285 [[nodiscard]]
1286 const std::shared_ptr<const EntryFrame> getParent() const
1287 {
1288 auto result = m_parent.lock();
1289 MUSX_ASSERT_IF(!result) {
1290 throw std::logic_error("Unable to obtain lock on parent entry frame.");
1291 }
1292 return result;
1293 }
1294
1295 const std::weak_ptr<const EntryFrame> m_parent;
1296 };
1297
1304 std::vector<TupletInfo> tupletInfo;
1309
1311 [[nodiscard]]
1312 DocumentPtr getDocument() const;
1313
1315 [[nodiscard]]
1316 const details::GFrameHoldContext& getContext() const { return m_context; }
1317
1319 [[nodiscard]]
1320 Cmper getRequestedPartId() const { return m_context.getRequestedPartId(); }
1321
1323 [[nodiscard]]
1324 StaffCmper getStaff() const;
1325
1327 [[nodiscard]]
1328 MeasCmper getMeasure() const;
1329
1331 [[nodiscard]]
1332 LayerIndex getLayerIndex() const { return m_layerIndex; }
1333
1335 [[nodiscard]]
1337
1340 [[nodiscard]]
1341 util::Fraction getTimeStretch() const { return m_timeStretch; }
1342
1344 [[nodiscard]]
1345 const std::vector<std::shared_ptr<const EntryInfo>>& getEntries() const
1346 { return m_entries; }
1347
1351 [[nodiscard]]
1352 EntryInfoPtr getFirstInVoice(int voice) const;
1353
1357 [[nodiscard]]
1358 EntryInfoPtr getLastInVoice(int voice) const;
1359
1412 [[nodiscard]]
1413 EntryInfoPtr::InterpretedIterator getFirstInterpretedIterator(int voice, bool remapBeamOverBarlineEntries = true) const;
1414
1416 void addEntry(const std::shared_ptr<const EntryInfo>& entry)
1417 { m_entries.emplace_back(entry); }
1418
1422 [[nodiscard]]
1423 std::shared_ptr<const EntryFrame> getNext(std::optional<MeasCmper> targetMeasure = std::nullopt) const;
1424
1428 [[nodiscard]]
1429 std::shared_ptr<const EntryFrame> getPrevious(std::optional<MeasCmper> targetMeasure = std::nullopt) const;
1430
1432 [[nodiscard]]
1435
1439 [[nodiscard]]
1440 MusxInstance<others::StaffComposite> createCurrentStaff(Edu eduPosition, const std::optional<StaffCmper>& forStaffId = std::nullopt) const;
1441
1443 [[nodiscard]]
1445
1451 [[nodiscard]]
1452 bool calcIsCueFrame(bool includeVisibleInScore = false) const;
1453
1459 [[nodiscard]]
1460 bool calcAreAllEntriesHiddenInFrame() const;
1461
1469 [[nodiscard]]
1470 EntryInfoPtr calcNearestEntry(util::Fraction position, bool findExact = true, MatchVoice matchVoice = MatchVoice::Any,
1471 util::Fraction atGraceNoteDuration = 0) const;
1472
1477 bool iterateEntries(std::function<bool(const EntryInfoPtr&)> iterator) const;
1478
1479private:
1481 LayerIndex m_layerIndex;
1482 util::Fraction m_timeStretch;
1483
1484 std::vector<std::shared_ptr<const EntryInfo>> m_entries;
1485
1488
1490 mutable MusxInstance<others::LayerAttributes> m_cachedLayerAttributes;
1491};
1492
1493namespace details {
1494class GFrameHold;
1495} // namespace details
1496
1506{
1511 explicit EntryInfo(const MusxInstance<Entry>& entry)
1512 : m_entry(entry) {}
1513
1514#ifndef DOXYGEN_SHOULD_IGNORE_THIS
1516#endif
1517
1518public:
1525 unsigned graceIndex{};
1529
1532 [[nodiscard]]
1534 {
1535 auto retval = m_entry.lock();
1536 if (!retval) {
1537 throw std::logic_error("Entry pointer is no longer valid");
1538 }
1539 return retval;
1540 }
1541
1543 [[nodiscard]]
1546
1547private:
1549};
1550
1553{
1554public:
1556 NoteInfoPtr() : m_entry(), m_noteIndex(0) {}
1557
1561 NoteInfoPtr(const EntryInfoPtr& entryInfo, size_t noteIndex)
1562 : m_entry(entryInfo), m_noteIndex(noteIndex)
1563 {}
1564
1566 explicit operator bool() const noexcept
1567 { return m_entry && m_noteIndex < m_entry->getEntry()->notes.size(); }
1568
1571 [[nodiscard]]
1572 bool isSameNote(const NoteInfoPtr& src) const
1573 { return m_entry.isSameEntry(src.m_entry) && m_noteIndex == src.m_noteIndex; }
1574
1578 [[nodiscard]]
1579 NoteInfoPtr findEqualPitch(const EntryInfoPtr& entry) const;
1580
1582 [[nodiscard]]
1584 {
1585 MUSX_ASSERT_IF(m_noteIndex >= m_entry->getEntry()->notes.size()) {
1586 throw std::logic_error("Note index is too large for notes array.");
1587 }
1588 return m_entry->getEntry()->notes[m_noteIndex];
1589 }
1590
1592 [[nodiscard]]
1594 { return m_entry; }
1595
1597 [[nodiscard]]
1598 size_t getNoteIndex() const
1599 { return m_noteIndex; }
1600
1614 [[nodiscard]]
1615 Note::NoteProperties calcNoteProperties(EnharmonicOverride enharmonicOverride = EnharmonicOverride::None, bool alwaysUseEntryStaff = false) const;
1616
1624 [[nodiscard]]
1625 Note::NoteProperties calcNotePropertiesConcert(bool alwaysUseEntryStaff = false) const;
1626
1635 [[nodiscard]]
1636 Note::NoteProperties calcNotePropertiesInView(bool alwaysUseEntryStaff = false) const;
1637
1640 [[nodiscard]]
1642
1645 [[nodiscard]]
1647
1651 [[nodiscard]]
1652 NoteInfoPtr calcTieTo() const;
1653
1658 [[nodiscard]]
1659 NoteInfoPtr calcTieFrom(bool requireTie = true) const;
1660
1666 [[nodiscard]]
1667 CurveContourDirection calcEffectiveTieDirection(bool forTieEnd = false) const;
1675 [[nodiscard]] bool calcHasOuterTie(bool forTieEnd = false) const;
1676
1684 [[nodiscard]] bool calcHasInnerTie(bool forTieEnd = false) const;
1685
1687 [[nodiscard]]
1688 StaffCmper calcStaff() const;
1689
1692 [[nodiscard]]
1693 std::unique_ptr<music_theory::Transposer> createTransposer() const;
1694
1697 [[nodiscard]]
1699 {
1700 if (m_noteIndex >= m_entry->getEntry()->notes.size()) {
1701 return NoteInfoPtr();
1702 }
1703 return NoteInfoPtr(m_entry, m_noteIndex + 1);
1704 }
1705
1708 [[nodiscard]]
1710 {
1711 if (m_noteIndex <= 0) {
1712 return NoteInfoPtr();
1713 }
1714 return NoteInfoPtr(m_entry, m_noteIndex - 1);
1715 }
1716
1718 [[nodiscard]]
1719 bool calcIsEnharmonicRespell() const;
1720
1730 [[nodiscard]]
1731 std::pair<int, int> calcDefaultEnharmonic() const
1732 { return (*this)->calcDefaultEnharmonic(m_entry.getKeySignature()); }
1733
1736 [[nodiscard]]
1738
1748 [[nodiscard]]
1750
1753 [[nodiscard]]
1754 bool calcIsIncludedInVoicing() const;
1755
1758 [[nodiscard]]
1759 bool calcIsTop() const;
1760
1763 [[nodiscard]]
1764 bool calcIsBottom() const;
1765
1772 [[nodiscard]]
1773 NoteInfoPtr calcArpeggiatedTieToNote(CurveContourDirection* tieDirection = nullptr) const;
1774
1782 [[nodiscard]]
1783 bool calcHasPseudoLvTie(CurveContourDirection* tieDirection = nullptr) const;
1784
1792 [[nodiscard]]
1793 bool calcHasPseudoTieEnd(CurveContourDirection* tieDirection = nullptr) const;
1794
1801 [[nodiscard]]
1802 std::vector<std::pair<NoteInfoPtr, CurveContourDirection>> calcJumpTieContinuationsFrom() const;
1803
1804private:
1805 enum class TieFromSearchAction {
1806 Continue,
1807 Accept,
1808 Stop,
1809 };
1810
1811 static NoteInfoPtr findTieFromCandidate(const NoteInfoPtr& note, Cmper previousMeasure,
1812 const std::function<TieFromSearchAction(const NoteInfoPtr&, bool)>& decide);
1813
1817 [[nodiscard]]
1818 bool calcPseudoTieInternal(utils::PseudoTieMode mode, CurveContourDirection* tieDirection) const;
1819
1823 [[nodiscard]]
1824 bool selectPseudoTieDirection(CurveContourDirection* tieDirection,
1825 std::vector<CurveContourDirection>& directions,
1826 const std::vector<size_t>* eligibleNoteIndices = nullptr) const;
1827
1831 [[nodiscard]]
1832 bool isSamePitch(const NoteInfoPtr& src) const;
1833
1837 [[nodiscard]]
1838 bool isSamePitchValues(const NoteInfoPtr& src) const;
1839
1842 [[nodiscard]]
1843 NoteInfoPtr calcTieToWithNextMeasure(Cmper nextMeasure) const;
1844
1848 [[nodiscard]]
1849 NoteInfoPtr calcTieFromWithPreviousMeasure(Cmper previousMeasure, bool requireTie) const;
1850
1851 EntryInfoPtr m_entry;
1852 size_t m_noteIndex;
1853
1855 mutable std::optional<CurveContourDirection> m_tieDirection{};
1856};
1857
1858} // namespace dom
1859} // 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:1173
util::Fraction getTimeStretch() const
Get the time stretch in this frame. Rather than accessing this value directly, consider using EntryIn...
Definition Entries.h:1341
util::Fraction maxElapsedStaffDuration
Definition Entries.h:1307
EntryFrame(const details::GFrameHoldContext &gfhold, LayerIndex layerIndex, util::Fraction timeStretch, const MusxInstance< others::StaffComposite > &startStaff)
Constructor function.
Definition Entries.h:1182
util::Fraction measureStaffDuration
The duration of the measure in staff duration units.
Definition Entries.h:1306
EntryInfoPtr getLastInVoice(int voice) const
Returns the last entry in the specified v1/v2 or null if none.
Definition Entries.cpp:158
MusxInstance< others::StaffComposite > getStartStaffInstance() const
Gets the staff at eduPosition 0 without needing to create it again.
Definition Entries.h:1433
bool calcAreAllEntriesHiddenInFrame() const
Calculates if this all notes in the frame are hidden. This routine only checks that entries are indiv...
Definition Entries.cpp:232
EntryInfoPtr calcNearestEntry(util::Fraction position, bool findExact=true, MatchVoice matchVoice=MatchVoice::Any, util::Fraction atGraceNoteDuration=0) const
Calculates the nearest non-grace-note entry at the given position.
Definition Entries.cpp:243
MeasCmper getMeasure() const
Get the measure for the entry frame.
Definition Entries.cpp:132
MusxInstance< others::Measure > getMeasureInstance() const
Get the measure instance.
Definition Entries.cpp:211
void addEntry(const std::shared_ptr< const EntryInfo > &entry)
Add an entry to the list.
Definition Entries.h:1416
const std::vector< std::shared_ptr< const EntryInfo > > & getEntries() const
Get the entry list.
Definition Entries.h:1345
EntryInfoPtr getFirstInVoice(int voice) const
Returns the first entry in the specified v1/v2 or null if none.
Definition Entries.cpp:142
StaffCmper getStaff() const
Get the staff for the entry.
Definition Entries.cpp:130
Cmper getRequestedPartId() const
Get the requested part ID for the entry frame.
Definition Entries.h:1320
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:181
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:202
MusxInstance< KeySignature > keySignature
This can be different than the measure key sig if the staff has independent key signatures.
Definition Entries.h:1305
MusxInstance< others::LayerAttributes > getLayerAttributes() const
Get the LayerAttributes for this entry frame.
Definition Entries.cpp:134
const details::GFrameHoldContext & getContext() const
Get the frame context for this frame.
Definition Entries.h:1316
LayerIndex getLayerIndex() const
Get the layer index (0..3) of the entry frame.
Definition Entries.h:1332
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:285
DocumentPtr getDocument() const
Get the document for the entry frame.
Definition Entries.cpp:128
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:190
std::vector< TupletInfo > tupletInfo
A list of the tuplets in the frame and their calculated starting and ending information.
Definition Entries.h:1304
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:168
bool calcIsCueFrame(bool includeVisibleInScore=false) const
Calculates if this entry frame is part of a cue.
Definition Entries.cpp:216
Iterator-style wrapper for workaround-aware voice traversal.
Definition Entries.h:1081
const EntryInfoPtr & getEntryInfo() const noexcept
Returns the entry at the current iterator position.
Definition Entries.h:1114
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:2240
InterpretedIterator getNext() const
Returns an iterator advanced to the next usable entry in this voice.
Definition Entries.cpp:2275
util::Fraction getEffectiveMeasureStaffDuration() const
Return the effective measure staff duration of the entry. Calling code using InterpretedIterator shou...
Definition Entries.cpp:2235
InterpretedIterator getPrevious() const
Returns an iterator advanced to the previous usable entry in this voice.
Definition Entries.cpp:2287
bool getEffectiveHidden() const noexcept
Returns whether the entry should be treated as hidden.
Definition Entries.h:1119
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:2219
util::Fraction getEffectiveElapsedDuration(bool global=false) const
Return the effective elapsed duration of the entry. Calling code using InterpretedIterator should use...
Definition Entries.cpp:2227
Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ow...
Definition Entries.h:512
bool calcUpStemDefault() const
Calculates if the entry is upstem by default, without considering voices, layers, staff options,...
Definition Entries.cpp:967
EntryInfoPtr getNextInFrame() const
Get the next entry in the frame.
Definition Entries.cpp:760
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:908
bool calcIsBeamStart(BeamIterationMode beamIterationMode=BeamIterationMode::Normal) const
Returns whether this is the start of a primary beam.
Definition Entries.cpp:1120
bool calcBeamMustStartHere() const
Determines if a beam must start on this entry.
Definition Entries.cpp:1115
EntryInfoPtr(const std::shared_ptr< const EntryFrame > &entryFrame, size_t index=0)
Constructor function.
Definition Entries.h:537
EntryInfoPtr getNextSameV() const
Get the next entry in the frame in the same voice.
Definition Entries.cpp:768
bool calcCanBeBeamed() const
Determines if this entry can be beamed.
Definition Entries.cpp:1102
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:1368
size_t getIndexInFrame() const
Returns the index within the frame.
Definition Entries.h:616
util::Fraction calcGlobalElapsedDuration() const
Calculates the elapsed duration in global edu, removing any time stretch due to independent time sign...
Definition Entries.cpp:1723
std::pair< bool, bool > calcEntryStemSettings() const
Returns the Entry stem settings for the current requested part. This function encapsulates handling o...
Definition Entries.cpp:686
EntryInfoPtr calcBeamContinuesLeftOverBarline() const
Determines if this entry continues a beam across a barline from the previous measure.
Definition Entries.cpp:1403
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:706
bool calcIfLayerSettingsApply() const
Calculates whether the conditions are met for the layer attributes dependent on others::LayerAttribut...
Definition Entries.cpp:1998
EntryInfoPtr getPreviousInVoice(int voice) const
Returns the previous entry in the frame in the specified v1/v2 or null if none.
Definition Entries.cpp:876
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:2157
unsigned calcReverseGraceIndex() const
Caclulates the grace index counting leftward (used by other standards such as MNX)
Definition Entries.cpp:703
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:475
EntryInfoPtr getPreviousSameVNoGrace() const
Get the previous entry in the frame in the same voice, skipping grace notes.
Definition Entries.cpp:857
MusxInstance< details::EntryPartFieldDetail > getPartFieldData() const
Gets the applicable part data for the entry, or nullptr if none.
Definition Entries.cpp:663
BeamIterationMode
Controls which entries are included when iterating over beams.
Definition Entries.h:517
@ 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:529
bool calcIsImmediatelyFollowedBy(const EntryInfoPtr &nextEntry) const
Returns true if nextEntry starts immediately after (or at) the end of this entry in time.
Definition Entries.cpp:796
Evpu calcManuaOffset() const
Returns the manual offset of the entry for the current requested part. This function encapsulates han...
Definition Entries.cpp:678
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:749
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:1578
bool isSameEntry(const EntryInfoPtr &src) const
Returns whether the input and the current instance refer to the same entry.
Definition Entries.cpp:516
EntryInfoPtr findHiddenSourceForBeamOverBarline() const
Find the hidden source entry for a mid-system beam created by the Beam Over Barline plugin....
Definition Entries.cpp:1241
unsigned calcLowestBeamStub() const
Returns the lowest beam stub at this entry, where 2 = 16th note stub, 3 = 32nd note stub,...
Definition Entries.cpp:1664
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:1964
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:580
util::Fraction calcGraceElapsedDuration() const
Calculates a grace note's symbolic starting duration as a negative offset from the main note....
Definition Entries.cpp:715
unsigned calcLowestBeamEnd() const
Returns the lowest beam number ending at this entry, where 1 = 8th note beam, 2 = 16th note beam,...
Definition Entries.cpp:1620
LayerIndex getLayerIndex() const
Get the layer index (0..3) of the entry.
Definition Entries.cpp:655
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:2084
unsigned calcLowestBeamEndAcrossBarlines() const
Returns the lowest beam number ending at this entry, where 1 = 8th note beam, 2 = 16th note beam,...
Definition Entries.cpp:1643
unsigned calcNumberOfBeams() const
Calculates the number of beams or flags on the entry.
Definition Entries.cpp:1527
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:892
EntryInfoPtr getPreviousInFrame() const
Get the previous entry in the frame.
Definition Entries.cpp:834
std::shared_ptr< const EntryFrame > getFrame() const
Returns the frame.
Definition Entries.h:613
bool calcUpStem() const
Determines the effective stem direction of the entry, taking into account voices, layers,...
Definition Entries.h:760
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:1944
int getVoice() const
Gets the voice as integer value 1 or 2.
Definition Entries.cpp:524
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:616
EntryInfoPtr findBeamStartOrCurrent() const
Finds the first entry of a beamed group or returns the current entry if it is not beams.
Definition Entries.cpp:1492
bool calcDisplaysAsRest() const
Calculates if an entry displays as a rest.
Definition Entries.cpp:924
MusxInstance< KeySignature > getKeySignature() const
Get the key signature of the entry.
Definition Entries.cpp:661
bool calcIsCue(bool includeVisibleInScore=false) const
Calculates if this entry is part of a cue.
Definition Entries.cpp:1894
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:711
InterpretedIterator asInterpretedIterator(bool remapBeamOverBarlineEntries=true) const
Returns this EntryInfoPtr in a InterpretedIterator instance.
Definition Entries.cpp:886
bool calcCreatesSingletonBeamLeft() const
Determines if this entry contains a tuplet that creates a singleton beam left. See EntryFrame::Tuplet...
Definition Entries.cpp:1132
bool operator<(const EntryInfoPtr &other) const
Explicit operator< for std::map.
Definition Entries.h:986
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:823
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:728
std::pair< int, int > calcTopBottomStaffPositions() const
Calculates the top and bottom staff positions of the entry, taking into account percussion notes....
Definition Entries.cpp:942
StaffCmper getStaff() const
Get the staff cmper.
Definition Entries.cpp:657
EntryInfoPtr findBeamEnd() const
Finds the end entry of a beamed group.
Definition Entries.cpp:1509
int calcEntrySize() const
Returns the entry size as a percentage, taking into account the beaming.
Definition Entries.cpp:1880
EntryInfoPtr getPreviousSameV() const
Get the previous entry in the frame in the same voice.
Definition Entries.cpp:842
int calcCrossStaffDirectionForAll(DeferredReference< MusxInstanceList< others::StaffUsed > > staffList={}) const
Calculates if this entry has cross-staffed notes all in a single direction.
Definition Entries.cpp:2039
MusxInstance< others::StaffComposite > createCurrentStaff(const std::optional< StaffCmper > &forStaffId=std::nullopt) const
Creates the current StaffComposite for the entry.
Definition Entries.cpp:695
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:1316
bool calcIsTrillToGraceEntry() const
Calculates if this entry is a trill-to entry as created by the Parenthesize Trill-To Notes plugin.
Definition Entries.cpp:2107
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:2096
EntryInfoPtr getNextInVoice(int voice) const
Returns the next entry in the frame in the specified v1/v2 or null if none.
Definition Entries.cpp:866
EntryInfoPtr calcBeamContinuesRightOverBarline() const
Determines if this entry continues a beam across a barline to the next measure.
Definition Entries.cpp:1447
std::optional< StaffCmper > calcCrossedStaffForAll() const
Calculates all the notes in this entry are crossed to the same staff.
Definition Entries.cpp:2063
const std::shared_ptr< const EntryInfo > operator->() const
Allows -> access to the underlying EntryInfo instance.
Definition Entries.cpp:500
bool calcUnbeamed() const
Returns whether this is an unbeamed entry.
Definition Entries.cpp:1093
NoteInfoPtr findNoteId(NoteNumber noteId) const
Returns a NoteInfoPtr for the note specified by noteId within this entry.
Definition Entries.cpp:644
EntryInfoPtr()
Default constructor.
Definition Entries.h:530
bool calcCreatesSingletonBeamRight() const
Determines if this entry contains a tuplet that creates a singleton beam right. See EntryFrame::Tuple...
Definition Entries.cpp:1143
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:1674
bool calcIsGlissToGraceEntry() const
Calculates if this entry is a gliss-to entry as created by the Parenthesize Trill-To Notes plugin.
Definition Entries.cpp:2130
bool calcIsFullMeasureRest() const
Returns whether this is a full measure rest.
Definition Entries.cpp:1920
util::Fraction calcGlobalActualDuration() const
Calculates the actual duration in global edu, removing any time stretch due to independent time signa...
Definition Entries.cpp:1728
MeasCmper getMeasure() const
Get the measure cmper.
Definition Entries.cpp:659
EntryInfoPtr getNextSameVNoGrace() const
Get the next entry in the frame in the same voice, skipping grace notes.
Definition Entries.cpp:786
std::vector< size_t > findTupletInfo() const
Finds the tuplet info for tuplets that include this entry.
Definition Entries.cpp:1984
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:1845
Information an entry along with the entry.
Definition Entries.h:1506
unsigned graceIndex
Definition Entries.h:1525
ClefIndex clefIndex
the clef index in effect for the entry.
Definition Entries.h:1527
util::Fraction calcNextElapsedDuration() const
Calculates the next duration position after this entry.
Definition Entries.h:1544
util::Fraction cumulativeRatio
Definition Entries.h:1523
util::Fraction elapsedDuration
Definition Entries.h:1519
ClefIndex clefIndexConcert
the concert clef index in effect for the entry.
Definition Entries.h:1528
util::Fraction actualDuration
Definition Entries.h:1521
MusxInstance< Entry > getEntry() const
Get the entry.
Definition Entries.h:1533
Represents an entry containing metadata and notes.
Definition Entries.h:356
bool splitStem
Definition Entries.h:404
Entry(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, EntryNumber entnum, EntryNumber prev, EntryNumber next)
Constructor function.
Definition Entries.h:362
EntryNumber getEntryNumber() const
Gets the entry number for this entry.
Definition Entries.h:444
bool articDetail
Indicates there is an articulation on the entry.
Definition Entries.h:386
bool upStemScore
Whether a stem is up or down as set in the score. (Only reliable when freezeStemScore is true....
Definition Entries.h:406
bool isNote
If this value is false, the entry is a rest.
Definition Entries.h:379
bool noLeger
Hide ledger lines.
Definition Entries.h:411
MusxInstance< Entry > getNext() const
Gets the next entry in this list or nullptr if none.
Definition Entries.cpp:50
bool noPlayback
Indicates that the entry should not be played back.
Definition Entries.h:417
bool voice2
This is a V2 note. (xml node <v2>)
Definition Entries.h:381
bool splitRest
Indicates that rests in different layers are not combined on this entry.
Definition Entries.h:389
bool beamExt
Indicates that there is a beam extension on the entry.
Definition Entries.h:393
bool createdByHP
Indicates the entry was created by Finale's smart playback engine.
Definition Entries.h:382
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Entries.h:495
MusxInstance< Entry > getPrevious() const
Gets the previous entry in this list or nullptr if none.
Definition Entries.cpp:60
bool secBeam
Signifies a secondary beam break occurs on the entry.
Definition Entries.h:397
bool stemDetail
Indicates there are stem modifications.
Definition Entries.h:399
bool slashGrace
Definition Entries.h:413
bool isValid
Should always be true but otherwise appears to be used internally by Finale.
Definition Entries.h:378
bool playDisabledByHP
Used by Finale's smart playback engine.
Definition Entries.h:383
bool flipTie
Indicates the existence of a flipped tie, either in Speedy Entry or Layer Attributes.
Definition Entries.h:394
bool flatBeam
Forces any beam that starts on this entry to be flat by default.
Definition Entries.h:416
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:422
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:483
bool dummy
Definition Entries.h:408
Evpu hOffsetScore
Manual offset created with the Note Position Tool in the score. (xml node is <posi>....
Definition Entries.h:377
bool checkAccis
Used by Finale to convert pre-2014 .mus files. May never be saved in .musx.
Definition Entries.h:407
bool noteDetail
Indicates there is a note detail or EntrySize record for the entry.
Definition Entries.h:385
util::Fraction calcFraction() const
Calculates the duration as a util::Fraction of a whole note.
Definition Entries.h:468
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:473
bool crossStaff
Signifies that at least one note in the entry has been cross staffed.
Definition Entries.h:400
bool floatRest
Is floating rest. If false, the first note element gives the staff position of the rest.
Definition Entries.h:391
bool smartShapeDetail
Indicates this entry has a smart shape assignment.
Definition Entries.h:410
Edu duration
Duration of the entry, not taking into account tuplets.
Definition Entries.h:375
bool isHidden
Indicates the entry is hidden, (xml node is <ignore>)
Definition Entries.h:392
bool tupletStart
Indicates that a tuplet start on the entry.
Definition Entries.h:388
bool lyricDetail
Indicates there is a lyric assignment on the entry.
Definition Entries.h:387
int numNotes
Number of notes in the entry. There is an error if this is not the same as notes.size().
Definition Entries.h:376
bool sorted
Sorted flag.
Definition Entries.h:412
bool reverseDownStem
Indicates that a stem normally down is reversed.
Definition Entries.h:402
bool reverseUpStem
Indicates that a stem normally up is reversed.
Definition Entries.h:401
bool v2Launch
Indicates if this entry (which is voice1) launches a voice2 sequence. (xml node is <controller>)
Definition Entries.h:380
bool doubleStem
Creates a double stem on the entry. (Appears to be exclusive with splitStem.)
Definition Entries.h:403
bool isPossibleFullMeasureRest() const
Returns true if the entry could be a full-measure rest.
Definition Entries.h:480
bool beam
Signifies the start of a beam or singleton entry. (That is, any beam breaks at this entry....
Definition Entries.h:396
bool freezeStemScore
Freeze stem flag in the score. (upStemScore gives the direction.)
Definition Entries.h:398
bool performanceData
Indicates there is performance data on the entry.
Definition Entries.h:390
bool noSpacing
Indicates that the entry should be ignored when calculating music spacing.
Definition Entries.h:418
bool dotTieAlt
Indicates dot or tie alterations are present.
Definition Entries.h:395
bool freezeBeam
Freeze beam flag (Derived from the presence of <freezeBeam> node.)
Definition Entries.h:419
struct musx::dom::Entry::EntryLocation location
The location of this entry.
bool graceNote
Indicate the entry is a grace note.
Definition Entries.h:384
Duration calcDurationInfo() const
Calculates the NoteType and number of augmentation dots. (See calcDurationInfoFromEdu....
Definition Entries.h:462
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:105
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:1553
size_t getNoteIndex() const
Gets the note index for this note.
Definition Entries.h:1598
int calcStaffPosition() const
Calculates the staff position for this note, taking into account percussion notes.
EntryInfoPtr getEntryInfo() const
Gets the entry info for this note.
Definition Entries.h:1593
MusxInstance< others::PercussionNoteInfo > calcPercussionNoteInfo() const
Calculates the percussion note info for this note, if any.
Definition Entries.cpp:2970
MusxInstance< Note > operator->() const
Allows -> access to the underlying Note instance.
Definition Entries.h:1583
bool calcHasInnerTie(bool forTieEnd=false) const
Determines whether this note has an inner tie at the specified endpoint.
Definition Entries.cpp:2892
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:3270
bool isSameNote(const NoteInfoPtr &src) const
Returns whether the input and the current instance refer to the same note.
Definition Entries.h:1572
StaffCmper calcStaff() const
Calculates the staff number, taking into account cross staffing.
Definition Entries.cpp:2902
bool calcIsBottom() const
Return true if this is the bottom note in the entry.
Definition Entries.cpp:3102
CurveContourDirection calcEffectiveTieDirection(bool forTieEnd=false) const
Calculates the effective tie direction for this note, taking into account all options and overrides.
Definition Entries.cpp:2874
NoteInfoPtr getPrevious() const
Gets the next note in a chord on the same entry.
Definition Entries.h:1709
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:2944
bool calcIsEnharmonicRespellInAnyPart() const
Calculates if any linked part has this note enharmonically respelled.
Definition Entries.cpp:3007
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:3120
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:3143
NoteInfoPtr calcTieFrom(bool requireTie=true) const
Calculates the note that this note could tie from.
Definition Entries.cpp:2869
bool calcIsIncludedInVoicing() const
Returns true if this note is included in the part voicing. This function returns the correct value ev...
Definition Entries.cpp:3076
bool calcHasOuterTie(bool forTieEnd=false) const
Determines whether this note has an outer tie at the specified endpoint.
Definition Entries.cpp:2882
bool calcIsEnharmonicRespell() const
Returns if this note is enharmonically respelled in the current part view.
Definition Entries.cpp:2996
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:1731
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:2960
int calcCrossStaffDirection(DeferredReference< MusxInstanceList< others::StaffUsed > > staffList={}) const
Calculates if this note is cross-staffed and if so, which direction.
Definition Entries.cpp:3053
NoteInfoPtr(const EntryInfoPtr &entryInfo, size_t noteIndex)
Constructor.
Definition Entries.h:1561
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:2864
bool calcIsTop() const
Return true if this is the top note in the entry.
Definition Entries.cpp:3084
NoteInfoPtr findEqualPitch(const EntryInfoPtr &entry) const
Finds a note with the same pitch in the supplied entry.
Definition Entries.cpp:2723
NoteInfoPtr getNext() const
Gets the next note in a chord on the same entry.
Definition Entries.h:1698
NoteInfoPtr()
Default constructor.
Definition Entries.h:1556
std::unique_ptr< music_theory::Transposer > createTransposer() const
Creates a transposer for this Note instance.
Definition Entries.cpp:2991
Note::NoteProperties calcNoteProperties(EnharmonicOverride enharmonicOverride=EnharmonicOverride::None, bool alwaysUseEntryStaff=false) const
Calculates the note name, octave number, actual alteration, and staff position. This function does no...
Definition Entries.cpp:2917
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:3148
Represents a single note element in an entry.
Definition Entries.h:257
bool upStemSecond
When the entry is upstem, it is drawn on the "wrong" side of the stem.
Definition Entries.h:283
bool isValid
Should always be true but otherwise appears to be used internally by Finale.
Definition Entries.h:279
bool playDisabledByHP
Used by Finale's smart playback engine.
Definition Entries.h:294
static constexpr NoteNumber RESTID
Non floating rests have a note with this noteId that defines their staff positions.
Definition Entries.h:266
int harmAlt
Chromatic alteration relative to the key signature. Never has a magnitude greater than +/-7.
Definition Entries.h:278
bool upSplitStem
Definition Entries.h:287
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:299
bool tieEnd
Indicates a tie ends on this note.
Definition Entries.h:281
Note(const DocumentWeakPtr &document, NoteNumber noteId)
Constructor function.
Definition Entries.h:260
bool tieStart
Indicates a tie starts on this note.
Definition Entries.h:280
bool crossStaff
Signifies that the note has a details::CrossStaff note detail.
Definition Entries.h:282
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:2642
int harmLev
Diatonic displacement relative to middle C or to the tonic in the middle C octave (if the key signatu...
Definition Entries.h:277
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:285
std::tuple< music_theory::NoteName, int, int, int > NoteProperties
Note properites. A tuple containing:
Definition Entries.h:275
bool noPlayback
Indicates that this note should not be played back.
Definition Entries.h:291
bool parenAcci
True if the accidental has parentheses.
Definition Entries.h:290
bool noSpacing
Indicates that this note should ignored when calculating spacing.
Definition Entries.h:292
bool showAcci
True if the note has an accidental. (Dynamically changed by Finale unless freezeAcci is set....
Definition Entries.h:289
bool freezeAcci
True if the accidental should be forced on or off (based on showAcci.)
Definition Entries.h:293
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:2677
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:120
MusxInstance< others::PartVoicing > getPolicyPartVoicing() const
Returns the part voicing for the requested part, based on the document's PartVoicingPolicy.
Definition Entries.h:112
MusxInstance< others::PartVoicing > getPartVoicing() const
Returns the part voicing for the requested part.
Definition Entries.h:104
std::map< LayerIndex, int > calcVoices(bool excludeHidden=false) const
Calculates the number of voices used by the GFrameHold instance.
Definition Entries.cpp:2490
std::shared_ptr< const EntryFrame > createEntryFrame(LayerIndex layerIndex) const
Returns the EntryFrame for all entries in the given layer.
Definition Entries.cpp:2353
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:220
util::Fraction snapLocationToEntryOrKeep(util::Fraction location, bool findExact=true) const
Snaps a measure position to the nearest entry if possible.
Definition Entries.cpp:2602
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:139
util::Fraction calcMinLegacyPickupSpacer() const
Calculates the minimum legacy pickup spacer, if any.
Definition Entries.cpp:2613
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:2471
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:2545
bool calcVoicingIncludesLayer(LayerIndex layerIndex) const
Calculates if the part voicing for the current requested part includes the specified layer....
Definition Entries.cpp:2630
bool calcPolicyVoicingIncludesLayer(LayerIndex layerIndex) const
Similar to calcVoicingIncludesLayer, but honoring the document's part voicing policy.
Definition Entries.h:214
Cmper getRequestedPartId() const
Returns the requested part ID associated with this context.
Definition Entries.h:96
EntryInfoPtr calcNearestEntry(util::Fraction position, bool findExact=true, std::optional< LayerIndex > matchLayer=std::nullopt, MatchVoice matchVoice=MatchVoice::Any, util::Fraction atGraceNoteDuration=0) const
Calculates the nearest non-grace-note entry at the given position.
Definition Entries.cpp:2570
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:2519
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
MatchVoice
Specifies which voice(s) are considered when matching entries.
Definition EnumClasses.h:128
@ Any
Consider entries from either voice. (Default)
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
EnharmonicOverride
Provides a three-state override option for enharmonic respelling.
Definition EnumClasses.h:108
@ None
Do not override the existing enharmonic state. (Default)
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:92
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:70
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:1192
size_t startIndex
the index of the first entry in the tuplet
Definition Entries.h:1194
bool calcCreatesSingletonBeamRight() const
Calculates if this tuplet is being used to create a singleton beam to the right.
Definition Entries.h:1253
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:1201
bool calcIsTremolo() const
Calculates if this tuplet represents a tremolo based on the following criteria.
Definition Entries.cpp:295
size_t endIndex
the index of the last entry in the tuplet
Definition Entries.h:1195
bool includesEntry(const EntryInfoPtr &entryInfo) const
Return true if the entry is part of this tuplet.
Definition Entries.h:1219
util::Fraction endDura
the actual duration where the tuplet ends
Definition Entries.h:1197
size_t numEntries() const
Return the number of entries in the tuplet.
Definition Entries.h:1208
util::Fraction startDura
the actual duration where the tuplet starts
Definition Entries.h:1196
bool calcCreatesSingletonBeamLeft() const
Calculates if this tuplet is being used to create a singleton beam to the left.
Definition Entries.h:1265
MusxInstance< details::TupletDef > tuplet
the tuplet
Definition Entries.h:1193
bool voice2
whether this tuplet is for voice2
Definition Entries.h:1198
bool calcCreatesTimeStretch() const
Detects tuplets being used to create time stretch in an independent time signature.
Definition Entries.cpp:441
The location of this entry as calculated by calcLocations, which is called by the factory.
Definition Entries.h:430
void clear()
Clears the entry location. (Mainly used for benchmarking.)
Definition Entries.h:439
size_t entryIndex
The 0-based index of this entry within its layer.
Definition Entries.h:434
bool found() const
Returns if this entry has been found.
Definition Entries.h:437
MeasCmper measureId
The measure containing this entry.
Definition Entries.h:432
LayerIndex layerIndex
The layer containing this entry within the measure.
Definition Entries.h:433
StaffCmper staffId
The staff containing this entry.
Definition Entries.h:431