28#include "musx/util/Fraction.h"
29#include "BaseClasses.h"
61 Whole = EDU_PER_WHOLE_NOTE,
229 bool m_sizeIsPercent;
286 {
return isLinear() ? int(int8_t(
key & 0xff)) + getAlterationOffset(ctx) : 0; }
302 return isSameConcert(src) && m_alterationOffset == src.m_alterationOffset && m_octaveDisplacement == src.m_octaveDisplacement;
351 std::optional<std::vector<int>>
calcKeyMap()
const;
357 std::unique_ptr<music_theory::Transposer>
createTransposer(
int displacement,
int alteration)
const;
363 MUSX_INTEGRITY_ERROR(
"Key signature has invalid key value: " + std::to_string(
key));
370 std::vector<unsigned> calcTonalCenterArrayForSharps()
const;
371 std::vector<unsigned> calcTonalCenterArrayForFlats()
const;
372 std::vector<unsigned> calcTonalCenterArray(
KeyContext ctx)
const;
373 std::vector<int> calcAcciAmountsArray(
KeyContext ctx)
const;
374 std::vector<unsigned> calcAcciOrderArray(
KeyContext ctx)
const;
376 int m_octaveDisplacement{};
377 int m_alterationOffset{};
441 {
return std::accumulate(
units.begin(),
units.end(),
Edu{}); }
457 { return acc + (comp.sumCounts() * comp.sumUnits()); }
459 return result /
Edu(NoteType::Whole);
489 void checkIndex(
size_t index)
const
492 throw std::invalid_argument(
"Index out of range. The time signature has " + std::to_string(
components.size())
493 +
" elements. The index requested was " + std::to_string(index) +
".");
501 explicit TimeSignature(
const DocumentWeakPtr& document,
int beats,
Edu unit,
bool hasCompositeTop,
bool hasCompositeBottom,
502 std::optional<bool> abbreviate = std::nullopt);
508 explicit TimeSignature(
const DocumentWeakPtr& document,
const TimeSigComponent& timeSigUnit, std::optional<bool> abbreviate)
509 : CommonClassBase(document), m_abbreviate(abbreviate)
514 std::optional<bool> m_abbreviate;
516 friend class others::Measure;
517 friend class details::IndependentStaffDetails;
556 :
OthersBase(document, partId, shareMode, cmper) {}
593 Cmper cmper = 0, std::optional<Inci> inci = std::nullopt)
594 :
OthersBase(document, partId, shareMode, cmper, inci)
618 std::optional<std::pair<MeasCmper, Edu>>
nextLocation(
const std::optional<StaffCmper>& forStaff = std::nullopt)
const;
642 :
OthersBase(document, partId, shareMode, cmper) {}
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
Represents the default font settings for a particular element type.
Definition CommonClasses.h:122
static constexpr uint16_t EnigmaStyleHidden
Hidden text bit.
Definition CommonClasses.h:154
static constexpr uint16_t EnigmaStyleItalic
Italic style bit.
Definition CommonClasses.h:150
FontInfo(const DocumentWeakPtr &document, bool sizeIsPercent=false)
constructor
Definition CommonClasses.h:129
static constexpr uint16_t EnigmaStyleStrikeout
Strikeout style bit.
Definition CommonClasses.h:152
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:151
uint16_t getEnigmaStyles() const
Returns the font styles as an nfx bitmask.
Definition CommonClasses.h:187
static constexpr uint16_t EnigmaStyleAbsolute
Fixed-size (absolute) bit.
Definition CommonClasses.h:153
static constexpr uint16_t EnigmaStyleBold
Bold style bit.
Definition CommonClasses.h:149
bool strikeout
Strikeout effect.
Definition CommonClasses.h:139
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:134
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:144
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:176
bool italic
Italic effect.
Definition CommonClasses.h:137
bool hidden
Hidden effect.
Definition CommonClasses.h:141
bool calcIsDefaultMusic() const
Calculates if this is the default music font.
Definition CommonClasses.h:200
int fontSize
Font size or percent (where 100 is 100%) of preceding font size. (See getSizeIsPercent....
Definition CommonClasses.h:135
bool underline
Underline effect.
Definition CommonClasses.h:138
bool absolute
Fixed size effect.
Definition CommonClasses.h:140
std::optional< std::filesystem::path > calcSMuFLMetaDataPath() const
Returns the filepath of the SMuFL font's metadata json file, if any.
Definition CommonClasses.h:211
bool bold
Bold effect.
Definition CommonClasses.h:136
Shared key signature class that is contained in other classes. (See others::Measure)
Definition CommonClasses.h:237
Cmper getKeyMode() const
Returns the key mode.
Definition CommonClasses.h:280
bool isSame(const KeySignature &src) const
returns whether the two key signatures represent the same key signature, taking into account transpos...
Definition CommonClasses.h:300
int getAlteration(KeyContext ctx) const
For linear keys, returns the number of sharps or flats from -7..7 (if any).
Definition CommonClasses.h:285
bool hideKeySigShowAccis
Instead of a key signature, show accidentals for the key on the notes where they occur.
Definition CommonClasses.h:264
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:359
bool isLinear() const
whether this is a linear key
Definition CommonClasses.h:288
int calcEDODivisions() const
Calculates the number of EDO division for the key. (The standard value is 12.)
Definition CommonClasses.cpp:418
bool isBuiltIn() const
whether this is a built-in key
Definition CommonClasses.h:290
KeyContext
Indicates whether to compute key signature values in concert or written pitch.
Definition CommonClasses.h:251
@ 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:302
int getOctaveDisplacement(KeyContext ctx) const
The octave displacement if this key is a transposed key.
Definition CommonClasses.h:344
uint16_t key
16-bit value intepreted as follows:
Definition CommonClasses.h:262
std::unique_ptr< music_theory::Transposer > createTransposer(int displacement, int alteration) const
Creates a transposer for this KeySignature instance.
Definition CommonClasses.cpp:426
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:431
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:345
int calcAlterationOnNote(unsigned noteIndex, KeyContext ctx) const
Calculates the amount of alteration on a note int the key.
Definition CommonClasses.cpp:313
bool isMinor() const
whether this is a built-in minor key
Definition CommonClasses.h:292
bool isNonLinear() const
whether this is a non-linear key
Definition CommonClasses.h:289
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:306
bool isMajor() const
whether this is a built-in major key
Definition CommonClasses.h:291
std::optional< std::vector< int > > calcKeyMap() const
Calculates the key's diatonic key map.
Definition CommonClasses.cpp:380
bool keyless
Indicates the absence of a key signature.
Definition CommonClasses.h:263
Contains the syllable information for a single syllable. (See texts::LyricsTextBase)
Definition CommonClasses.h:393
bool hasHyphenAfter
indicates the syllable if followed by a hyphen.
Definition CommonClasses.h:398
std::string syllable
the syllable text with no hyphenation or font information.
Definition CommonClasses.h:396
bool hasHyphenBefore
indicates the syllable is preceded by a hyphen.
Definition CommonClasses.h:397
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:419
bool isSame(const TimeSignature &src) const
returns whether the two time signatures represent the same time signature
Definition CommonClasses.h:463
bool isCutTime() const
Returns if this time signature is cut time.
Definition CommonClasses.cpp:529
std::vector< TimeSigComponent > components
the components in the time signature
Definition CommonClasses.h:444
util::Fraction calcTotalDuration() const
Calculates the total duration of the time signature as a fraction of a whole note.
Definition CommonClasses.h:453
std::optional< char32_t > getAbbreviatedSymbol() const
Returns the abbreviated symbol (code point) for this time signature, or std::nullopt if none.
Definition CommonClasses.cpp:498
bool isCommonTime() const
Returns if this time signature is common time.
Definition CommonClasses.cpp:521
MusxInstance< TimeSignature > createComponent(size_t index) const
Creates a time signature corresponding to the component at index.
Definition CommonClasses.h:471
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:537
Represents independent time and key signature overrides for a staff.
Definition Details.h:721
Represents the enclosure settings for text expressions.
Definition CommonClasses.h:529
bool notTall
"Enforce Minimum Width": don't let shape get taller than it is wide
Definition CommonClasses.h:567
Evpu yAdd
Center Y offset - offsets text from center (in EVPU).
Definition CommonClasses.h:559
Enclosure(const DocumentWeakPtr &document, Cmper partId=0, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an Enclosure object.
Definition CommonClasses.h:555
bool roundCorners
Whether the enclosure has rounded corners.
Definition CommonClasses.h:569
Efix lineWidth
Line thickness in 64ths of an EVPU (EFIX).
Definition CommonClasses.h:562
static const xml::XmlElementArray< Enclosure > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool opaque
Whether the enclosure is opaque.
Definition CommonClasses.h:568
Shape
Enumeration for enclosure shapes.
Definition CommonClasses.h:536
@ NoEnclosure
No enclosure.
Evpu yMargin
Half height - extra space on top/bottom sides (in EVPU).
Definition CommonClasses.h:561
Shape shape
Enclosure shape (default: NoEnclosure).
Definition CommonClasses.h:563
bool fixedSize
Whether the enclosure is fixed size (ignore text bounding box)
Definition CommonClasses.h:565
bool equalAspect
"Match Height and Width"
Definition CommonClasses.h:566
Efix cornerRadius
Corner radius (in EFIX).
Definition CommonClasses.h:564
Evpu xMargin
Half width - extra space on left/right sides (in EVPU).
Definition CommonClasses.h:560
Evpu xAdd
Center X offset - offsets text from center (in EVPU).
Definition CommonClasses.h:558
Represents the attributes of a measure.
Definition Others.h:963
Represents a range of music using measure and EDUs.
Definition CommonClasses.h:582
Edu startEdu
Starting EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:599
MeasCmper endMeas
Ending measure in the range.
Definition CommonClasses.h:600
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 Others.cpp:274
static const xml::XmlElementArray< MusicRange > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
Edu endEdu
Ending EDU (Elapsed Durational Unit) in the range.
Definition CommonClasses.h:601
MusicRange(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0, std::optional< Inci > inci=std::nullopt)
Constructs a MusicRange object.
Definition CommonClasses.h:592
MeasCmper startMeas
Starting measure in the range.
Definition CommonClasses.h:598
bool contains(MeasCmper measId, Edu eduPosition) const
Returns true of the given metric location is contained in this MusicRange instance.
Definition CommonClasses.h:606
Contains horizontal and vertical offsets, alignment, and expansion settings for name positioning.
Definition CommonClasses.h:631
bool indivPos
Indicates that this positioning overrides the default positioning. (Not used by options::StaffOptions...
Definition CommonClasses.h:656
NamePositioning(const DocumentWeakPtr &document, Cmper partId=SCORE_PARTID, ShareMode shareMode=ShareMode::All, Cmper cmper=0)
Constructs an NamePositioning object.
Definition CommonClasses.h:641
bool expand
"Expand Single Word"
Definition CommonClasses.h:658
AlignJustify
Alignment and justification options for staff and group names.
Definition CommonClasses.h:647
@ Center
Center alignment.
@ Left
Left alignment or justification (the default value.)
Evpu horzOff
Horizontal distance from staff in Evpu.
Definition CommonClasses.h:653
AlignJustify hAlign
Horizontal alignment for the name text. (xml node is <halign>)
Definition CommonClasses.h:657
AlignJustify justify
Justification for the name text.
Definition CommonClasses.h:655
Evpu vertOff
Vertical offset from staff in Evpu.
Definition CommonClasses.h:654
static const xml::XmlElementArray< NamePositioning > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
Represents the definition of a Finale staff.
Definition Staff.h:43
Base class for lyrics text.
Definition Texts.h:122
A class to represent fractions with integer m_numerator and m_denominator, automatically reduced to s...
Definition Fraction.h:38
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:108
@ 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")
NoteType
Enum class representing note types based on EDU values.
Definition CommonClasses.h:57
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:35
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:82
@ 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:424
std::vector< util::Fraction > counts
Definition CommonClasses.h:425
std::vector< Edu > units
Definition CommonClasses.h:427
util::Fraction sumCounts() const
Compute the sum of all counts.
Definition CommonClasses.h:436
Edu sumUnits() const
Compute the sum of all units.
Definition CommonClasses.h:440
bool operator==(const TimeSigComponent &src) const
Test if two TimeSigComponent values are the same.
Definition CommonClasses.h:432