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#include <string>
28#include <string_view>
29#include <optional>
30#include <utility>
31#include <vector>
32
33#include "musx/dom/ResolvedFontInfo.h"
34#include "musx/util/EnigmaString.h"
35#include "musx/util/Fraction.h"
36#include "BaseClasses.h"
37#include "EnumClasses.h"
38
39namespace music_theory {
40class Transposer;
41enum class DiatonicMode : int;
42struct Pitch;
43} // namespace music_theory
44
45namespace musx {
46namespace dom {
47
48class EntryInfoPtr;
49
50namespace details { // forward declarations
52class LyricAssign;
53} // namespace details
54
55namespace others { // forward declarations
56class FontDefinition;
57class Measure;
58class OssiaHeader;
59class Staff;
60} // namespace others
61
63using Duration = std::pair<NoteType, unsigned>;
64
65// This file contains common classes that are shared among Options, Others, and Details.
66
75[[nodiscard]]
76std::string normalizeFontName(std::string_view name);
77
98[[nodiscard]]
99std::optional<Cmper> importFontDefinitionInto(const DocumentPtr& target,
101 const ImportObjectCallback& onImported = {});
102
111{
112public:
118 FontInfo(const DocumentWeakPtr& document, bool sizeIsPercent = false)
119 : CommonClassBase(document), m_sizeIsPercent(sizeIsPercent)
120 {
121 }
122
124 int fontSize{};
125 bool bold{};
126 bool italic{};
127 bool underline{};
128 bool strikeout{};
129 bool absolute{};
130 bool hidden{};
131
145 bool calcIsSameTypeface(const FontInfo& src) const;
146
156 bool isSame(const FontInfo& src) const;
157
159 bool getSizeIsPercent() const { return m_sizeIsPercent; }
160
164 inline static constexpr uint16_t EnigmaStyleBold = 0x01;
165 inline static constexpr uint16_t EnigmaStyleItalic = 0x02;
166 inline static constexpr uint16_t EnigmaStyleUnderline = 0x04;
167 inline static constexpr uint16_t EnigmaStyleStrikeout = 0x20;
168 inline static constexpr uint16_t EnigmaStyleAbsolute = 0x40;
169 inline static constexpr uint16_t EnigmaStyleHidden = 0x80;
171
176 std::string getName() const;
177
183 void setFontIdByName(const std::string& name);
184
191 void setEnigmaStyles(uint16_t efx)
192 {
193 bold = efx & EnigmaStyleBold;
199 }
200
202 uint16_t getEnigmaStyles() const
203 {
204 uint16_t result = 0;
205 if (bold) result |= EnigmaStyleBold;
206 if (italic) result |= EnigmaStyleItalic;
207 if (underline) result |= EnigmaStyleUnderline;
208 if (strikeout) result |= EnigmaStyleStrikeout;
209 if (absolute) result |= EnigmaStyleAbsolute;
210 if (hidden) result |= EnigmaStyleHidden;
211 return result;
212 }
213
216 { return fontId == 0; }
217
219 bool calcIsSymbolFont() const;
220
223 static std::optional<std::filesystem::path> calcSMuFLMetaDataPath(const std::string& fontName);
224
226 std::optional<std::filesystem::path> calcSMuFLMetaDataPath() const
228
232 bool calcIsSMuFL() const;
233
240
246 static std::vector<std::filesystem::path> calcSMuFLPaths();
247
249
250private:
251 bool m_sizeIsPercent;
252};
253
259{
260public:
262
273 enum class KeyContext {
274 Concert,
275 Written
276 };
277
284 uint16_t key{};
285 bool keyless{};
287
302 Cmper getKeyMode() const { return isLinear() ? key >> 8 : key; }
303
308 { return isLinear() ? int(int8_t(key & 0xff)) + getAlterationOffset(ctx) : 0; }
309
310 bool isLinear() const { return (key & 0xC000) == 0; }
311 bool isNonLinear() const { return (key & 0xC000) != 0; }
312 bool isBuiltIn() const { return isLinear() && getKeyMode() <= 1; }
313 bool isMajor() const { return getKeyMode() == 0; }
314 bool isMinor() const { return getKeyMode() == 1; }
315
319 std::optional<music_theory::DiatonicMode> calcDiatonicMode() const;
320
322 bool isSame(const KeySignature& src) const
323 {
324 return isSameConcert(src) && m_alterationOffset == src.m_alterationOffset && m_octaveDisplacement == src.m_octaveDisplacement;
325 }
326
328 bool isSameConcert(const KeySignature& src) const
329 {
330 return key == src.key && keyless == src.keyless && hideKeySigShowAccis == src.hideKeySigShowAccis;
331 }
332
336 int calcScaleDegree(int displacement) const;
337
354 void setTransposition(int interval, int keyAdjustment, bool simplify);
355
358
362 int calcTonalCenterIndex(KeyContext ctx) const;
363
367 int calcAlterationOnNote(unsigned noteIndex, KeyContext ctx ) const;
368
377 [[nodiscard]]
378 music_theory::Pitch calcPitch(int displacement, int alteration, KeyContext ctx) const;
379
392 [[nodiscard]]
393 music_theory::Pitch calcPitchFromStaffPosition(int staffPosition, ClefIndex clefIndex, KeyContext ctx,
394 std::optional<int> actualAlteration = std::nullopt) const;
395
399 { return ctx == KeyContext::Written ? m_octaveDisplacement : 0; }
400
402 int calcEDODivisions() const;
403
405 std::optional<std::vector<int>> calcKeyMap() const;
406
411 std::unique_ptr<music_theory::Transposer> createTransposer(int displacement, int alteration) const;
412
413 void integrityCheck(const std::shared_ptr<EnigmaBase>& ptrToThis) override
414 {
415 this->CommonClassBase::integrityCheck(ptrToThis);
416 if (key >= 0x8000) {
417 MUSX_INTEGRITY_ERROR("Key signature has invalid key value: " + std::to_string(key));
418 }
419 }
420
422
423private:
424 std::vector<unsigned> calcTonalCenterArrayForSharps() const;
425 std::vector<unsigned> calcTonalCenterArrayForFlats() const;
426 std::vector<unsigned> calcTonalCenterArray(KeyContext ctx) const;
427 std::vector<int> calcAcciAmountsArray(KeyContext ctx) const;
428 std::vector<unsigned> calcAcciOrderArray(KeyContext ctx) const;
429
430 int m_octaveDisplacement{};
431 int m_alterationOffset{};
432
433 int getAlterationOffset(KeyContext ctx) const
434 { return ctx == KeyContext::Written ? m_alterationOffset : 0; }
435
436};
437
438namespace texts {
439class LyricsTextBase; // forward delcaration
440} // namespace texts
441
447{
448public:
455 LyricsLineInfo(const DocumentWeakPtr& document, Cmper requestedPartId, std::string_view type, Cmper lyricNo, Evpu baseline) :
456 CommonClassBase(document), baselinePosition(baseline), lyricsType(type), lyricNumber(lyricNo), assignments(document, requestedPartId)
457 {
458 }
459
461 std::string_view lyricsType;
464};
465
471{
472public:
488 {
489 public:
490 std::optional<char32_t> joinMarker;
493
495 std::string text() const;
496
502
503 private:
504 std::vector<std::pair<std::string, util::EnigmaStyles>> m_chunks;
505
506 friend class LyricsSyllableInfo;
507 };
508
509 std::string syllable;
513
519
524 std::vector<ElisionRun> calcElisionRuns() const;
525
526private:
531 class StyleSpan
532 {
533 public:
534 size_t start; // start byte
535 size_t end; // end byte (exclusive)
536 size_t styleIndex; // index into LyricsTextBase's style table
537 };
538
547 LyricsSyllableInfo(const DocumentWeakPtr& document, const MusxInstance<texts::LyricsTextBase>& owner, const std::string text, bool before, bool after, int underscores, std::vector<StyleSpan>&& enigmaStyleMap)
548 : DocumentElementNoPart(document), syllable(text), hasHyphenBefore(before), hasHyphenAfter(after), strippedUnderscores(underscores), m_owner(owner), m_enigmaStyleMap(std::move(enigmaStyleMap))
549 {
550 }
551
554 bool iterateStylesInRange(size_t rangeStart, size_t rangeEnd, const util::EnigmaString::TextChunkCallback& callback) const;
555
556 MusxInstanceWeak<texts::LyricsTextBase> m_owner;
557 std::vector<StyleSpan> m_enigmaStyleMap;
558
559 friend class texts::LyricsTextBase;
560};
561
574{
575public:
577 constexpr MusicPoint() = default;
578
582 constexpr MusicPoint(MeasCmper measId, util::Fraction pos)
583 : measureId(measId), position(pos)
584 {
585 }
586
589
593 [[nodiscard]]
594 constexpr bool operator==(const MusicPoint& other) const
595 { return measureId == other.measureId && position == other.position; }
596
600 [[nodiscard]]
601 constexpr bool operator!=(const MusicPoint& other) const
602 { return !(*this == other); }
603
607 [[nodiscard]]
608 constexpr bool operator<(const MusicPoint& other) const
609 { return measureId < other.measureId || (measureId == other.measureId && position < other.position); }
610
614 [[nodiscard]]
615 constexpr bool operator<=(const MusicPoint& other) const
616 { return *this < other || *this == other; }
617
621 [[nodiscard]]
622 constexpr bool operator>(const MusicPoint& other) const
623 { return other < *this; }
624
628 [[nodiscard]]
629 constexpr bool operator>=(const MusicPoint& other) const
630 { return other <= *this; }
631};
632
643{
644public:
651 explicit MusicRange(const DocumentWeakPtr& document, MeasCmper startMeasId, util::Fraction startPos, MeasCmper endMeasId, util::Fraction endPos)
652 : MusicRange(document, MusicPoint(startMeasId, startPos), MusicPoint(endMeasId, endPos))
653 {
654 }
655
660 explicit MusicRange(const DocumentWeakPtr& document, MusicPoint startPoint, MusicPoint endPoint)
661 : DocumentElementNoPart(document), start(startPoint), end(endPoint)
662 {
663 }
664
667
671 bool contains(MeasCmper measId, util::Fraction position) const
672 { return contains(MusicPoint(measId, position)); }
673
676 bool contains(const MusicPoint& point) const
677 { return start <= point && point <= end; }
678
680 // The MusicRange must be expressed in the Staff EDUs of the entry.
682 bool contains(const EntryInfoPtr& entryInfo) const;
683
687 [[nodiscard]]
688 std::optional<MusicPoint> nextLocation(const std::optional<StaffCmper>& forStaff = std::nullopt) const;
689};
690
696{
697public:
700 enum class Abbreviation
701 {
703 Numeric,
705 };
706
709 {
710 std::vector<util::Fraction> counts;
712 std::vector<Edu> units;
715
717 bool operator==(const TimeSigComponent& src) const
718 { return counts == src.counts && units == src.units; }
719
722 { return std::accumulate(counts.begin(), counts.end(), util::Fraction{}); }
723
725 Edu sumUnits() const
726 { return std::accumulate(units.begin(), units.end(), Edu{}); }
727
730 static std::pair<util::Fraction, Edu> normalizeCompoundUnit(util::Fraction count, Edu unit);
731
736 };
737
738 std::vector<TimeSigComponent> components;
739
744 std::pair<util::Fraction, NoteType> calcSimplified() const;
745
748 {
749 util::Fraction result = std::accumulate(components.begin(), components.end(), util::Fraction{},
750 [](const util::Fraction& acc, const TimeSigComponent& comp)
751 { return acc + (comp.sumCounts() * comp.sumUnits()); }
752 );
753 return result / Edu(NoteType::Whole);
754 }
755
765 util::Fraction calcBeatValueAt(Edu eduPosition) const;
766
768 bool isSame(const TimeSignature& src) const;
769
774 {
775 checkIndex(index);
776 return MusxInstance<TimeSignature>(new TimeSignature(getDocument(), components[index], m_abbreviation));
777 }
778
783 std::optional<char32_t> getAbbreviatedSymbol() const;
784
786 bool isCommonTime() const;
788 bool isCutTime() const;
789
790private:
791 void checkIndex(size_t index) const
792 {
793 if (index > components.size()) {
794 throw std::invalid_argument("Index out of range. The time signature has " + std::to_string(components.size())
795 + " elements. The index requested was " + std::to_string(index) + ".");
796 }
797 }
798
800 explicit TimeSignature(const DocumentWeakPtr& document, int beats, Edu unit, bool hasCompositeTop, bool hasCompositeBottom,
801 Abbreviation abbreviate = {});
802
804 explicit TimeSignature(const DocumentWeakPtr& document, const TimeSigComponent& timeSigUnit, Abbreviation abbreviate = {})
805 : DocumentElementNoPart(document), m_abbreviation(abbreviate)
806 {
807 components.push_back(timeSigUnit);
808 }
809
810 Abbreviation m_abbreviation{};
811
812 friend class others::Measure;
813 friend class others::OssiaHeader;
814 friend class details::IndependentStaffDetails;
815};
816
817namespace others {
818
819// The following classes are defined here because they are shared by multiple subclasses and container classes.
820
825class Enclosure : public OthersBase
826{
827public:
832 enum class Shape : uint8_t
833 {
834 NoEnclosure = 0,
835 Rectangle = 1,
836 Ellipse = 2,
837 Triangle = 3,
838 Diamond = 4,
839 Pentagon = 5,
840 Hexagon = 6,
841 Heptagon = 7,
842 Octogon = 8
843 };
844
852 explicit Enclosure(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All, Cmper cmper = 0)
853 : OthersBase(document, partId, shareMode, cmper) {}
854
862 bool fixedSize{};
863 bool equalAspect{};
864 bool notTall{};
865 bool opaque{};
867
869};
870
881{
882public:
891 explicit EnigmaMusicRange(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All,
892 Cmper cmper = 0, std::optional<Inci> inci = std::nullopt)
893 : OthersBase(document, partId, shareMode, cmper, inci)
894 {
895 }
896
901
905 bool contains(MeasCmper measId, Edu eduPosition) const
906 {
907 return (startMeas < measId || (startMeas == measId && startEdu <= eduPosition)) &&
908 (endMeas > measId || (endMeas == measId && endEdu >= eduPosition));
909 }
910
917
921 std::optional<MusicPoint> nextLocation(const std::optional<StaffCmper>& forStaff = std::nullopt) const
922 { return createMusicRange().nextLocation(forStaff); }
923
925};
926
935{
936public:
937
945 explicit NamePositioning(const DocumentWeakPtr& document, Cmper partId = SCORE_PARTID, ShareMode shareMode = ShareMode::All, Cmper cmper = 0)
946 : OthersBase(document, partId, shareMode, cmper) {}
947
951 bool indivPos{};
953 bool expand{};
954 bool hidden{};
955
957};
958
959} // namespace others
960} // namespace dom
961} // namespace mux
EnigmaBase class for classes that are commonly used among others, details, entries,...
Definition BaseClasses.h:158
CommonClassBase(const DocumentWeakPtr &document)
Constructs a CommonClassBase object.
Definition BaseClasses.h:167
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:95
virtual void integrityCheck(const std::shared_ptr< EnigmaBase > &ptrToThis)
Performs a final consistency check after population.
Definition BaseClasses.h:116
Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ow...
Definition Entries.h:555
Represents the default font settings for a particular element type.
Definition CommonClasses.h:111
static constexpr uint16_t EnigmaStyleHidden
Hidden text bit.
Definition CommonClasses.h:169
static constexpr uint16_t EnigmaStyleItalic
Italic style bit.
Definition CommonClasses.h:165
FontInfo(const DocumentWeakPtr &document, bool sizeIsPercent=false)
constructor
Definition CommonClasses.h:118
static constexpr uint16_t EnigmaStyleStrikeout
Strikeout style bit.
Definition CommonClasses.h:167
bool calcIsSymbolFont() const
Calculates if this is a symbol font. (See others::FontDefinition::calcIsSymbolFont....
Definition CommonClasses.cpp:356
static constexpr uint16_t EnigmaStyleUnderline
Underline style bit.
Definition CommonClasses.h:166
uint16_t getEnigmaStyles() const
Returns the font styles as an nfx bitmask.
Definition CommonClasses.h:202
static constexpr uint16_t EnigmaStyleAbsolute
Fixed-size (absolute) bit.
Definition CommonClasses.h:168
static constexpr uint16_t EnigmaStyleBold
Bold style bit.
Definition CommonClasses.h:164
bool strikeout
Strikeout effect.
Definition CommonClasses.h:128
void setFontIdByName(const std::string &name)
Sets the id of the font from a string name.
Definition CommonClasses.cpp:227
Cmper fontId
Font identifier. This is a Cmper for others::FontDefinition.
Definition CommonClasses.h:123
static std::vector< std::filesystem::path > calcSMuFLPaths()
Returns the standard SMuFL font folder.
Definition CommonClasses.cpp:364
bool calcIsSMuFL() const
Calculates whether this is a SMuFL font.
Definition CommonClasses.cpp:297
std::string getName() const
Get the name of the font.
Definition CommonClasses.cpp:219
bool calcIsSameTypeface(const FontInfo &src) const
Return true if the two fonts specify the same typeface, ignoring size and effects.
Definition CommonClasses.cpp:239
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:159
bool isSame(const FontInfo &src) const
Return true if the two fonts represent the same font.
Definition CommonClasses.cpp:252
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:191
ResolvedFontInfo resolve() const
Creates a document-independent snapshot of the font.
Definition CommonClasses.cpp:280
bool italic
Italic effect.
Definition CommonClasses.h:126
bool hidden
Hidden effect.
Definition CommonClasses.h:130
bool calcIsDefaultMusic() const
Calculates if this is the default music font.
Definition CommonClasses.h:215
int fontSize
Font size or percent (where 100 is 100%) of preceding font size. (See getSizeIsPercent....
Definition CommonClasses.h:124
bool underline
Underline effect.
Definition CommonClasses.h:127
bool absolute
Fixed size effect.
Definition CommonClasses.h:129
std::optional< std::filesystem::path > calcSMuFLMetaDataPath() const
Returns the filepath of the SMuFL font's metadata json file, if any.
Definition CommonClasses.h:226
bool bold
Bold effect.
Definition CommonClasses.h:125
Shared key signature class that is contained in other classes. (See others::Measure)
Definition CommonClasses.h:259
void integrityCheck(const std::shared_ptr< EnigmaBase > &ptrToThis) override
Performs a final consistency check after population.
Definition CommonClasses.h:413
Cmper getKeyMode() const
Returns the key mode.
Definition CommonClasses.h:302
bool isSame(const KeySignature &src) const
returns whether the two key signatures represent the same key signature, taking into account transpos...
Definition CommonClasses.h:322
int getAlteration(KeyContext ctx) const
For linear keys, returns the number of sharps or flats from -7..7 (if any).
Definition CommonClasses.h:307
bool hideKeySigShowAccis
Instead of a key signature, show accidentals for the key on the notes where they occur.
Definition CommonClasses.h:286
int calcScaleDegree(int displacement) const
Calculates the scale degree for the given displacement, where 0 is the tonic.
Definition CommonClasses.cpp:626
bool isLinear() const
whether this is a linear key
Definition CommonClasses.h:310
int calcEDODivisions() const
Calculates the number of EDO division for the key. (The standard value is 12.)
Definition CommonClasses.cpp:710
bool isBuiltIn() const
whether this is a built-in key
Definition CommonClasses.h:312
KeyContext
Indicates whether to compute key signature values in concert or written pitch.
Definition CommonClasses.h:273
@ 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:595
int calcTonalCenterIndex(KeyContext ctx) const
Calculates the tonal center index for the key, where C=0, D=1, E=2, ...
Definition CommonClasses.cpp:552
int getOctaveDisplacement(KeyContext ctx) const
The octave displacement if this key is a transposed key.
Definition CommonClasses.h:398
music_theory::Pitch calcPitchFromStaffPosition(int staffPosition, ClefIndex clefIndex, KeyContext ctx, std::optional< int > actualAlteration=std::nullopt) const
Converts a staff position into a spelled pitch using the specified clef and key context.
Definition CommonClasses.cpp:609
uint16_t key
16-bit value intepreted as follows:
Definition CommonClasses.h:284
std::unique_ptr< music_theory::Transposer > createTransposer(int displacement, int alteration) const
Creates a transposer for this KeySignature instance.
Definition CommonClasses.cpp:718
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:723
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:637
int calcAlterationOnNote(unsigned noteIndex, KeyContext ctx) const
Calculates the amount of alteration on a note int the key.
Definition CommonClasses.cpp:563
bool isMinor() const
whether this is a built-in minor key
Definition CommonClasses.h:314
bool isNonLinear() const
whether this is a non-linear key
Definition CommonClasses.h:311
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:328
bool isMajor() const
whether this is a built-in major key
Definition CommonClasses.h:313
std::optional< std::vector< int > > calcKeyMap() const
Calculates the key's diatonic key map.
Definition CommonClasses.cpp:672
bool keyless
Indicates the absence of a key signature.
Definition CommonClasses.h:285
Contains information about a line of lyrics on a system.
Definition CommonClasses.h:447
std::string_view lyricsType
the type of lyric ("chorus", "verse", or "section", corresponding to the xml tags for lyrics text)
Definition CommonClasses.h:461
MusxInstanceList< details::LyricAssign > assignments
The lyric assignments on this line. They all share the same lyricNumber value.
Definition CommonClasses.h:463
Evpu baselinePosition
baseline position of this line on this system, relative to the staff's reference line
Definition CommonClasses.h:460
Cmper lyricNumber
the text number for all lyric assignments on this line.
Definition CommonClasses.h:462
LyricsLineInfo(const DocumentWeakPtr &document, Cmper requestedPartId, std::string_view type, Cmper lyricNo, Evpu baseline)
Constructor function.
Definition CommonClasses.h:455
One text run produced by splitting a syllable's text at an embedded Finale elision marker....
Definition CommonClasses.h:488
bool iterateStyles(util::EnigmaString::TextChunkCallback callback) const
Iterates this run's already-resolved style chunks. In the common case (one style throughout the run) ...
Definition CommonClasses.cpp:1065
bool hasHyphenBefore
See LyricsSyllableInfo::hasHyphenBefore.
Definition CommonClasses.h:491
std::string text() const
This run's text (all style chunks concatenated).
Definition CommonClasses.cpp:1056
bool hasHyphenAfter
See LyricsSyllableInfo::hasHyphenAfter.
Definition CommonClasses.h:492
std::optional< char32_t > joinMarker
The codepoint joining this run to the previous one; absent for the first run.
Definition CommonClasses.h:490
Contains the syllable information for a single syllable. (See texts::LyricsTextBase)
Definition CommonClasses.h:471
bool iterateStyles(util::EnigmaString::TextChunkCallback callback) const
Parse this syllable into chunks with EnigmaStyles for that chunk. In the most common case,...
Definition CommonClasses.cpp:1051
bool hasHyphenAfter
indicates the syllable if followed by a hyphen.
Definition CommonClasses.h:511
std::vector< ElisionRun > calcElisionRuns() const
Splits syllable at embedded Finale elision markers, redistributing hasHyphenBefore and hasHyphenAfter...
Definition CommonClasses.cpp:1075
int strippedUnderscores
indicates the number of trailing underscores stripped (because smart word extensions convert them to ...
Definition CommonClasses.h:512
std::string syllable
the syllable text with no hyphenation or font information.
Definition CommonClasses.h:509
bool hasHyphenBefore
indicates the syllable is preceded by a hyphen.
Definition CommonClasses.h:510
Utility class that represents a single location in musical time.
Definition CommonClasses.h:574
constexpr bool operator>=(const MusicPoint &other) const
Greater-than-or-equal-to comparison operator.
Definition CommonClasses.h:629
constexpr bool operator!=(const MusicPoint &other) const
Inequality comparison operator.
Definition CommonClasses.h:601
constexpr bool operator<=(const MusicPoint &other) const
Less-than-or-equal-to comparison operator.
Definition CommonClasses.h:615
util::Fraction position
Position within the measure, where 1/4 is a quarter note value.
Definition CommonClasses.h:588
constexpr bool operator>(const MusicPoint &other) const
Greater-than comparison operator.
Definition CommonClasses.h:622
constexpr MusicPoint()=default
Constructs a MusicPoint at measure 1, position 0.
constexpr bool operator==(const MusicPoint &other) const
Equality comparison operator.
Definition CommonClasses.h:594
constexpr MusicPoint(MeasCmper measId, util::Fraction pos)
Constructs a MusicPoint object.
Definition CommonClasses.h:582
MeasCmper measureId
Measure ID of the point.
Definition CommonClasses.h:587
constexpr bool operator<(const MusicPoint &other) const
Less-than comparison operator.
Definition CommonClasses.h:608
Utility class that represents of a range of musical time.
Definition CommonClasses.h:643
MusicPoint end
Ending point in the range.
Definition CommonClasses.h:666
MusicRange(const DocumentWeakPtr &document, MeasCmper startMeasId, util::Fraction startPos, MeasCmper endMeasId, util::Fraction endPos)
Constructs a MusicRange object.
Definition CommonClasses.h:651
std::optional< MusicPoint > nextLocation(const std::optional< StaffCmper > &forStaff=std::nullopt) const
Returns the next metric location following the music range.
Definition CommonClasses.cpp:741
MusicPoint start
Starting point in the range.
Definition CommonClasses.h:665
bool contains(MeasCmper measId, util::Fraction position) const
Returns true of the given metric location is contained in this MusicRange instance.
Definition CommonClasses.h:671
bool contains(const MusicPoint &point) const
Returns true if the given metric location is contained in this MusicRange instance.
Definition CommonClasses.h:676
MusicRange(const DocumentWeakPtr &document, MusicPoint startPoint, MusicPoint endPoint)
Constructs a MusicRange object.
Definition CommonClasses.h:660
Provides optional per-type extension methods for MusxInstanceList.
Definition MusxInstance.h:118
EnigmaBase class for all "others" types.
Definition BaseClasses.h:263
Shared time signature class that is derived from other classes. (See others::Measure)
Definition CommonClasses.h:696
bool isSame(const TimeSignature &src) const
returns whether the two time signatures represent the same time signature
Definition CommonClasses.cpp:855
Abbreviation
Specifies whether a time signature is displayed in numeric or abbreviated form.
Definition CommonClasses.h:701
@ 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:943
bool isCutTime() const
Returns if this time signature is cut time.
Definition CommonClasses.cpp:874
std::vector< TimeSigComponent > components
the components in the time signature
Definition CommonClasses.h:738
util::Fraction calcTotalDuration() const
Calculates the total duration of the time signature as a fraction of a whole note.
Definition CommonClasses.h:747
std::optional< char32_t > getAbbreviatedSymbol() const
Returns the abbreviated symbol (code point) for this time signature, or std::nullopt if none.
Definition CommonClasses.cpp:827
bool isCommonTime() const
Returns if this time signature is common time.
Definition CommonClasses.cpp:866
MusxInstance< TimeSignature > createComponent(size_t index) const
Creates a time signature corresponding to the component at index.
Definition CommonClasses.h:773
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:913
Represents independent time and key signature overrides for a staff.
Definition Details.h:1219
Contains assignment data for a lyric assignment (a single syllable)
Definition Details.h:1310
Represents the enclosure settings for text expressions.
Definition CommonClasses.h:826
bool notTall
"Enforce Minimum Width": don't let shape get taller than it is wide
Definition CommonClasses.h:864
Enclosure(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an Enclosure object.
Definition CommonClasses.h:852
Evpu yAdd
Center Y offset - offsets text from center (in EVPU).
Definition CommonClasses.h:856
bool roundCorners
Whether the enclosure has rounded corners.
Definition CommonClasses.h:866
Efix lineWidth
Line thickness in 64ths of an EVPU (EFIX).
Definition CommonClasses.h:859
static const xml::XmlElementArray< Enclosure > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool opaque
Whether the enclosure is opaque.
Definition CommonClasses.h:865
Shape
Enumeration for enclosure shapes.
Definition CommonClasses.h:833
Evpu yMargin
Half height - extra space on top/bottom sides (in EVPU).
Definition CommonClasses.h:858
Shape shape
Enclosure shape (default: NoEnclosure).
Definition CommonClasses.h:860
bool fixedSize
Whether the enclosure is fixed size (ignore text bounding box)
Definition CommonClasses.h:862
bool equalAspect
"Match Height and Width"
Definition CommonClasses.h:863
Efix cornerRadius
Corner radius (in EFIX).
Definition CommonClasses.h:861
Evpu xMargin
Half width - extra space on left/right sides (in EVPU).
Definition CommonClasses.h:857
Evpu xAdd
Center X offset - offsets text from center (in EVPU).
Definition CommonClasses.h:855
The representation of a range of music used by Enigma files.
Definition CommonClasses.h:881
MeasCmper startMeas
Starting measure in the range.
Definition CommonClasses.h:897
std::optional< MusicPoint > nextLocation(const std::optional< StaffCmper > &forStaff=std::nullopt) const
Returns the next metric location following the music range.
Definition CommonClasses.h:921
MeasCmper endMeas
Ending measure in the range.
Definition CommonClasses.h:899
MusicRange createMusicRange() const
Creates a MusicRange instance corresponding to this instance. The MusicRange uses util::Fraction for ...
Definition CommonClasses.h:913
Edu startEdu
Starting EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:898
Edu endEdu
Ending EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:900
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:891
bool contains(MeasCmper measId, Edu eduPosition) const
Returns true of the given metric location is contained in this EnigmaMusicRange instance.
Definition CommonClasses.h:905
static const xml::XmlElementArray< EnigmaMusicRange > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
The name and font characteristics of fonts contained.
Definition Others.h:564
Represents the attributes of a measure.
Definition Others.h:1155
Contains horizontal and vertical offsets, alignment, and expansion settings for name positioning.
Definition CommonClasses.h:935
bool indivPos
Indicates that this positioning overrides the default positioning. (Not used by options::StaffOptions...
Definition CommonClasses.h:951
NamePositioning(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an NamePositioning object.
Definition CommonClasses.h:945
bool hidden
Inverse of "Show": it hides the name.
Definition CommonClasses.h:954
bool expand
"Expand Single Word"
Definition CommonClasses.h:953
Evpu horzOff
Horizontal distance from staff in Evpu.
Definition CommonClasses.h:948
AlignJustify hAlign
Horizontal alignment for the name text. (xml node is <halign>)
Definition CommonClasses.h:952
AlignJustify justify
Justification for the name text.
Definition CommonClasses.h:950
Evpu vertOff
Vertical offset from staff in Evpu.
Definition CommonClasses.h:949
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
std::function< bool(const std::string &text, const EnigmaStyles &styles)> TextChunkCallback
Iteration function type that the parser calls back when the font has changed or when recursively pars...
Definition EnigmaString.h:385
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:132
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
std::string normalizeFontName(std::string_view name)
Normalizes a font name for comparison by removing ASCII whitespace and folding ASCII case.
Definition CommonClasses.cpp:95
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
uint16_t ClefIndex
Index into options::ClefOptions::clefDefs.
Definition Fundamentals.h:70
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:63
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition DocumentElement.h:37
std::function< void(const EnigmaBase &)> ImportObjectCallback
Receives each document-pool object newly created by an import helper.
Definition BaseClasses.h:150
std::shared_ptr< Document > DocumentPtr
Shared Document pointer.
Definition DocumentElement.h:35
AlignJustify
Alignment and justification options for staff and group names.
Definition EnumClasses.h:30
std::optional< Cmper > importFontDefinitionInto(const DocumentPtr &target, const MusxInstance< others::FontDefinition > &source, const ImportObjectCallback &onImported)
Copies a font definition into another document, reusing an equivalent one when present.
Definition CommonClasses.cpp:179
std::vector< XmlElementDescriptor< T > > XmlElementArray
an array type for XmlElementDescriptor instances.
Definition XmlInterface.h:133
object model for musx file (enigmaxml)
Definition BaseClasses.h:38
A spelled pitch, expressed relative to C4.
Definition music_theory.hpp:84
Document-independent snapshot of a #FontInfo. (See FontInfo::resolve.)
Definition ResolvedFontInfo.h:36
A single time signature component.
Definition CommonClasses.h:709
std::vector< util::Fraction > counts
Definition CommonClasses.h:710
std::vector< Edu > units
Definition CommonClasses.h:712
util::Fraction sumCounts() const
Compute the sum of all counts.
Definition CommonClasses.h:721
TimeSigComponent normalizeCompound() const
Returns a copy of this component normalized for compound meter. For example, 2 dotted quarters become...
Definition CommonClasses.cpp:898
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:882
Edu sumUnits() const
Compute the sum of all units.
Definition CommonClasses.h:725
bool operator==(const TimeSigComponent &src) const
Test if two TimeSigComponent values are the same.
Definition CommonClasses.h:717