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
31namespace music_theory {
32class Transposer;
33enum class DiatonicMode : int;
34} // namespace music_theory
35
36namespace musx {
37namespace dom {
38
39class EntryInfoPtr;
40
41namespace details { // forward declarations
43class LyricAssign;
44} // namespace details
45
46namespace others { // forward declarations
47class Measure;
48class OssiaHeader;
49class Staff;
50} // namespace others
51
52// This file contains common classes that are shared among Options, Others, and Details.
53
60{
61 Treble = 0,
62 Alto = 1,
63 Tenor = 2,
64 Bass = 3,
65 Percussion = 4,
66 Treble8vb = 5,
67 Bass8vb = 6,
68 Baritone = 7,
69 FrenchViolin = 8,
70 BaritoneC = 9,
71 MezzoSoprano = 10,
72 Soprano = 11,
73 AltPercussion = 12,
74 Treble8va = 13,
75 Bass8va = 14,
76 Blank = 15,
77 Tab1 = 16,
78 Tab2 = 17
79};
80
85enum class LyricTextType
86{
87 Verse,
88 Chorus,
89 Section,
90};
91
98enum class NoteType : Edu
99{
100 Maxima = 0x8000,
101 Longa = 0x4000,
102 Breve = 0x2000,
103 Whole = EDU_PER_WHOLE_NOTE,
104 Half = 0x0800,
105 Quarter = 0x0400,
106 Eighth = 0x0200,
107 Note16th = 0x0100,
108 Note32nd = 0x0080,
109 Note64th = 0x0040,
110 Note128th = 0x0020,
111 Note256th = 0x0010,
112 Note512th = 0x0008,
113 Note1024th = 0x0004,
114 Note2048th = 0x0002,
115 Note4096th = 0x0001
116};
117
122enum class ShowClefMode
123{
124 WhenNeeded,
125 Never,
126 Always
127};
128
137{
138public:
144 FontInfo(const DocumentWeakPtr& document, bool sizeIsPercent = false)
145 : CommonClassBase(document), m_sizeIsPercent(sizeIsPercent)
146 {
147 }
148
150 int fontSize{};
151 bool bold{};
152 bool italic{};
153 bool underline{};
154 bool strikeout{};
155 bool absolute{};
156 bool hidden{};
157
160 bool isSame(const FontInfo& src) const
161 {
162 return fontId == src.fontId && fontSize == src.fontSize && m_sizeIsPercent == src.m_sizeIsPercent
163 && getEnigmaStyles() == src.getEnigmaStyles();
164 }
165
167 bool getSizeIsPercent() const { return m_sizeIsPercent; }
168
172 inline static constexpr uint16_t EnigmaStyleBold = 0x01;
173 inline static constexpr uint16_t EnigmaStyleItalic = 0x02;
174 inline static constexpr uint16_t EnigmaStyleUnderline = 0x04;
175 inline static constexpr uint16_t EnigmaStyleStrikeout = 0x20;
176 inline static constexpr uint16_t EnigmaStyleAbsolute = 0x40;
177 inline static constexpr uint16_t EnigmaStyleHidden = 0x80;
179
184 std::string getName() const;
185
191 void setFontIdByName(const std::string& name);
192
199 void setEnigmaStyles(uint16_t efx)
200 {
201 bold = efx & EnigmaStyleBold;
207 }
208
210 uint16_t getEnigmaStyles() const
211 {
212 uint16_t result = 0;
213 if (bold) result |= EnigmaStyleBold;
214 if (italic) result |= EnigmaStyleItalic;
215 if (underline) result |= EnigmaStyleUnderline;
216 if (strikeout) result |= EnigmaStyleStrikeout;
217 if (absolute) result |= EnigmaStyleAbsolute;
218 if (hidden) result |= EnigmaStyleHidden;
219 return result;
220 }
221
224 { return fontId == 0; }
225
227 bool calcIsSymbolFont() const;
228
231 static std::optional<std::filesystem::path> calcSMuFLMetaDataPath(const std::string& fontName);
232
234 std::optional<std::filesystem::path> calcSMuFLMetaDataPath() const
236
240 bool calcIsSMuFL() const;
241
247 static std::vector<std::filesystem::path> calcSMuFLPaths();
248
250
251private:
252 bool m_sizeIsPercent;
253};
254
260{
261public:
263
274 enum class KeyContext {
275 Concert,
276 Written
277 };
278
285 uint16_t key{};
286 bool keyless{};
288
303 Cmper getKeyMode() const { return isLinear() ? key >> 8 : key; }
304
309 { return isLinear() ? int(int8_t(key & 0xff)) + getAlterationOffset(ctx) : 0; }
310
311 bool isLinear() const { return (key & 0xC000) == 0; }
312 bool isNonLinear() const { return (key & 0xC000) != 0; }
313 bool isBuiltIn() const { return isLinear() && getKeyMode() <= 1; }
314 bool isMajor() const { return getKeyMode() == 0; }
315 bool isMinor() const { return getKeyMode() == 1; }
316
320 std::optional<music_theory::DiatonicMode> calcDiatonicMode() const;
321
323 bool isSame(const KeySignature& src) const
324 {
325 return isSameConcert(src) && m_alterationOffset == src.m_alterationOffset && m_octaveDisplacement == src.m_octaveDisplacement;
326 }
327
329 bool isSameConcert(const KeySignature& src) const
330 {
331 return key == src.key && keyless == src.keyless && hideKeySigShowAccis == src.hideKeySigShowAccis;
332 }
333
337 int calcScaleDegree(int displacement) const;
338
355 void setTransposition(int interval, int keyAdjustment, bool simplify);
356
359
363 int calcTonalCenterIndex(KeyContext ctx) const;
364
368 int calcAlterationOnNote(unsigned noteIndex, KeyContext ctx ) const;
369
373 { return ctx == KeyContext::Written ? m_octaveDisplacement : 0; }
374
376 int calcEDODivisions() const;
377
379 std::optional<std::vector<int>> calcKeyMap() const;
380
385 std::unique_ptr<music_theory::Transposer> createTransposer(int displacement, int alteration) const;
386
387 void integrityCheck(const std::shared_ptr<Base>& ptrToThis) override
388 {
389 this->CommonClassBase::integrityCheck(ptrToThis);
390 if (key >= 0x8000) {
391 MUSX_INTEGRITY_ERROR("Key signature has invalid key value: " + std::to_string(key));
392 }
393 }
394
396
397private:
398 std::vector<unsigned> calcTonalCenterArrayForSharps() const;
399 std::vector<unsigned> calcTonalCenterArrayForFlats() const;
400 std::vector<unsigned> calcTonalCenterArray(KeyContext ctx) const;
401 std::vector<int> calcAcciAmountsArray(KeyContext ctx) const;
402 std::vector<unsigned> calcAcciOrderArray(KeyContext ctx) const;
403
404 int m_octaveDisplacement{};
405 int m_alterationOffset{};
406
407 int getAlterationOffset(KeyContext ctx) const
408 { return ctx == KeyContext::Written ? m_alterationOffset : 0; }
409
410};
411
412namespace texts {
413class LyricsTextBase; // forward delcaration
414} // namespace texts
415
421{
422public:
429 LyricsLineInfo(const DocumentWeakPtr& document, Cmper requestedPartId, std::string_view type, Cmper lyricNo, Evpu baseline) :
430 CommonClassBase(document), baselinePosition(baseline), lyricsType(type), lyricNumber(lyricNo), assignments(document, requestedPartId)
431 {
432 }
433
435 std::string_view lyricsType;
438};
439
445{
446public:
447 std::string syllable;
451
452private:
457 class StyleSpan
458 {
459 public:
460 size_t start; // start byte
461 size_t end; // end byte (exclusive)
462 size_t styleIndex; // index into LyricsTextBase's style table
463 };
464
472 LyricsSyllableInfo(const DocumentWeakPtr& document, const std::string text, bool before, bool after, int underscores, std::vector<StyleSpan>&& enigmaStyleMap)
473 : CommonClassBase(document), syllable(text), hasHyphenBefore(before), hasHyphenAfter(after), strippedUnderscores(underscores), m_enigmaStyleMap(std::move(enigmaStyleMap))
474 {
475 }
476
477 std::vector<StyleSpan> m_enigmaStyleMap;
478
479 friend class texts::LyricsTextBase;
480};
481
493{
494public:
501 explicit MusicRange(const DocumentWeakPtr& document, MeasCmper startMeasId, util::Fraction startPos, MeasCmper endMeasId, util::Fraction endPos)
502 : CommonClassBase(document), startMeasureId(startMeasId), startPosition(startPos), endMeasureId(endMeasId), endPosition(endPos)
503 {
504 }
505
510
514 bool contains(MeasCmper measId, util::Fraction eduPosition) const
515 {
516 return (startMeasureId < measId || (startMeasureId == measId && startPosition <= eduPosition)) &&
517 (endMeasureId > measId || (endMeasureId == measId && endPosition >= eduPosition));
518 }
519
521 // The MusicRange must be expressed in the Staff EDUs of the entry.
523 bool contains(const EntryInfoPtr& entryInfo) const;
524
531 [[nodiscard]]
532 std::optional<std::pair<MeasCmper, Edu>> nextLocation(const std::optional<StaffCmper>& forStaff = std::nullopt) const;
533};
534
540{
541public:
542
545 {
546 std::vector<util::Fraction> counts;
548 std::vector<Edu> units;
551
553 bool operator==(const TimeSigComponent& src) const
554 { return counts == src.counts && units == src.units; }
555
558 { return std::accumulate(counts.begin(), counts.end(), util::Fraction{}); }
559
561 Edu sumUnits() const
562 { return std::accumulate(units.begin(), units.end(), Edu{}); }
563 };
564
565 std::vector<TimeSigComponent> components;
566
571 std::pair<util::Fraction, NoteType> calcSimplified() const;
572
575 {
576 util::Fraction result = std::accumulate(components.begin(), components.end(), util::Fraction{},
577 [](const util::Fraction& acc, const TimeSigComponent& comp)
578 { return acc + (comp.sumCounts() * comp.sumUnits()); }
579 );
580 return result / Edu(NoteType::Whole);
581 }
582
584 bool isSame(const TimeSignature& src) const;
585
590 {
591 checkIndex(index);
592 return MusxInstance<TimeSignature>(new TimeSignature(getDocument(), components[index], m_abbreviate));
593 }
594
599 std::optional<char32_t> getAbbreviatedSymbol() const;
600
602 bool isCommonTime() const;
604 bool isCutTime() const;
605
606private:
607 void checkIndex(size_t index) const
608 {
609 if (index > components.size()) {
610 throw std::invalid_argument("Index out of range. The time signature has " + std::to_string(components.size())
611 + " elements. The index requested was " + std::to_string(index) + ".");
612 }
613 }
614
619 explicit TimeSignature(const DocumentWeakPtr& document, int beats, Edu unit, bool hasCompositeTop, bool hasCompositeBottom,
620 std::optional<bool> abbreviate = std::nullopt);
621
626 explicit TimeSignature(const DocumentWeakPtr& document, const TimeSigComponent& timeSigUnit, std::optional<bool> abbreviate)
627 : CommonClassBase(document), m_abbreviate(abbreviate)
628 {
629 components.push_back(timeSigUnit);
630 }
631
632 std::optional<bool> m_abbreviate;
633
634 friend class others::Measure;
635 friend class others::OssiaHeader;
636 friend class details::IndependentStaffDetails;
637};
638
639namespace others {
640
641// The following classes are defined here because they are shared by multiple subclasses and container classes.
642
647class Enclosure : public OthersBase
648{
649public:
654 enum class Shape : uint8_t
655 {
656 NoEnclosure = 0,
657 Rectangle = 1,
658 Ellipse = 2,
659 Triangle = 3,
660 Diamond = 4,
661 Pentagon = 5,
662 Hexagon = 6,
663 Heptagon = 7,
664 Octogon = 8
665 };
666
674 explicit Enclosure(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All, Cmper cmper = 0)
675 : OthersBase(document, partId, shareMode, cmper) {}
676
684 bool fixedSize{};
685 bool equalAspect{};
686 bool notTall{};
687 bool opaque{};
689
691};
692
703{
704public:
713 explicit EnigmaMusicRange(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All,
714 Cmper cmper = 0, std::optional<Inci> inci = std::nullopt)
715 : OthersBase(document, partId, shareMode, cmper, inci)
716 {
717 }
718
723
727 bool contains(MeasCmper measId, Edu eduPosition) const
728 {
729 return (startMeas < measId || (startMeas == measId && startEdu <= eduPosition)) &&
730 (endMeas > measId || (endMeas == measId && endEdu >= eduPosition));
731 }
732
739
746 std::optional<std::pair<MeasCmper, Edu>> nextLocation(const std::optional<StaffCmper>& forStaff = std::nullopt) const
747 { return createMusicRange().nextLocation(forStaff); }
748
750};
751
760{
761public:
762
770 explicit NamePositioning(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All, Cmper cmper = 0)
771 : OthersBase(document, partId, shareMode, cmper) {}
772
775 enum class AlignJustify
776 {
777 Left,
778 Right,
779 Center
780 };
781
785 bool indivPos{};
787 bool expand{};
788
790};
791
792} // namespace others
793} // namespace dom
794} // namespace mux
DocumentPtr getDocument() const
Gets a reference to the Document.
Definition BaseClasses.h:108
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
Base class for classes that are commonly used among others, details, entries, and/or texts....
Definition BaseClasses.h:200
CommonClassBase(const DocumentWeakPtr &document)
Constructs a CommonClassBase object.
Definition BaseClasses.h:209
Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ow...
Definition Entries.h:417
Represents the default font settings for a particular element type.
Definition CommonClasses.h:137
static constexpr uint16_t EnigmaStyleHidden
Hidden text bit.
Definition CommonClasses.h:177
static constexpr uint16_t EnigmaStyleItalic
Italic style bit.
Definition CommonClasses.h:173
FontInfo(const DocumentWeakPtr &document, bool sizeIsPercent=false)
constructor
Definition CommonClasses.h:144
static constexpr uint16_t EnigmaStyleStrikeout
Strikeout style bit.
Definition CommonClasses.h:175
bool calcIsSymbolFont() const
Calculates if this is a symbol font. (See others::FontDefinition::calcIsSymbolFont....
Definition CommonClasses.cpp:109
static constexpr uint16_t EnigmaStyleUnderline
Underline style bit.
Definition CommonClasses.h:174
uint16_t getEnigmaStyles() const
Returns the font styles as an nfx bitmask.
Definition CommonClasses.h:210
static constexpr uint16_t EnigmaStyleAbsolute
Fixed-size (absolute) bit.
Definition CommonClasses.h:176
static constexpr uint16_t EnigmaStyleBold
Bold style bit.
Definition CommonClasses.h:172
bool strikeout
Strikeout effect.
Definition CommonClasses.h:154
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:149
static std::vector< std::filesystem::path > calcSMuFLPaths()
Returns the standard SMuFL font folder.
Definition CommonClasses.cpp:117
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:167
bool isSame(const FontInfo &src) const
Return true if the two fonts represent the same font.
Definition CommonClasses.h:160
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:199
bool italic
Italic effect.
Definition CommonClasses.h:152
bool hidden
Hidden effect.
Definition CommonClasses.h:156
bool calcIsDefaultMusic() const
Calculates if this is the default music font.
Definition CommonClasses.h:223
int fontSize
Font size or percent (where 100 is 100%) of preceding font size. (See getSizeIsPercent....
Definition CommonClasses.h:150
bool underline
Underline effect.
Definition CommonClasses.h:153
bool absolute
Fixed size effect.
Definition CommonClasses.h:155
std::optional< std::filesystem::path > calcSMuFLMetaDataPath() const
Returns the filepath of the SMuFL font's metadata json file, if any.
Definition CommonClasses.h:234
bool bold
Bold effect.
Definition CommonClasses.h:151
Shared key signature class that is contained in other classes. (See others::Measure)
Definition CommonClasses.h:260
Cmper getKeyMode() const
Returns the key mode.
Definition CommonClasses.h:303
bool isSame(const KeySignature &src) const
returns whether the two key signatures represent the same key signature, taking into account transpos...
Definition CommonClasses.h:323
int getAlteration(KeyContext ctx) const
For linear keys, returns the number of sharps or flats from -7..7 (if any).
Definition CommonClasses.h:308
bool hideKeySigShowAccis
Instead of a key signature, show accidentals for the key on the notes where they occur.
Definition CommonClasses.h:287
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 CommonClasses.h:387
int calcScaleDegree(int displacement) const
Calculates the scale degree for the given displacement, where 0 is the tonic.
Definition CommonClasses.cpp:342
bool isLinear() const
whether this is a linear key
Definition CommonClasses.h:311
int calcEDODivisions() const
Calculates the number of EDO division for the key. (The standard value is 12.)
Definition CommonClasses.cpp:426
bool isBuiltIn() const
whether this is a built-in key
Definition CommonClasses.h:313
KeyContext
Indicates whether to compute key signature values in concert or written pitch.
Definition CommonClasses.h:274
@ 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:299
int getOctaveDisplacement(KeyContext ctx) const
The octave displacement if this key is a transposed key.
Definition CommonClasses.h:372
uint16_t key
16-bit value intepreted as follows:
Definition CommonClasses.h:285
std::unique_ptr< music_theory::Transposer > createTransposer(int displacement, int alteration) const
Creates a transposer for this KeySignature instance.
Definition CommonClasses.cpp:434
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:439
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:353
int calcAlterationOnNote(unsigned noteIndex, KeyContext ctx) const
Calculates the amount of alteration on a note int the key.
Definition CommonClasses.cpp:310
bool isMinor() const
whether this is a built-in minor key
Definition CommonClasses.h:315
bool isNonLinear() const
whether this is a non-linear key
Definition CommonClasses.h:312
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:329
bool isMajor() const
whether this is a built-in major key
Definition CommonClasses.h:314
std::optional< std::vector< int > > calcKeyMap() const
Calculates the key's diatonic key map.
Definition CommonClasses.cpp:388
bool keyless
Indicates the absence of a key signature.
Definition CommonClasses.h:286
Contains information about a line of lyrics on a system.
Definition CommonClasses.h:421
std::string_view lyricsType
the type of lyric ("chorus", "verse", or "section", corresponding to the xml tags for lyrics text)
Definition CommonClasses.h:435
MusxInstanceList< details::LyricAssign > assignments
The lyric assignments on this line. They all share the same lyricNumber value.
Definition CommonClasses.h:437
Evpu baselinePosition
baseline position of this line on this system, relative to the staff's reference line
Definition CommonClasses.h:434
Cmper lyricNumber
the text number for all lyric assignments on this line.
Definition CommonClasses.h:436
LyricsLineInfo(const DocumentWeakPtr &document, Cmper requestedPartId, std::string_view type, Cmper lyricNo, Evpu baseline)
Constructor function.
Definition CommonClasses.h:429
Contains the syllable information for a single syllable. (See texts::LyricsTextBase)
Definition CommonClasses.h:445
bool hasHyphenAfter
indicates the syllable if followed by a hyphen.
Definition CommonClasses.h:449
int strippedUnderscores
indicates the number of trailing underscores stripped (because smart word extensions convert them to ...
Definition CommonClasses.h:450
std::string syllable
the syllable text with no hyphenation or font information.
Definition CommonClasses.h:447
bool hasHyphenBefore
indicates the syllable is preceded by a hyphen.
Definition CommonClasses.h:448
Utility class that represents of a range of musical time.
Definition CommonClasses.h:493
std::optional< std::pair< MeasCmper, Edu > > nextLocation(const std::optional< StaffCmper > &forStaff=std::nullopt) const
Returns the next metric location following the music range.
Definition CommonClasses.cpp:457
util::Fraction endPosition
Ending EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:509
MusicRange(const DocumentWeakPtr &document, MeasCmper startMeasId, util::Fraction startPos, MeasCmper endMeasId, util::Fraction endPos)
Constructs a MusicRange object.
Definition CommonClasses.h:501
bool contains(MeasCmper measId, util::Fraction eduPosition) const
Returns true of the given metric location is contained in this MusicRange instance.
Definition CommonClasses.h:514
util::Fraction startPosition
Starting EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:507
MeasCmper endMeasureId
Ending measure in the range.
Definition CommonClasses.h:508
MeasCmper startMeasureId
Starting measure in the range.
Definition CommonClasses.h:506
Provides optional per-type extension methods for MusxInstanceList.
Definition MusxInstance.h:103
Base class for all "others" types.
Definition BaseClasses.h:283
Shared time signature class that is derived from other classes. (See others::Measure)
Definition CommonClasses.h:540
bool isSame(const TimeSignature &src) const
returns whether the two time signatures represent the same time signature
Definition CommonClasses.cpp:561
bool isCutTime() const
Returns if this time signature is cut time.
Definition CommonClasses.cpp:580
std::vector< TimeSigComponent > components
the components in the time signature
Definition CommonClasses.h:565
util::Fraction calcTotalDuration() const
Calculates the total duration of the time signature as a fraction of a whole note.
Definition CommonClasses.h:574
std::optional< char32_t > getAbbreviatedSymbol() const
Returns the abbreviated symbol (code point) for this time signature, or std::nullopt if none.
Definition CommonClasses.cpp:538
bool isCommonTime() const
Returns if this time signature is common time.
Definition CommonClasses.cpp:572
MusxInstance< TimeSignature > createComponent(size_t index) const
Creates a time signature corresponding to the component at index.
Definition CommonClasses.h:589
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:588
Represents independent time and key signature overrides for a staff.
Definition Details.h:1151
Contains assignment data for a lyric assignment (a single syllable)
Definition Details.h:1242
Represents the enclosure settings for text expressions.
Definition CommonClasses.h:648
bool notTall
"Enforce Minimum Width": don't let shape get taller than it is wide
Definition CommonClasses.h:686
Enclosure(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an Enclosure object.
Definition CommonClasses.h:674
Evpu yAdd
Center Y offset - offsets text from center (in EVPU).
Definition CommonClasses.h:678
bool roundCorners
Whether the enclosure has rounded corners.
Definition CommonClasses.h:688
Efix lineWidth
Line thickness in 64ths of an EVPU (EFIX).
Definition CommonClasses.h:681
static const xml::XmlElementArray< Enclosure > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool opaque
Whether the enclosure is opaque.
Definition CommonClasses.h:687
Shape
Enumeration for enclosure shapes.
Definition CommonClasses.h:655
Evpu yMargin
Half height - extra space on top/bottom sides (in EVPU).
Definition CommonClasses.h:680
Shape shape
Enclosure shape (default: NoEnclosure).
Definition CommonClasses.h:682
bool fixedSize
Whether the enclosure is fixed size (ignore text bounding box)
Definition CommonClasses.h:684
bool equalAspect
"Match Height and Width"
Definition CommonClasses.h:685
Efix cornerRadius
Corner radius (in EFIX).
Definition CommonClasses.h:683
Evpu xMargin
Half width - extra space on left/right sides (in EVPU).
Definition CommonClasses.h:679
Evpu xAdd
Center X offset - offsets text from center (in EVPU).
Definition CommonClasses.h:677
The representation of a range of music used by Enigma files.
Definition CommonClasses.h:703
MeasCmper startMeas
Starting measure in the range.
Definition CommonClasses.h:719
std::optional< std::pair< MeasCmper, Edu > > nextLocation(const std::optional< StaffCmper > &forStaff=std::nullopt) const
Returns the next metric location following the music range.
Definition CommonClasses.h:746
MeasCmper endMeas
Ending measure in the range.
Definition CommonClasses.h:721
MusicRange createMusicRange() const
Creates a MusicRange instance corresponding to this instance. The MusicRange uses util::Fraction for ...
Definition CommonClasses.h:735
Edu startEdu
Starting EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:720
Edu endEdu
Ending EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:722
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:713
bool contains(MeasCmper measId, Edu eduPosition) const
Returns true of the given metric location is contained in this EnigmaMusicRange instance.
Definition CommonClasses.h:727
static const xml::XmlElementArray< EnigmaMusicRange > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
Represents the attributes of a measure.
Definition Others.h:1130
Contains horizontal and vertical offsets, alignment, and expansion settings for name positioning.
Definition CommonClasses.h:760
bool indivPos
Indicates that this positioning overrides the default positioning. (Not used by options::StaffOptions...
Definition CommonClasses.h:785
NamePositioning(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an NamePositioning object.
Definition CommonClasses.h:770
bool expand
"Expand Single Word"
Definition CommonClasses.h:787
AlignJustify
Alignment and justification options for staff and group names.
Definition CommonClasses.h:776
@ Left
Left alignment or justification (the default value.)
Evpu horzOff
Horizontal distance from staff in Evpu.
Definition CommonClasses.h:782
AlignJustify hAlign
Horizontal alignment for the name text. (xml node is <halign>)
Definition CommonClasses.h:786
AlignJustify justify
Justification for the name text.
Definition CommonClasses.h:784
Evpu vertOff
Vertical offset from staff in Evpu.
Definition CommonClasses.h:783
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:103
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
ShowClefMode
Enum representing the clef display mode for a frame.
Definition CommonClasses.h:123
@ WhenNeeded
Clef is displayed only when needed (the default).
@ Always
Clef is always displayed. (xml value is "forced")
@ Never
Clef is never displayed. (xml value is "hidden")
LyricTextType
The lyric text type if this is a lyrics smart shape.
Definition CommonClasses.h:86
@ Verse
The assignment is to a Verse lyrics text block.
@ Chorus
The assignment is to a Chorus lyrics text block.
@ Section
The assignment is to a Section lyrics text block.
NoteType
Enum class representing note types based on EDU values.
Definition CommonClasses.h:99
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:39
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
DefaultClefType
Clef types used by default in Finale documents. The values correspond to indices into musx::dom::opti...
Definition CommonClasses.h:60
@ Bass8vb
F clef, sounds one octave lower (8vb).
@ Alto
C clef, centered on third line (Alto clef).
@ BaritoneC
C clef on fifth line (Baritone clef).
@ Tab1
Tablature clef (5 lines).
@ Treble
G clef, standard treble.
@ FrenchViolin
G clef placed on first line (French violin clef).
@ Treble8va
G clef, sounds one octave higher (8va).
@ Bass8va
F clef, sounds one octave higher (8va).
@ AltPercussion
Alternate percussion clef, heavy vertical hash marks (no pitch).
@ Soprano
C clef on first line (Soprano clef).
@ Bass
F clef, standard bass.
@ Percussion
Percussion clef, open rectangle (no pitch).
@ Baritone
F clef on third line (Baritone clef).
@ Tab2
Tablature clef (5 lines, alternative style).
@ Treble8vb
G clef, sounds one octave lower (8vb).
@ Blank
Blank clef (invisible, no symbol).
@ MezzoSoprano
C clef on second line (Mezzo-soprano clef).
@ Tenor
C clef, centered on fourth line (Tenor clef).
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::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition BaseClasses.h:57
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
A single time signature component.
Definition CommonClasses.h:545
std::vector< util::Fraction > counts
Definition CommonClasses.h:546
std::vector< Edu > units
Definition CommonClasses.h:548
util::Fraction sumCounts() const
Compute the sum of all counts.
Definition CommonClasses.h:557
Edu sumUnits() const
Compute the sum of all units.
Definition CommonClasses.h:561
bool operator==(const TimeSigComponent &src) const
Test if two TimeSigComponent values are the same.
Definition CommonClasses.h:553