27#include "Enumerations.h"
36 using NumType = unsigned;
39 static constexpr size_t NUMERATOR_INDEX = 0;
40 static constexpr size_t DENOMINATOR_INDEX = 1;
50 throw std::invalid_argument(
"mnx::Fraction must have exactly 2 elements.");
71#ifndef DOXYGEN_SHOULD_IGNORE_THIS
75 return a.numerator() * b.denominator() == b.numerator() * a.denominator();
78inline bool operator!=(
const Fraction& a,
const Fraction& b) {
82inline bool operator<(
const Fraction& a,
const Fraction& b) {
83 return a.numerator() * b.denominator() < b.numerator() * a.denominator();
86inline bool operator<=(
const Fraction& a,
const Fraction& b) {
90inline bool operator>(
const Fraction& a,
const Fraction& b) {
94inline bool operator>=(
const Fraction& a,
const Fraction& b) {
120 create_fraction(position);
149 set_measure(measureId);
150 create_position(position);
214 set_base(noteValue.base);
215 if (noteValue.dots) {
216 set_dots(noteValue.dots);
249 create_duration(noteValue);
Represents an MNX array, encapsulating property access.
Definition BaseTypes.h:483
size_t size() const
Get the size of the array.
Definition BaseTypes.h:526
std::enable_if_t<!std::is_base_of_v< Base, U >, void > push_back(const U &value)
Append a new value to the array. (Available only for primitive types)
Definition BaseTypes.h:559
Base class wrapper for all MNX JSON nodes.
Definition BaseTypes.h:210
json_pointer pointer() const
Returns the json_pointer for this node.
Definition BaseTypes.h:271
T parent() const
Returns the parent object for this node.
Definition BaseTypes.h:258
const std::shared_ptr< json > & root() const
Returns the root.
Definition BaseTypes.h:288
Represents a fraction of a whole note, for measuring musical time.
Definition CommonClasses.h:34
std::pair< NumType, NumType > Initializer
initializer for Fraction class (numerator, denominator)
Definition CommonClasses.h:43
MNX_ARRAY_ELEMENT_PROPERTY(NumType, denominator, DENOMINATOR_INDEX)
the denominator of the fraction
Fraction(Base &parent, const std::string_view &key, const Initializer &value)
Creates a new Array class as a child of a JSON element.
Definition CommonClasses.h:58
MNX_ARRAY_ELEMENT_PROPERTY(NumType, numerator, NUMERATOR_INDEX)
the numerator of the fraction
Fraction(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor to wrap a Fraction instance around existing JSON.
Definition CommonClasses.h:46
Represents a key signature.
Definition CommonClasses.h:162
MNX_OPTIONAL_PROPERTY(std::string, color)
color to use when rendering the key signature
KeySignature(Base &parent, const std::string_view &key, int fifths)
Creates a new KeySignature class as a child of a JSON element.
Definition CommonClasses.h:174
KeySignature(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing KeySignature objects.
Definition CommonClasses.h:165
MNX_OPTIONAL_NAMED_PROPERTY(std::string, styleClass, "class")
style class
MNX_REQUIRED_PROPERTY(int, fifths)
offset from signature with no accidentals
Represents a system on a page in a score.
Definition CommonClasses.h:133
MNX_REQUIRED_PROPERTY(int, measure)
The measure id of the measure of this MeasureRhythmicPosition.
MeasureRhythmicPosition(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing rhythmic position instances.
Definition CommonClasses.h:136
MNX_REQUIRED_CHILD(RhythmicPosition, position)
The metric position, where 1/4 is a quarter note.
MeasureRhythmicPosition(Base &parent, const std::string_view &key, int measureId, const Fraction::Initializer &position)
Creates a new MeasureRhythmicPosition class as a child of a JSON element.
Definition CommonClasses.h:146
Represents a quantity of symbolic note values=.
Definition CommonClasses.h:232
MNX_REQUIRED_CHILD(NoteValue, duration)
duration unit
MNX_REQUIRED_PROPERTY(unsigned, multiple)
quantity of duration units
NoteValueQuantity(Base &parent, const std::string_view &key, unsigned count, const NoteValue::Initializer ¬eValue)
Creates a new Barline class as a child of a JSON element.
Definition CommonClasses.h:245
NoteValueQuantity(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing NoteValue instances.
Definition CommonClasses.h:235
Definition CommonClasses.h:193
Represents a symbolic note value (not necessarily a duration)
Definition CommonClasses.h:190
MNX_OPTIONAL_PROPERTY_WITH_DEFAULT(unsigned, dots, 0)
the number of dots
unsigned calcNumberOfFlags() const
Calculates the number of flags or beams required by this note value.
Definition Implementations.cpp:134
NoteValue(Base &parent, const std::string_view &key, const Initializer ¬eValue)
Creates a new Barline class as a child of a JSON element.
Definition CommonClasses.h:211
NoteValue(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing NoteValue instances.
Definition CommonClasses.h:202
MNX_REQUIRED_PROPERTY(NoteValueBase, base)
the type ("base") of note
Represents an MNX object, encapsulating property access.
Definition BaseTypes.h:420
Represents a system on a page in a score.
Definition CommonClasses.h:105
RhythmicPosition(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing rhythmic position instances.
Definition CommonClasses.h:108
RhythmicPosition(Base &parent, const std::string_view &key, const Fraction::Initializer &position)
Creates a new RhythmicPosition class as a child of a JSON element.
Definition CommonClasses.h:117
MNX_OPTIONAL_PROPERTY(unsigned, graceIndex)
(0 is the primary, and then count to the left.)
MNX_REQUIRED_CHILD(Fraction, fraction)
The metric position, where 1/4 is a quarter note.
Represents the tempo for a global measure.
Definition CommonClasses.h:261
MNX_REQUIRED_PROPERTY(TimeSignatureUnit, unit)
the unit value (bottom number)
TimeSignature(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing NoteValue instances.
Definition CommonClasses.h:264
TimeSignature(Base &parent, const std::string_view &key, int count, TimeSignatureUnit unit)
Creates a new Barline class as a child of a JSON element.
Definition CommonClasses.h:274
MNX_REQUIRED_PROPERTY(int, count)
the number of beats (top number)
object model for MNX format
json::json_pointer json_pointer
JSON pointer class for MNX.
Definition BaseTypes.h:197
TimeSignatureUnit
Valid units for the lower numbers of time signatures.
Definition Enumerations.h:276
NoteValueBase
The note values allowed in MNX.
Definition Enumerations.h:187