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;
35} // namespace music_theory
36
37namespace musx {
38namespace dom {
39
40class EntryInfoPtr;
41
42namespace details { // forward declarations
44class LyricAssign;
45} // namespace details
46
47namespace others { // forward declarations
48class Measure;
49class OssiaHeader;
50class Staff;
51} // namespace others
52
54using Duration = std::pair<NoteType, unsigned>;
55
56// This file contains common classes that are shared among Options, Others, and Details.
57
66{
67public:
73 FontInfo(const DocumentWeakPtr& document, bool sizeIsPercent = false)
74 : CommonClassBase(document), m_sizeIsPercent(sizeIsPercent)
75 {
76 }
77
79 int fontSize{};
80 bool bold{};
81 bool italic{};
82 bool underline{};
83 bool strikeout{};
84 bool absolute{};
85 bool hidden{};
86
89 bool isSame(const FontInfo& src) const
90 {
91 return fontId == src.fontId && fontSize == src.fontSize && m_sizeIsPercent == src.m_sizeIsPercent
92 && getEnigmaStyles() == src.getEnigmaStyles();
93 }
94
96 bool getSizeIsPercent() const { return m_sizeIsPercent; }
97
101 inline static constexpr uint16_t EnigmaStyleBold = 0x01;
102 inline static constexpr uint16_t EnigmaStyleItalic = 0x02;
103 inline static constexpr uint16_t EnigmaStyleUnderline = 0x04;
104 inline static constexpr uint16_t EnigmaStyleStrikeout = 0x20;
105 inline static constexpr uint16_t EnigmaStyleAbsolute = 0x40;
106 inline static constexpr uint16_t EnigmaStyleHidden = 0x80;
108
113 std::string getName() const;
114
120 void setFontIdByName(const std::string& name);
121
128 void setEnigmaStyles(uint16_t efx)
129 {
130 bold = efx & EnigmaStyleBold;
136 }
137
139 uint16_t getEnigmaStyles() const
140 {
141 uint16_t result = 0;
142 if (bold) result |= EnigmaStyleBold;
143 if (italic) result |= EnigmaStyleItalic;
144 if (underline) result |= EnigmaStyleUnderline;
145 if (strikeout) result |= EnigmaStyleStrikeout;
146 if (absolute) result |= EnigmaStyleAbsolute;
147 if (hidden) result |= EnigmaStyleHidden;
148 return result;
149 }
150
153 { return fontId == 0; }
154
156 bool calcIsSymbolFont() const;
157
160 static std::optional<std::filesystem::path> calcSMuFLMetaDataPath(const std::string& fontName);
161
163 std::optional<std::filesystem::path> calcSMuFLMetaDataPath() const
165
169 bool calcIsSMuFL() const;
170
176 static std::vector<std::filesystem::path> calcSMuFLPaths();
177
179
180private:
181 bool m_sizeIsPercent;
182};
183
189{
190public:
192
203 enum class KeyContext {
204 Concert,
205 Written
206 };
207
214 uint16_t key{};
215 bool keyless{};
217
232 Cmper getKeyMode() const { return isLinear() ? key >> 8 : key; }
233
238 { return isLinear() ? int(int8_t(key & 0xff)) + getAlterationOffset(ctx) : 0; }
239
240 bool isLinear() const { return (key & 0xC000) == 0; }
241 bool isNonLinear() const { return (key & 0xC000) != 0; }
242 bool isBuiltIn() const { return isLinear() && getKeyMode() <= 1; }
243 bool isMajor() const { return getKeyMode() == 0; }
244 bool isMinor() const { return getKeyMode() == 1; }
245
249 std::optional<music_theory::DiatonicMode> calcDiatonicMode() const;
250
252 bool isSame(const KeySignature& src) const
253 {
254 return isSameConcert(src) && m_alterationOffset == src.m_alterationOffset && m_octaveDisplacement == src.m_octaveDisplacement;
255 }
256
258 bool isSameConcert(const KeySignature& src) const
259 {
260 return key == src.key && keyless == src.keyless && hideKeySigShowAccis == src.hideKeySigShowAccis;
261 }
262
266 int calcScaleDegree(int displacement) const;
267
284 void setTransposition(int interval, int keyAdjustment, bool simplify);
285
288
292 int calcTonalCenterIndex(KeyContext ctx) const;
293
297 int calcAlterationOnNote(unsigned noteIndex, KeyContext ctx ) const;
298
302 { return ctx == KeyContext::Written ? m_octaveDisplacement : 0; }
303
305 int calcEDODivisions() const;
306
308 std::optional<std::vector<int>> calcKeyMap() const;
309
314 std::unique_ptr<music_theory::Transposer> createTransposer(int displacement, int alteration) const;
315
316 void integrityCheck(const std::shared_ptr<EnigmaBase>& ptrToThis) override
317 {
318 this->CommonClassBase::integrityCheck(ptrToThis);
319 if (key >= 0x8000) {
320 MUSX_INTEGRITY_ERROR("Key signature has invalid key value: " + std::to_string(key));
321 }
322 }
323
325
326private:
327 std::vector<unsigned> calcTonalCenterArrayForSharps() const;
328 std::vector<unsigned> calcTonalCenterArrayForFlats() const;
329 std::vector<unsigned> calcTonalCenterArray(KeyContext ctx) const;
330 std::vector<int> calcAcciAmountsArray(KeyContext ctx) const;
331 std::vector<unsigned> calcAcciOrderArray(KeyContext ctx) const;
332
333 int m_octaveDisplacement{};
334 int m_alterationOffset{};
335
336 int getAlterationOffset(KeyContext ctx) const
337 { return ctx == KeyContext::Written ? m_alterationOffset : 0; }
338
339};
340
341namespace texts {
342class LyricsTextBase; // forward delcaration
343} // namespace texts
344
350{
351public:
358 LyricsLineInfo(const DocumentWeakPtr& document, Cmper requestedPartId, std::string_view type, Cmper lyricNo, Evpu baseline) :
359 CommonClassBase(document), baselinePosition(baseline), lyricsType(type), lyricNumber(lyricNo), assignments(document, requestedPartId)
360 {
361 }
362
364 std::string_view lyricsType;
367};
368
374{
375public:
376 std::string syllable;
380
381private:
386 class StyleSpan
387 {
388 public:
389 size_t start; // start byte
390 size_t end; // end byte (exclusive)
391 size_t styleIndex; // index into LyricsTextBase's style table
392 };
393
401 LyricsSyllableInfo(const DocumentWeakPtr& document, const std::string text, bool before, bool after, int underscores, std::vector<StyleSpan>&& enigmaStyleMap)
402 : DocumentElementNoPart(document), syllable(text), hasHyphenBefore(before), hasHyphenAfter(after), strippedUnderscores(underscores), m_enigmaStyleMap(std::move(enigmaStyleMap))
403 {
404 }
405
406 std::vector<StyleSpan> m_enigmaStyleMap;
407
408 friend class texts::LyricsTextBase;
409};
410
423{
424public:
426 constexpr MusicPoint() = default;
427
431 constexpr MusicPoint(MeasCmper measId, util::Fraction pos)
432 : measureId(measId), position(pos)
433 {
434 }
435
438
442 [[nodiscard]]
443 constexpr bool operator==(const MusicPoint& other) const
444 { return measureId == other.measureId && position == other.position; }
445
449 [[nodiscard]]
450 constexpr bool operator!=(const MusicPoint& other) const
451 { return !(*this == other); }
452
456 [[nodiscard]]
457 constexpr bool operator<(const MusicPoint& other) const
458 { return measureId < other.measureId || (measureId == other.measureId && position < other.position); }
459
463 [[nodiscard]]
464 constexpr bool operator<=(const MusicPoint& other) const
465 { return *this < other || *this == other; }
466
470 [[nodiscard]]
471 constexpr bool operator>(const MusicPoint& other) const
472 { return other < *this; }
473
477 [[nodiscard]]
478 constexpr bool operator>=(const MusicPoint& other) const
479 { return other <= *this; }
480};
481
492{
493public:
500 explicit MusicRange(const DocumentWeakPtr& document, MeasCmper startMeasId, util::Fraction startPos, MeasCmper endMeasId, util::Fraction endPos)
501 : MusicRange(document, MusicPoint(startMeasId, startPos), MusicPoint(endMeasId, endPos))
502 {
503 }
504
509 explicit MusicRange(const DocumentWeakPtr& document, MusicPoint startPoint, MusicPoint endPoint)
510 : DocumentElementNoPart(document), start(startPoint), end(endPoint)
511 {
512 }
513
516
520 bool contains(MeasCmper measId, util::Fraction position) const
521 { return contains(MusicPoint(measId, position)); }
522
525 bool contains(const MusicPoint& point) const
526 { return start <= point && point <= end; }
527
529 // The MusicRange must be expressed in the Staff EDUs of the entry.
531 bool contains(const EntryInfoPtr& entryInfo) const;
532
536 [[nodiscard]]
537 std::optional<MusicPoint> nextLocation(const std::optional<StaffCmper>& forStaff = std::nullopt) const;
538};
539
545{
546public:
549 enum class Abbreviation
550 {
552 Numeric,
554 };
555
558 {
559 std::vector<util::Fraction> counts;
561 std::vector<Edu> units;
564
566 bool operator==(const TimeSigComponent& src) const
567 { return counts == src.counts && units == src.units; }
568
571 { return std::accumulate(counts.begin(), counts.end(), util::Fraction{}); }
572
574 Edu sumUnits() const
575 { return std::accumulate(units.begin(), units.end(), Edu{}); }
576 };
577
578 std::vector<TimeSigComponent> components;
579
584 std::pair<util::Fraction, NoteType> calcSimplified() const;
585
588 {
589 util::Fraction result = std::accumulate(components.begin(), components.end(), util::Fraction{},
590 [](const util::Fraction& acc, const TimeSigComponent& comp)
591 { return acc + (comp.sumCounts() * comp.sumUnits()); }
592 );
593 return result / Edu(NoteType::Whole);
594 }
595
605 util::Fraction calcBeatValueAt(Edu eduPosition) const;
606
608 bool isSame(const TimeSignature& src) const;
609
614 {
615 checkIndex(index);
616 return MusxInstance<TimeSignature>(new TimeSignature(getDocument(), components[index], m_abbreviation));
617 }
618
623 std::optional<char32_t> getAbbreviatedSymbol() const;
624
626 bool isCommonTime() const;
628 bool isCutTime() const;
629
630private:
631 void checkIndex(size_t index) const
632 {
633 if (index > components.size()) {
634 throw std::invalid_argument("Index out of range. The time signature has " + std::to_string(components.size())
635 + " elements. The index requested was " + std::to_string(index) + ".");
636 }
637 }
638
640 explicit TimeSignature(const DocumentWeakPtr& document, int beats, Edu unit, bool hasCompositeTop, bool hasCompositeBottom,
641 Abbreviation abbreviate = {});
642
644 explicit TimeSignature(const DocumentWeakPtr& document, const TimeSigComponent& timeSigUnit, Abbreviation abbreviate = {})
645 : DocumentElementNoPart(document), m_abbreviation(abbreviate)
646 {
647 components.push_back(timeSigUnit);
648 }
649
650 Abbreviation m_abbreviation{};
651
652 friend class others::Measure;
653 friend class others::OssiaHeader;
654 friend class details::IndependentStaffDetails;
655};
656
657namespace others {
658
659// The following classes are defined here because they are shared by multiple subclasses and container classes.
660
665class Enclosure : public OthersBase
666{
667public:
672 enum class Shape : uint8_t
673 {
674 NoEnclosure = 0,
675 Rectangle = 1,
676 Ellipse = 2,
677 Triangle = 3,
678 Diamond = 4,
679 Pentagon = 5,
680 Hexagon = 6,
681 Heptagon = 7,
682 Octogon = 8
683 };
684
692 explicit Enclosure(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All, Cmper cmper = 0)
693 : OthersBase(document, partId, shareMode, cmper) {}
694
702 bool fixedSize{};
703 bool equalAspect{};
704 bool notTall{};
705 bool opaque{};
707
709};
710
721{
722public:
731 explicit EnigmaMusicRange(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All,
732 Cmper cmper = 0, std::optional<Inci> inci = std::nullopt)
733 : OthersBase(document, partId, shareMode, cmper, inci)
734 {
735 }
736
741
745 bool contains(MeasCmper measId, Edu eduPosition) const
746 {
747 return (startMeas < measId || (startMeas == measId && startEdu <= eduPosition)) &&
748 (endMeas > measId || (endMeas == measId && endEdu >= eduPosition));
749 }
750
757
761 std::optional<MusicPoint> nextLocation(const std::optional<StaffCmper>& forStaff = std::nullopt) const
762 { return createMusicRange().nextLocation(forStaff); }
763
765};
766
775{
776public:
777
785 explicit NamePositioning(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All, Cmper cmper = 0)
786 : OthersBase(document, partId, shareMode, cmper) {}
787
791 bool indivPos{};
793 bool expand{};
794
796};
797
798} // namespace others
799} // namespace dom
800} // 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:513
Represents the default font settings for a particular element type.
Definition CommonClasses.h:66
static constexpr uint16_t EnigmaStyleHidden
Hidden text bit.
Definition CommonClasses.h:106
static constexpr uint16_t EnigmaStyleItalic
Italic style bit.
Definition CommonClasses.h:102
FontInfo(const DocumentWeakPtr &document, bool sizeIsPercent=false)
constructor
Definition CommonClasses.h:73
static constexpr uint16_t EnigmaStyleStrikeout
Strikeout style bit.
Definition CommonClasses.h:104
bool calcIsSymbolFont() const
Calculates if this is a symbol font. (See others::FontDefinition::calcIsSymbolFont....
Definition CommonClasses.cpp:113
static constexpr uint16_t EnigmaStyleUnderline
Underline style bit.
Definition CommonClasses.h:103
uint16_t getEnigmaStyles() const
Returns the font styles as an nfx bitmask.
Definition CommonClasses.h:139
static constexpr uint16_t EnigmaStyleAbsolute
Fixed-size (absolute) bit.
Definition CommonClasses.h:105
static constexpr uint16_t EnigmaStyleBold
Bold style bit.
Definition CommonClasses.h:101
bool strikeout
Strikeout effect.
Definition CommonClasses.h:83
void setFontIdByName(const std::string &name)
Sets the id of the font from a string name.
Definition CommonClasses.cpp:60
Cmper fontId
Font identifier. This is a Cmper for others::FontDefinition.
Definition CommonClasses.h:78
static std::vector< std::filesystem::path > calcSMuFLPaths()
Returns the standard SMuFL font folder.
Definition CommonClasses.cpp:121
bool calcIsSMuFL() const
Calculates whether this is a SMuFL font.
Definition CommonClasses.cpp:87
std::string getName() const
Get the name of the font.
Definition CommonClasses.cpp:52
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:96
bool isSame(const FontInfo &src) const
Return true if the two fonts represent the same font.
Definition CommonClasses.h:89
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:128
bool italic
Italic effect.
Definition CommonClasses.h:81
bool hidden
Hidden effect.
Definition CommonClasses.h:85
bool calcIsDefaultMusic() const
Calculates if this is the default music font.
Definition CommonClasses.h:152
int fontSize
Font size or percent (where 100 is 100%) of preceding font size. (See getSizeIsPercent....
Definition CommonClasses.h:79
bool underline
Underline effect.
Definition CommonClasses.h:82
bool absolute
Fixed size effect.
Definition CommonClasses.h:84
std::optional< std::filesystem::path > calcSMuFLMetaDataPath() const
Returns the filepath of the SMuFL font's metadata json file, if any.
Definition CommonClasses.h:163
bool bold
Bold effect.
Definition CommonClasses.h:80
Shared key signature class that is contained in other classes. (See others::Measure)
Definition CommonClasses.h:189
void integrityCheck(const std::shared_ptr< EnigmaBase > &ptrToThis) override
Performs a final consistency check after population.
Definition CommonClasses.h:316
Cmper getKeyMode() const
Returns the key mode.
Definition CommonClasses.h:232
bool isSame(const KeySignature &src) const
returns whether the two key signatures represent the same key signature, taking into account transpos...
Definition CommonClasses.h:252
int getAlteration(KeyContext ctx) const
For linear keys, returns the number of sharps or flats from -7..7 (if any).
Definition CommonClasses.h:237
bool hideKeySigShowAccis
Instead of a key signature, show accidentals for the key on the notes where they occur.
Definition CommonClasses.h:216
int calcScaleDegree(int displacement) const
Calculates the scale degree for the given displacement, where 0 is the tonic.
Definition CommonClasses.cpp:346
bool isLinear() const
whether this is a linear key
Definition CommonClasses.h:240
int calcEDODivisions() const
Calculates the number of EDO division for the key. (The standard value is 12.)
Definition CommonClasses.cpp:430
bool isBuiltIn() const
whether this is a built-in key
Definition CommonClasses.h:242
KeyContext
Indicates whether to compute key signature values in concert or written pitch.
Definition CommonClasses.h:203
@ Written
Use written pitch (with transposition)
@ Concert
Use concert pitch (untransposed)
int calcTonalCenterIndex(KeyContext ctx) const
Calculates the tonal center index for the key, where C=0, D=1, E=2, ...
Definition CommonClasses.cpp:303
int getOctaveDisplacement(KeyContext ctx) const
The octave displacement if this key is a transposed key.
Definition CommonClasses.h:301
uint16_t key
16-bit value intepreted as follows:
Definition CommonClasses.h:214
std::unique_ptr< music_theory::Transposer > createTransposer(int displacement, int alteration) const
Creates a transposer for this KeySignature instance.
Definition CommonClasses.cpp:438
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:443
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:357
int calcAlterationOnNote(unsigned noteIndex, KeyContext ctx) const
Calculates the amount of alteration on a note int the key.
Definition CommonClasses.cpp:314
bool isMinor() const
whether this is a built-in minor key
Definition CommonClasses.h:244
bool isNonLinear() const
whether this is a non-linear key
Definition CommonClasses.h:241
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:258
bool isMajor() const
whether this is a built-in major key
Definition CommonClasses.h:243
std::optional< std::vector< int > > calcKeyMap() const
Calculates the key's diatonic key map.
Definition CommonClasses.cpp:392
bool keyless
Indicates the absence of a key signature.
Definition CommonClasses.h:215
Contains information about a line of lyrics on a system.
Definition CommonClasses.h:350
std::string_view lyricsType
the type of lyric ("chorus", "verse", or "section", corresponding to the xml tags for lyrics text)
Definition CommonClasses.h:364
MusxInstanceList< details::LyricAssign > assignments
The lyric assignments on this line. They all share the same lyricNumber value.
Definition CommonClasses.h:366
Evpu baselinePosition
baseline position of this line on this system, relative to the staff's reference line
Definition CommonClasses.h:363
Cmper lyricNumber
the text number for all lyric assignments on this line.
Definition CommonClasses.h:365
LyricsLineInfo(const DocumentWeakPtr &document, Cmper requestedPartId, std::string_view type, Cmper lyricNo, Evpu baseline)
Constructor function.
Definition CommonClasses.h:358
Contains the syllable information for a single syllable. (See texts::LyricsTextBase)
Definition CommonClasses.h:374
bool hasHyphenAfter
indicates the syllable if followed by a hyphen.
Definition CommonClasses.h:378
int strippedUnderscores
indicates the number of trailing underscores stripped (because smart word extensions convert them to ...
Definition CommonClasses.h:379
std::string syllable
the syllable text with no hyphenation or font information.
Definition CommonClasses.h:376
bool hasHyphenBefore
indicates the syllable is preceded by a hyphen.
Definition CommonClasses.h:377
Utility class that represents a single location in musical time.
Definition CommonClasses.h:423
constexpr bool operator>=(const MusicPoint &other) const
Greater-than-or-equal-to comparison operator.
Definition CommonClasses.h:478
constexpr bool operator!=(const MusicPoint &other) const
Inequality comparison operator.
Definition CommonClasses.h:450
constexpr bool operator<=(const MusicPoint &other) const
Less-than-or-equal-to comparison operator.
Definition CommonClasses.h:464
util::Fraction position
Position within the measure, where 1/4 is a quarter note value.
Definition CommonClasses.h:437
constexpr bool operator>(const MusicPoint &other) const
Greater-than comparison operator.
Definition CommonClasses.h:471
constexpr MusicPoint()=default
Constructs a MusicPoint at measure 1, position 0.
constexpr bool operator==(const MusicPoint &other) const
Equality comparison operator.
Definition CommonClasses.h:443
constexpr MusicPoint(MeasCmper measId, util::Fraction pos)
Constructs a MusicPoint object.
Definition CommonClasses.h:431
MeasCmper measureId
Measure ID of the point.
Definition CommonClasses.h:436
constexpr bool operator<(const MusicPoint &other) const
Less-than comparison operator.
Definition CommonClasses.h:457
Utility class that represents of a range of musical time.
Definition CommonClasses.h:492
MusicPoint end
Ending point in the range.
Definition CommonClasses.h:515
MusicRange(const DocumentWeakPtr &document, MeasCmper startMeasId, util::Fraction startPos, MeasCmper endMeasId, util::Fraction endPos)
Constructs a MusicRange object.
Definition CommonClasses.h:500
std::optional< MusicPoint > nextLocation(const std::optional< StaffCmper > &forStaff=std::nullopt) const
Returns the next metric location following the music range.
Definition CommonClasses.cpp:461
MusicPoint start
Starting point in the range.
Definition CommonClasses.h:514
bool contains(MeasCmper measId, util::Fraction position) const
Returns true of the given metric location is contained in this MusicRange instance.
Definition CommonClasses.h:520
bool contains(const MusicPoint &point) const
Returns true if the given metric location is contained in this MusicRange instance.
Definition CommonClasses.h:525
MusicRange(const DocumentWeakPtr &document, MusicPoint startPoint, MusicPoint endPoint)
Constructs a MusicRange object.
Definition CommonClasses.h:509
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:545
bool isSame(const TimeSignature &src) const
returns whether the two time signatures represent the same time signature
Definition CommonClasses.cpp:571
Abbreviation
Specifies whether a time signature is displayed in numeric or abbreviated form.
Definition CommonClasses.h:550
@ 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:634
bool isCutTime() const
Returns if this time signature is cut time.
Definition CommonClasses.cpp:590
std::vector< TimeSigComponent > components
the components in the time signature
Definition CommonClasses.h:578
util::Fraction calcTotalDuration() const
Calculates the total duration of the time signature as a fraction of a whole note.
Definition CommonClasses.h:587
std::optional< char32_t > getAbbreviatedSymbol() const
Returns the abbreviated symbol (code point) for this time signature, or std::nullopt if none.
Definition CommonClasses.cpp:543
bool isCommonTime() const
Returns if this time signature is common time.
Definition CommonClasses.cpp:582
MusxInstance< TimeSignature > createComponent(size_t index) const
Creates a time signature corresponding to the component at index.
Definition CommonClasses.h:613
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:598
Represents independent time and key signature overrides for a staff.
Definition Details.h:1201
Contains assignment data for a lyric assignment (a single syllable)
Definition Details.h:1292
Represents the enclosure settings for text expressions.
Definition CommonClasses.h:666
bool notTall
"Enforce Minimum Width": don't let shape get taller than it is wide
Definition CommonClasses.h:704
Enclosure(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an Enclosure object.
Definition CommonClasses.h:692
Evpu yAdd
Center Y offset - offsets text from center (in EVPU).
Definition CommonClasses.h:696
bool roundCorners
Whether the enclosure has rounded corners.
Definition CommonClasses.h:706
Efix lineWidth
Line thickness in 64ths of an EVPU (EFIX).
Definition CommonClasses.h:699
static const xml::XmlElementArray< Enclosure > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool opaque
Whether the enclosure is opaque.
Definition CommonClasses.h:705
Shape
Enumeration for enclosure shapes.
Definition CommonClasses.h:673
Evpu yMargin
Half height - extra space on top/bottom sides (in EVPU).
Definition CommonClasses.h:698
Shape shape
Enclosure shape (default: NoEnclosure).
Definition CommonClasses.h:700
bool fixedSize
Whether the enclosure is fixed size (ignore text bounding box)
Definition CommonClasses.h:702
bool equalAspect
"Match Height and Width"
Definition CommonClasses.h:703
Efix cornerRadius
Corner radius (in EFIX).
Definition CommonClasses.h:701
Evpu xMargin
Half width - extra space on left/right sides (in EVPU).
Definition CommonClasses.h:697
Evpu xAdd
Center X offset - offsets text from center (in EVPU).
Definition CommonClasses.h:695
The representation of a range of music used by Enigma files.
Definition CommonClasses.h:721
MeasCmper startMeas
Starting measure in the range.
Definition CommonClasses.h:737
std::optional< MusicPoint > nextLocation(const std::optional< StaffCmper > &forStaff=std::nullopt) const
Returns the next metric location following the music range.
Definition CommonClasses.h:761
MeasCmper endMeas
Ending measure in the range.
Definition CommonClasses.h:739
MusicRange createMusicRange() const
Creates a MusicRange instance corresponding to this instance. The MusicRange uses util::Fraction for ...
Definition CommonClasses.h:753
Edu startEdu
Starting EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:738
Edu endEdu
Ending EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:740
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:731
bool contains(MeasCmper measId, Edu eduPosition) const
Returns true of the given metric location is contained in this EnigmaMusicRange instance.
Definition CommonClasses.h:745
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:775
bool indivPos
Indicates that this positioning overrides the default positioning. (Not used by options::StaffOptions...
Definition CommonClasses.h:791
NamePositioning(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an NamePositioning object.
Definition CommonClasses.h:785
bool expand
"Expand Single Word"
Definition CommonClasses.h:793
Evpu horzOff
Horizontal distance from staff in Evpu.
Definition CommonClasses.h:788
AlignJustify hAlign
Horizontal alignment for the name text. (xml node is <halign>)
Definition CommonClasses.h:792
AlignJustify justify
Justification for the name text.
Definition CommonClasses.h:790
Evpu vertOff
Vertical offset from staff in Evpu.
Definition CommonClasses.h:789
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:52
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:85
int16_t MeasCmper
Enigma meas Cmper (may be negative when not applicable)
Definition Fundamentals.h:64
int32_t Efix
EFIX value (64 per EVPU, 64*288=18432 per inch)
Definition Fundamentals.h:60
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:79
int32_t Evpu
EVPU value (288 per inch)
Definition Fundamentals.h:57
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
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
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 single time signature component.
Definition CommonClasses.h:558
std::vector< util::Fraction > counts
Definition CommonClasses.h:559
std::vector< Edu > units
Definition CommonClasses.h:561
util::Fraction sumCounts() const
Compute the sum of all counts.
Definition CommonClasses.h:570
Edu sumUnits() const
Compute the sum of all units.
Definition CommonClasses.h:574
bool operator==(const TimeSigComponent &src) const
Test if two TimeSigComponent values are the same.
Definition CommonClasses.h:566