MUSX Document Model
Loading...
Searching...
No Matches
CommonClasses.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 <numeric>
25#include <filesystem>
26#include <array>
27
28#include "musx/util/Fraction.h"
29#include "BaseClasses.h"
30#include "EnumClasses.h"
31
32namespace music_theory {
33class Transposer;
34enum class DiatonicMode : int;
35struct Pitch;
36} // namespace music_theory
37
38namespace musx {
39namespace dom {
40
41class EntryInfoPtr;
42
43namespace details { // forward declarations
45class LyricAssign;
46} // namespace details
47
48namespace others { // forward declarations
49class Measure;
50class OssiaHeader;
51class Staff;
52} // namespace others
53
55using Duration = std::pair<NoteType, unsigned>;
56
57// This file contains common classes that are shared among Options, Others, and Details.
58
67{
68public:
74 FontInfo(const DocumentWeakPtr& document, bool sizeIsPercent = false)
75 : CommonClassBase(document), m_sizeIsPercent(sizeIsPercent)
76 {
77 }
78
80 int fontSize{};
81 bool bold{};
82 bool italic{};
83 bool underline{};
84 bool strikeout{};
85 bool absolute{};
86 bool hidden{};
87
90 bool isSame(const FontInfo& src) const
91 {
92 return fontId == src.fontId && fontSize == src.fontSize && m_sizeIsPercent == src.m_sizeIsPercent
93 && getEnigmaStyles() == src.getEnigmaStyles();
94 }
95
97 bool getSizeIsPercent() const { return m_sizeIsPercent; }
98
102 inline static constexpr uint16_t EnigmaStyleBold = 0x01;
103 inline static constexpr uint16_t EnigmaStyleItalic = 0x02;
104 inline static constexpr uint16_t EnigmaStyleUnderline = 0x04;
105 inline static constexpr uint16_t EnigmaStyleStrikeout = 0x20;
106 inline static constexpr uint16_t EnigmaStyleAbsolute = 0x40;
107 inline static constexpr uint16_t EnigmaStyleHidden = 0x80;
109
114 std::string getName() const;
115
121 void setFontIdByName(const std::string& name);
122
129 void setEnigmaStyles(uint16_t efx)
130 {
131 bold = efx & EnigmaStyleBold;
137 }
138
140 uint16_t getEnigmaStyles() const
141 {
142 uint16_t result = 0;
143 if (bold) result |= EnigmaStyleBold;
144 if (italic) result |= EnigmaStyleItalic;
145 if (underline) result |= EnigmaStyleUnderline;
146 if (strikeout) result |= EnigmaStyleStrikeout;
147 if (absolute) result |= EnigmaStyleAbsolute;
148 if (hidden) result |= EnigmaStyleHidden;
149 return result;
150 }
151
154 { return fontId == 0; }
155
157 bool calcIsSymbolFont() const;
158
161 static std::optional<std::filesystem::path> calcSMuFLMetaDataPath(const std::string& fontName);
162
164 std::optional<std::filesystem::path> calcSMuFLMetaDataPath() const
166
170 bool calcIsSMuFL() const;
171
177 static std::vector<std::filesystem::path> calcSMuFLPaths();
178
180
181private:
182 bool m_sizeIsPercent;
183};
184
190{
191public:
193
204 enum class KeyContext {
205 Concert,
206 Written
207 };
208
215 uint16_t key{};
216 bool keyless{};
218
233 Cmper getKeyMode() const { return isLinear() ? key >> 8 : key; }
234
239 { return isLinear() ? int(int8_t(key & 0xff)) + getAlterationOffset(ctx) : 0; }
240
241 bool isLinear() const { return (key & 0xC000) == 0; }
242 bool isNonLinear() const { return (key & 0xC000) != 0; }
243 bool isBuiltIn() const { return isLinear() && getKeyMode() <= 1; }
244 bool isMajor() const { return getKeyMode() == 0; }
245 bool isMinor() const { return getKeyMode() == 1; }
246
250 std::optional<music_theory::DiatonicMode> calcDiatonicMode() const;
251
253 bool isSame(const KeySignature& src) const
254 {
255 return isSameConcert(src) && m_alterationOffset == src.m_alterationOffset && m_octaveDisplacement == src.m_octaveDisplacement;
256 }
257
259 bool isSameConcert(const KeySignature& src) const
260 {
261 return key == src.key && keyless == src.keyless && hideKeySigShowAccis == src.hideKeySigShowAccis;
262 }
263
267 int calcScaleDegree(int displacement) const;
268
285 void setTransposition(int interval, int keyAdjustment, bool simplify);
286
289
293 int calcTonalCenterIndex(KeyContext ctx) const;
294
298 int calcAlterationOnNote(unsigned noteIndex, KeyContext ctx ) const;
299
308 [[nodiscard]]
309 music_theory::Pitch calcPitch(int displacement, int alteration, KeyContext ctx) const;
310
314 { return ctx == KeyContext::Written ? m_octaveDisplacement : 0; }
315
317 int calcEDODivisions() const;
318
320 std::optional<std::vector<int>> calcKeyMap() const;
321
326 std::unique_ptr<music_theory::Transposer> createTransposer(int displacement, int alteration) const;
327
328 void integrityCheck(const std::shared_ptr<EnigmaBase>& ptrToThis) override
329 {
330 this->CommonClassBase::integrityCheck(ptrToThis);
331 if (key >= 0x8000) {
332 MUSX_INTEGRITY_ERROR("Key signature has invalid key value: " + std::to_string(key));
333 }
334 }
335
337
338private:
339 std::vector<unsigned> calcTonalCenterArrayForSharps() const;
340 std::vector<unsigned> calcTonalCenterArrayForFlats() const;
341 std::vector<unsigned> calcTonalCenterArray(KeyContext ctx) const;
342 std::vector<int> calcAcciAmountsArray(KeyContext ctx) const;
343 std::vector<unsigned> calcAcciOrderArray(KeyContext ctx) const;
344
345 int m_octaveDisplacement{};
346 int m_alterationOffset{};
347
348 int getAlterationOffset(KeyContext ctx) const
349 { return ctx == KeyContext::Written ? m_alterationOffset : 0; }
350
351};
352
353namespace texts {
354class LyricsTextBase; // forward delcaration
355} // namespace texts
356
362{
363public:
370 LyricsLineInfo(const DocumentWeakPtr& document, Cmper requestedPartId, std::string_view type, Cmper lyricNo, Evpu baseline) :
371 CommonClassBase(document), baselinePosition(baseline), lyricsType(type), lyricNumber(lyricNo), assignments(document, requestedPartId)
372 {
373 }
374
376 std::string_view lyricsType;
379};
380
386{
387public:
388 std::string syllable;
392
393private:
398 class StyleSpan
399 {
400 public:
401 size_t start; // start byte
402 size_t end; // end byte (exclusive)
403 size_t styleIndex; // index into LyricsTextBase's style table
404 };
405
413 LyricsSyllableInfo(const DocumentWeakPtr& document, const std::string text, bool before, bool after, int underscores, std::vector<StyleSpan>&& enigmaStyleMap)
414 : DocumentElementNoPart(document), syllable(text), hasHyphenBefore(before), hasHyphenAfter(after), strippedUnderscores(underscores), m_enigmaStyleMap(std::move(enigmaStyleMap))
415 {
416 }
417
418 std::vector<StyleSpan> m_enigmaStyleMap;
419
420 friend class texts::LyricsTextBase;
421};
422
435{
436public:
438 constexpr MusicPoint() = default;
439
443 constexpr MusicPoint(MeasCmper measId, util::Fraction pos)
444 : measureId(measId), position(pos)
445 {
446 }
447
450
454 [[nodiscard]]
455 constexpr bool operator==(const MusicPoint& other) const
456 { return measureId == other.measureId && position == other.position; }
457
461 [[nodiscard]]
462 constexpr bool operator!=(const MusicPoint& other) const
463 { return !(*this == other); }
464
468 [[nodiscard]]
469 constexpr bool operator<(const MusicPoint& other) const
470 { return measureId < other.measureId || (measureId == other.measureId && position < other.position); }
471
475 [[nodiscard]]
476 constexpr bool operator<=(const MusicPoint& other) const
477 { return *this < other || *this == other; }
478
482 [[nodiscard]]
483 constexpr bool operator>(const MusicPoint& other) const
484 { return other < *this; }
485
489 [[nodiscard]]
490 constexpr bool operator>=(const MusicPoint& other) const
491 { return other <= *this; }
492};
493
504{
505public:
512 explicit MusicRange(const DocumentWeakPtr& document, MeasCmper startMeasId, util::Fraction startPos, MeasCmper endMeasId, util::Fraction endPos)
513 : MusicRange(document, MusicPoint(startMeasId, startPos), MusicPoint(endMeasId, endPos))
514 {
515 }
516
521 explicit MusicRange(const DocumentWeakPtr& document, MusicPoint startPoint, MusicPoint endPoint)
522 : DocumentElementNoPart(document), start(startPoint), end(endPoint)
523 {
524 }
525
528
532 bool contains(MeasCmper measId, util::Fraction position) const
533 { return contains(MusicPoint(measId, position)); }
534
537 bool contains(const MusicPoint& point) const
538 { return start <= point && point <= end; }
539
541 // The MusicRange must be expressed in the Staff EDUs of the entry.
543 bool contains(const EntryInfoPtr& entryInfo) const;
544
548 [[nodiscard]]
549 std::optional<MusicPoint> nextLocation(const std::optional<StaffCmper>& forStaff = std::nullopt) const;
550};
551
557{
558public:
561 enum class Abbreviation
562 {
564 Numeric,
566 };
567
570 {
571 std::vector<util::Fraction> counts;
573 std::vector<Edu> units;
576
578 bool operator==(const TimeSigComponent& src) const
579 { return counts == src.counts && units == src.units; }
580
583 { return std::accumulate(counts.begin(), counts.end(), util::Fraction{}); }
584
586 Edu sumUnits() const
587 { return std::accumulate(units.begin(), units.end(), Edu{}); }
588
591 static std::pair<util::Fraction, Edu> normalizeCompoundUnit(util::Fraction count, Edu unit);
592
597 };
598
599 std::vector<TimeSigComponent> components;
600
605 std::pair<util::Fraction, NoteType> calcSimplified() const;
606
609 {
610 util::Fraction result = std::accumulate(components.begin(), components.end(), util::Fraction{},
611 [](const util::Fraction& acc, const TimeSigComponent& comp)
612 { return acc + (comp.sumCounts() * comp.sumUnits()); }
613 );
614 return result / Edu(NoteType::Whole);
615 }
616
626 util::Fraction calcBeatValueAt(Edu eduPosition) const;
627
629 bool isSame(const TimeSignature& src) const;
630
635 {
636 checkIndex(index);
637 return MusxInstance<TimeSignature>(new TimeSignature(getDocument(), components[index], m_abbreviation));
638 }
639
644 std::optional<char32_t> getAbbreviatedSymbol() const;
645
647 bool isCommonTime() const;
649 bool isCutTime() const;
650
651private:
652 void checkIndex(size_t index) const
653 {
654 if (index > components.size()) {
655 throw std::invalid_argument("Index out of range. The time signature has " + std::to_string(components.size())
656 + " elements. The index requested was " + std::to_string(index) + ".");
657 }
658 }
659
661 explicit TimeSignature(const DocumentWeakPtr& document, int beats, Edu unit, bool hasCompositeTop, bool hasCompositeBottom,
662 Abbreviation abbreviate = {});
663
665 explicit TimeSignature(const DocumentWeakPtr& document, const TimeSigComponent& timeSigUnit, Abbreviation abbreviate = {})
666 : DocumentElementNoPart(document), m_abbreviation(abbreviate)
667 {
668 components.push_back(timeSigUnit);
669 }
670
671 Abbreviation m_abbreviation{};
672
673 friend class others::Measure;
674 friend class others::OssiaHeader;
675 friend class details::IndependentStaffDetails;
676};
677
678namespace others {
679
680// The following classes are defined here because they are shared by multiple subclasses and container classes.
681
686class Enclosure : public OthersBase
687{
688public:
693 enum class Shape : uint8_t
694 {
695 NoEnclosure = 0,
696 Rectangle = 1,
697 Ellipse = 2,
698 Triangle = 3,
699 Diamond = 4,
700 Pentagon = 5,
701 Hexagon = 6,
702 Heptagon = 7,
703 Octogon = 8
704 };
705
713 explicit Enclosure(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All, Cmper cmper = 0)
714 : OthersBase(document, partId, shareMode, cmper) {}
715
723 bool fixedSize{};
724 bool equalAspect{};
725 bool notTall{};
726 bool opaque{};
728
730};
731
742{
743public:
752 explicit EnigmaMusicRange(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All,
753 Cmper cmper = 0, std::optional<Inci> inci = std::nullopt)
754 : OthersBase(document, partId, shareMode, cmper, inci)
755 {
756 }
757
762
766 bool contains(MeasCmper measId, Edu eduPosition) const
767 {
768 return (startMeas < measId || (startMeas == measId && startEdu <= eduPosition)) &&
769 (endMeas > measId || (endMeas == measId && endEdu >= eduPosition));
770 }
771
778
782 std::optional<MusicPoint> nextLocation(const std::optional<StaffCmper>& forStaff = std::nullopt) const
783 { return createMusicRange().nextLocation(forStaff); }
784
786};
787
796{
797public:
798
806 explicit NamePositioning(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All, Cmper cmper = 0)
807 : OthersBase(document, partId, shareMode, cmper) {}
808
812 bool indivPos{};
814 bool expand{};
815
817};
818
819} // namespace others
820} // namespace dom
821} // namespace mux
EnigmaBase class for classes that are commonly used among others, details, entries,...
Definition BaseClasses.h:161
CommonClassBase(const DocumentWeakPtr &document)
Constructs a CommonClassBase object.
Definition BaseClasses.h:170
Base for DOM classes that belong to a Document.
Definition DocumentElement.h:103
DocumentElementNoPart(const DocumentWeakPtr &document)
Constructs the document element (with no meaningful associated part)
Definition DocumentElement.h:112
DocumentPtr getDocument() const
Gets a reference to the Document.
Definition DocumentElement.h:58
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:91
virtual void integrityCheck(const std::shared_ptr< EnigmaBase > &ptrToThis)
Performs a final consistency check after population.
Definition BaseClasses.h:125
Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ow...
Definition Entries.h:553
Represents the default font settings for a particular element type.
Definition CommonClasses.h:67
static constexpr uint16_t EnigmaStyleHidden
Hidden text bit.
Definition CommonClasses.h:107
static constexpr uint16_t EnigmaStyleItalic
Italic style bit.
Definition CommonClasses.h:103
FontInfo(const DocumentWeakPtr &document, bool sizeIsPercent=false)
constructor
Definition CommonClasses.h:74
static constexpr uint16_t EnigmaStyleStrikeout
Strikeout style bit.
Definition CommonClasses.h:105
bool calcIsSymbolFont() const
Calculates if this is a symbol font. (See others::FontDefinition::calcIsSymbolFont....
Definition CommonClasses.cpp:182
static constexpr uint16_t EnigmaStyleUnderline
Underline style bit.
Definition CommonClasses.h:104
uint16_t getEnigmaStyles() const
Returns the font styles as an nfx bitmask.
Definition CommonClasses.h:140
static constexpr uint16_t EnigmaStyleAbsolute
Fixed-size (absolute) bit.
Definition CommonClasses.h:106
static constexpr uint16_t EnigmaStyleBold
Bold style bit.
Definition CommonClasses.h:102
bool strikeout
Strikeout effect.
Definition CommonClasses.h:84
void setFontIdByName(const std::string &name)
Sets the id of the font from a string name.
Definition CommonClasses.cpp:111
Cmper fontId
Font identifier. This is a Cmper for others::FontDefinition.
Definition CommonClasses.h:79
static std::vector< std::filesystem::path > calcSMuFLPaths()
Returns the standard SMuFL font folder.
Definition CommonClasses.cpp:190
bool calcIsSMuFL() const
Calculates whether this is a SMuFL font.
Definition CommonClasses.cpp:145
std::string getName() const
Get the name of the font.
Definition CommonClasses.cpp:103
static const xml::XmlElementArray< FontInfo > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool getSizeIsPercent() const
If true, the size of this font is calculated as a percent of the preceding font size (in an Enigma st...
Definition CommonClasses.h:97
bool isSame(const FontInfo &src) const
Return true if the two fonts represent the same font.
Definition CommonClasses.h:90
void setEnigmaStyles(uint16_t efx)
Set style effects based on a bitmask. This is mainly useful for capturing text styles from enigma str...
Definition CommonClasses.h:129
bool italic
Italic effect.
Definition CommonClasses.h:82
bool hidden
Hidden effect.
Definition CommonClasses.h:86
bool calcIsDefaultMusic() const
Calculates if this is the default music font.
Definition CommonClasses.h:153
int fontSize
Font size or percent (where 100 is 100%) of preceding font size. (See getSizeIsPercent....
Definition CommonClasses.h:80
bool underline
Underline effect.
Definition CommonClasses.h:83
bool absolute
Fixed size effect.
Definition CommonClasses.h:85
std::optional< std::filesystem::path > calcSMuFLMetaDataPath() const
Returns the filepath of the SMuFL font's metadata json file, if any.
Definition CommonClasses.h:164
bool bold
Bold effect.
Definition CommonClasses.h:81
Shared key signature class that is contained in other classes. (See others::Measure)
Definition CommonClasses.h:190
void integrityCheck(const std::shared_ptr< EnigmaBase > &ptrToThis) override
Performs a final consistency check after population.
Definition CommonClasses.h:328
Cmper getKeyMode() const
Returns the key mode.
Definition CommonClasses.h:233
bool isSame(const KeySignature &src) const
returns whether the two key signatures represent the same key signature, taking into account transpos...
Definition CommonClasses.h:253
int getAlteration(KeyContext ctx) const
For linear keys, returns the number of sharps or flats from -7..7 (if any).
Definition CommonClasses.h:238
bool hideKeySigShowAccis
Instead of a key signature, show accidentals for the key on the notes where they occur.
Definition CommonClasses.h:217
int calcScaleDegree(int displacement) const
Calculates the scale degree for the given displacement, where 0 is the tonic.
Definition CommonClasses.cpp:435
bool isLinear() const
whether this is a linear key
Definition CommonClasses.h:241
int calcEDODivisions() const
Calculates the number of EDO division for the key. (The standard value is 12.)
Definition CommonClasses.cpp:519
bool isBuiltIn() const
whether this is a built-in key
Definition CommonClasses.h:243
KeyContext
Indicates whether to compute key signature values in concert or written pitch.
Definition CommonClasses.h:204
@ Written
Use written pitch (with transposition)
@ Concert
Use concert pitch (untransposed)
music_theory::Pitch calcPitch(int displacement, int alteration, KeyContext ctx) const
Converts a key-relative pitch representation into a spelled pitch.
Definition CommonClasses.cpp:421
int calcTonalCenterIndex(KeyContext ctx) const
Calculates the tonal center index for the key, where C=0, D=1, E=2, ...
Definition CommonClasses.cpp:378
int getOctaveDisplacement(KeyContext ctx) const
The octave displacement if this key is a transposed key.
Definition CommonClasses.h:313
uint16_t key
16-bit value intepreted as follows:
Definition CommonClasses.h:215
std::unique_ptr< music_theory::Transposer > createTransposer(int displacement, int alteration) const
Creates a transposer for this KeySignature instance.
Definition CommonClasses.cpp:527
std::optional< music_theory::DiatonicMode > calcDiatonicMode() const
If this key specifies a diatonic mode, returns the mode. This value is independent of EDO divisions....
Definition CommonClasses.cpp:532
void setTransposition(int interval, int keyAdjustment, bool simplify)
Transposes the key by the specified amounts. Set them to zero to remove transposition.
Definition CommonClasses.cpp:446
int calcAlterationOnNote(unsigned noteIndex, KeyContext ctx) const
Calculates the amount of alteration on a note int the key.
Definition CommonClasses.cpp:389
bool isMinor() const
whether this is a built-in minor key
Definition CommonClasses.h:245
bool isNonLinear() const
whether this is a non-linear key
Definition CommonClasses.h:242
static const xml::XmlElementArray< KeySignature > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool isSameConcert(const KeySignature &src) const
returns whether the two key signatures represent the same concert key signature, ignoring transpositi...
Definition CommonClasses.h:259
bool isMajor() const
whether this is a built-in major key
Definition CommonClasses.h:244
std::optional< std::vector< int > > calcKeyMap() const
Calculates the key's diatonic key map.
Definition CommonClasses.cpp:481
bool keyless
Indicates the absence of a key signature.
Definition CommonClasses.h:216
Contains information about a line of lyrics on a system.
Definition CommonClasses.h:362
std::string_view lyricsType
the type of lyric ("chorus", "verse", or "section", corresponding to the xml tags for lyrics text)
Definition CommonClasses.h:376
MusxInstanceList< details::LyricAssign > assignments
The lyric assignments on this line. They all share the same lyricNumber value.
Definition CommonClasses.h:378
Evpu baselinePosition
baseline position of this line on this system, relative to the staff's reference line
Definition CommonClasses.h:375
Cmper lyricNumber
the text number for all lyric assignments on this line.
Definition CommonClasses.h:377
LyricsLineInfo(const DocumentWeakPtr &document, Cmper requestedPartId, std::string_view type, Cmper lyricNo, Evpu baseline)
Constructor function.
Definition CommonClasses.h:370
Contains the syllable information for a single syllable. (See texts::LyricsTextBase)
Definition CommonClasses.h:386
bool hasHyphenAfter
indicates the syllable if followed by a hyphen.
Definition CommonClasses.h:390
int strippedUnderscores
indicates the number of trailing underscores stripped (because smart word extensions convert them to ...
Definition CommonClasses.h:391
std::string syllable
the syllable text with no hyphenation or font information.
Definition CommonClasses.h:388
bool hasHyphenBefore
indicates the syllable is preceded by a hyphen.
Definition CommonClasses.h:389
Utility class that represents a single location in musical time.
Definition CommonClasses.h:435
constexpr bool operator>=(const MusicPoint &other) const
Greater-than-or-equal-to comparison operator.
Definition CommonClasses.h:490
constexpr bool operator!=(const MusicPoint &other) const
Inequality comparison operator.
Definition CommonClasses.h:462
constexpr bool operator<=(const MusicPoint &other) const
Less-than-or-equal-to comparison operator.
Definition CommonClasses.h:476
util::Fraction position
Position within the measure, where 1/4 is a quarter note value.
Definition CommonClasses.h:449
constexpr bool operator>(const MusicPoint &other) const
Greater-than comparison operator.
Definition CommonClasses.h:483
constexpr MusicPoint()=default
Constructs a MusicPoint at measure 1, position 0.
constexpr bool operator==(const MusicPoint &other) const
Equality comparison operator.
Definition CommonClasses.h:455
constexpr MusicPoint(MeasCmper measId, util::Fraction pos)
Constructs a MusicPoint object.
Definition CommonClasses.h:443
MeasCmper measureId
Measure ID of the point.
Definition CommonClasses.h:448
constexpr bool operator<(const MusicPoint &other) const
Less-than comparison operator.
Definition CommonClasses.h:469
Utility class that represents of a range of musical time.
Definition CommonClasses.h:504
MusicPoint end
Ending point in the range.
Definition CommonClasses.h:527
MusicRange(const DocumentWeakPtr &document, MeasCmper startMeasId, util::Fraction startPos, MeasCmper endMeasId, util::Fraction endPos)
Constructs a MusicRange object.
Definition CommonClasses.h:512
std::optional< MusicPoint > nextLocation(const std::optional< StaffCmper > &forStaff=std::nullopt) const
Returns the next metric location following the music range.
Definition CommonClasses.cpp:550
MusicPoint start
Starting point in the range.
Definition CommonClasses.h:526
bool contains(MeasCmper measId, util::Fraction position) const
Returns true of the given metric location is contained in this MusicRange instance.
Definition CommonClasses.h:532
bool contains(const MusicPoint &point) const
Returns true if the given metric location is contained in this MusicRange instance.
Definition CommonClasses.h:537
MusicRange(const DocumentWeakPtr &document, MusicPoint startPoint, MusicPoint endPoint)
Constructs a MusicRange object.
Definition CommonClasses.h:521
Provides optional per-type extension methods for MusxInstanceList.
Definition MusxInstance.h:118
EnigmaBase class for all "others" types.
Definition BaseClasses.h:244
Shared time signature class that is derived from other classes. (See others::Measure)
Definition CommonClasses.h:557
bool isSame(const TimeSignature &src) const
returns whether the two time signatures represent the same time signature
Definition CommonClasses.cpp:664
Abbreviation
Specifies whether a time signature is displayed in numeric or abbreviated form.
Definition CommonClasses.h:562
@ NotApplicable
The time signature is not for display, so abbreviation is inapplicable. (Default)
@ Numeric
Display the numeric time signature (e.g., 4/4 or 2/2).
@ Abbreviated
Display the abbreviated time signature when available (i.e., common time or cut time).
util::Fraction calcBeatValueAt(Edu eduPosition) const
Returns the beat value (duration) at the given EDU position.
Definition CommonClasses.cpp:752
bool isCutTime() const
Returns if this time signature is cut time.
Definition CommonClasses.cpp:683
std::vector< TimeSigComponent > components
the components in the time signature
Definition CommonClasses.h:599
util::Fraction calcTotalDuration() const
Calculates the total duration of the time signature as a fraction of a whole note.
Definition CommonClasses.h:608
std::optional< char32_t > getAbbreviatedSymbol() const
Returns the abbreviated symbol (code point) for this time signature, or std::nullopt if none.
Definition CommonClasses.cpp:636
bool isCommonTime() const
Returns if this time signature is common time.
Definition CommonClasses.cpp:675
MusxInstance< TimeSignature > createComponent(size_t index) const
Creates a time signature corresponding to the component at index.
Definition CommonClasses.h:634
std::pair< util::Fraction, NoteType > calcSimplified() const
Calculates the simplest form of of this time signature, expressed as a fractional count of NoteType u...
Definition CommonClasses.cpp:722
Represents independent time and key signature overrides for a staff.
Definition Details.h:1216
Contains assignment data for a lyric assignment (a single syllable)
Definition Details.h:1307
Represents the enclosure settings for text expressions.
Definition CommonClasses.h:687
bool notTall
"Enforce Minimum Width": don't let shape get taller than it is wide
Definition CommonClasses.h:725
Enclosure(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an Enclosure object.
Definition CommonClasses.h:713
Evpu yAdd
Center Y offset - offsets text from center (in EVPU).
Definition CommonClasses.h:717
bool roundCorners
Whether the enclosure has rounded corners.
Definition CommonClasses.h:727
Efix lineWidth
Line thickness in 64ths of an EVPU (EFIX).
Definition CommonClasses.h:720
static const xml::XmlElementArray< Enclosure > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool opaque
Whether the enclosure is opaque.
Definition CommonClasses.h:726
Shape
Enumeration for enclosure shapes.
Definition CommonClasses.h:694
Evpu yMargin
Half height - extra space on top/bottom sides (in EVPU).
Definition CommonClasses.h:719
Shape shape
Enclosure shape (default: NoEnclosure).
Definition CommonClasses.h:721
bool fixedSize
Whether the enclosure is fixed size (ignore text bounding box)
Definition CommonClasses.h:723
bool equalAspect
"Match Height and Width"
Definition CommonClasses.h:724
Efix cornerRadius
Corner radius (in EFIX).
Definition CommonClasses.h:722
Evpu xMargin
Half width - extra space on left/right sides (in EVPU).
Definition CommonClasses.h:718
Evpu xAdd
Center X offset - offsets text from center (in EVPU).
Definition CommonClasses.h:716
The representation of a range of music used by Enigma files.
Definition CommonClasses.h:742
MeasCmper startMeas
Starting measure in the range.
Definition CommonClasses.h:758
std::optional< MusicPoint > nextLocation(const std::optional< StaffCmper > &forStaff=std::nullopt) const
Returns the next metric location following the music range.
Definition CommonClasses.h:782
MeasCmper endMeas
Ending measure in the range.
Definition CommonClasses.h:760
MusicRange createMusicRange() const
Creates a MusicRange instance corresponding to this instance. The MusicRange uses util::Fraction for ...
Definition CommonClasses.h:774
Edu startEdu
Starting EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:759
Edu endEdu
Ending EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:761
EnigmaMusicRange(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0, std::optional< Inci > inci=std::nullopt)
Constructs a EnigmaMusicRange object.
Definition CommonClasses.h:752
bool contains(MeasCmper measId, Edu eduPosition) const
Returns true of the given metric location is contained in this EnigmaMusicRange instance.
Definition CommonClasses.h:766
static const xml::XmlElementArray< EnigmaMusicRange > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
Represents the attributes of a measure.
Definition Others.h:1146
Contains horizontal and vertical offsets, alignment, and expansion settings for name positioning.
Definition CommonClasses.h:796
bool indivPos
Indicates that this positioning overrides the default positioning. (Not used by options::StaffOptions...
Definition CommonClasses.h:812
NamePositioning(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an NamePositioning object.
Definition CommonClasses.h:806
bool expand
"Expand Single Word"
Definition CommonClasses.h:814
Evpu horzOff
Horizontal distance from staff in Evpu.
Definition CommonClasses.h:809
AlignJustify hAlign
Horizontal alignment for the name text. (xml node is <halign>)
Definition CommonClasses.h:813
AlignJustify justify
Justification for the name text.
Definition CommonClasses.h:811
Evpu vertOff
Vertical offset from staff in Evpu.
Definition CommonClasses.h:810
static const xml::XmlElementArray< NamePositioning > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
Header properties for an ossia passage (clef, key, time, grouping).
Definition Ossia.h:71
Represents the definition of a Finale staff.
Definition Staff.h:54
Base class for lyrics text.
Definition Texts.h:123
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
A dependency-free, header-only collection of useful functions for music theory.
DiatonicMode
Represents the seven standard diatonic musical modes.
Definition music_theory.hpp:110
int16_t MeasCmper
Enigma meas Cmper (may be negative when not applicable)
Definition Fundamentals.h:66
int32_t Efix
EFIX value (64 per EVPU, 64*288=18432 per inch)
Definition Fundamentals.h:62
std::shared_ptr< const T > MusxInstance
Defines the type of a musx instance stored in a pool.
Definition MusxInstance.h:40
constexpr Cmper SCORE_PARTID
The part id of the score.
Definition Fundamentals.h:81
int32_t Evpu
EVPU value (288 per inch)
Definition Fundamentals.h:59
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:57
int32_t Edu
"Enigma Durational Units" value (1024 per quarter note)
Definition Fundamentals.h:63
std::pair< NoteType, unsigned > Duration
Expresses a duration as a NoteType and a number of dots (unsigned)
Definition CommonClasses.h:55
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition DocumentElement.h:37
AlignJustify
Alignment and justification options for staff and group names.
Definition EnumClasses.h:30
std::vector< XmlElementDescriptor< T > > XmlElementArray
an array type for XmlElementDescriptor instances.
Definition XmlInterface.h:127
object model for musx file (enigmaxml)
Definition BaseClasses.h:38
A spelled pitch, expressed relative to C4.
Definition music_theory.hpp:83
A single time signature component.
Definition CommonClasses.h:570
std::vector< util::Fraction > counts
Definition CommonClasses.h:571
std::vector< Edu > units
Definition CommonClasses.h:573
util::Fraction sumCounts() const
Compute the sum of all counts.
Definition CommonClasses.h:582
TimeSigComponent normalizeCompound() const
Returns a copy of this component normalized for compound meter. For example, 2 dotted quarters become...
Definition CommonClasses.cpp:707
static std::pair< util::Fraction, Edu > normalizeCompoundUnit(util::Fraction count, Edu unit)
Normalizes a single time signature count and unit to a power-of-two unit.
Definition CommonClasses.cpp:691
Edu sumUnits() const
Compute the sum of all units.
Definition CommonClasses.h:586
bool operator==(const TimeSigComponent &src) const
Test if two TimeSigComponent values are the same.
Definition CommonClasses.h:578