MUSX Document Model
Loading...
Searching...
No Matches
musx::dom::TimeSignature Class Reference

Shared time signature class that is derived from other classes. (See others::Measure) More...

#include <CommonClasses.h>

+ Inheritance diagram for musx::dom::TimeSignature:

Classes

struct  TimeSigComponent
 A single time signature component. More...
 

Public Types

enum class  Abbreviation { NotApplicable , Numeric , Abbreviated }
 Specifies whether a time signature is displayed in numeric or abbreviated form. More...
 

Public Member Functions

std::pair< util::Fraction, NoteTypecalcSimplified () const
 Calculates the simplest form of of this time signature, expressed as a fractional count of NoteType units.
 
util::Fraction calcTotalDuration () const
 Calculates the total duration of the time signature as a fraction of a whole note.
 
util::Fraction calcBeatValueAt (Edu eduPosition) const
 Returns the beat value (duration) at the given EDU position.
 
bool isSame (const TimeSignature &src) const
 returns whether the two time signatures represent the same time signature
 
MusxInstance< TimeSignaturecreateComponent (size_t index) const
 Creates a time signature corresponding to the component at index.
 
std::optional< char32_t > getAbbreviatedSymbol () const
 Returns the abbreviated symbol (code point) for this time signature, or std::nullopt if none.
 
bool isCommonTime () const
 Returns if this time signature is common time.
 
bool isCutTime () const
 Returns if this time signature is cut time.
 
- Public Member Functions inherited from musx::dom::DocumentElementNoPart
 DocumentElementNoPart (const DocumentWeakPtr &document)
 Constructs the document element (with no meaningful associated part)
 
- Public Member Functions inherited from musx::dom::DocumentElement
virtual ~DocumentElement () noexcept(false)=default
 Virtual destructor for polymorphic behavior.
 
DocumentPtr getDocument () const
 Gets a reference to the Document.
 
Cmper getPartId () const
 Gets the part id associated with this instance.
 

Public Attributes

std::vector< TimeSigComponentcomponents
 the components in the time signature
 

Friends

class others::Measure
 
class others::OssiaHeader
 
class details::IndependentStaffDetails
 

Additional Inherited Members

- Protected Member Functions inherited from musx::dom::DocumentElement
 DocumentElement (const DocumentWeakPtr &document, Cmper partId)
 Constructs the document element.
 
 DocumentElement (const DocumentElement &)=default
 explicit default copy constructor
 
 DocumentElement (DocumentElement &&) noexcept=default
 explicit default move constructor
 
DocumentElementoperator= (const DocumentElement &)
 no-op copy assignment operator allows subclasses to copy their values.
 
DocumentElementoperator= (DocumentElement &&) noexcept
 no-op move assignment operator allows subclasses to move their values.
 

Detailed Description

Shared time signature class that is derived from other classes. (See others::Measure)

Member Enumeration Documentation

◆ Abbreviation

Specifies whether a time signature is displayed in numeric or abbreviated form.

Enumerator
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).

Member Function Documentation

◆ calcBeatValueAt()

util::Fraction musx::dom::TimeSignature::calcBeatValueAt ( Edu  eduPosition) const

Returns the beat value (duration) at the given EDU position.

Each TimeSigComponent is treated as a run of identical beats:

  • The beat value is the sum of comp.units (in EDU).
  • The number of beats is the sum of comp.counts (as util::Fraction).
Parameters
eduPositionPosition from the start of the measure, in EDU.
Returns
Beat value at eduPosition as a fraction of a whole note. Returns 0 if no beat information is available.

◆ calcSimplified()

std::pair< util::Fraction, NoteType > musx::dom::TimeSignature::calcSimplified ( ) const

Calculates the simplest form of of this time signature, expressed as a fractional count of NoteType units.

In typical cases, the returned util::Fraction has a denominator of 1, but Finale supports other kinds of fractions. Use util::Fraction::quotient to get the integer value and util::Fraction::remainder to get the residual fractional component.

◆ createComponent()

MusxInstance< TimeSignature > musx::dom::TimeSignature::createComponent ( size_t  index) const
inline

Creates a time signature corresponding to the component at index.

Parameters
indexThe 0-based component index
Exceptions
std::invalid_argumentif index is out of range

◆ getAbbreviatedSymbol()

std::optional< char32_t > musx::dom::TimeSignature::getAbbreviatedSymbol ( ) const

Returns the abbreviated symbol (code point) for this time signature, or std::nullopt if none.

If the musx document lacks music symbol options but abbreviation was requested, the SMuFL values are returned as default substitute values.