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);
178 set_halfSteps(halfSteps);
179 set_staffDistance(staffDistance);
245 set_base(noteValue.
base);
246 if (noteValue.
dots) {
247 set_dots(noteValue.
dots);
280 create_duration(noteValue);
Represents an MNX array, encapsulating property access.
Definition BaseTypes.h:487
size_t size() const
Get the size of the array.
Definition BaseTypes.h:530
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:563
Base class wrapper for all MNX JSON nodes.
Definition BaseTypes.h:211
json_pointer pointer() const
Returns the json_pointer for this node.
Definition BaseTypes.h:272
T parent() const
Returns the parent object for this node.
Definition BaseTypes.h:259
const std::shared_ptr< json > & root() const
Returns the root.
Definition BaseTypes.h:289
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 musical chromatic interval.
Definition CommonClasses.h:162
MNX_REQUIRED_PROPERTY(int, halfSteps)
the number of 12-EDO chromatic halfsteps in the interval (negative is down)
Interval(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing NoteValue instances.
Definition CommonClasses.h:165
MNX_REQUIRED_PROPERTY(int, staffDistance)
the number of diatonic steps in the interval (negative is down)
Interval(Base &parent, const std::string_view &key, int staffDistance, int halfSteps)
Creates a new Barline class as a child of a JSON element.
Definition CommonClasses.h:175
Represents a key signature.
Definition CommonClasses.h:191
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:203
KeySignature(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing KeySignature objects.
Definition CommonClasses.h:194
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:263
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:276
NoteValueQuantity(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing NoteValue instances.
Definition CommonClasses.h:266
initializer class for NoteValue
Definition CommonClasses.h:223
Initializer(NoteValueBase inBase, unsigned inDots=0)
constructor
Definition CommonClasses.h:229
unsigned dots
the number of dots to initialize
Definition CommonClasses.h:226
NoteValueBase base
the note value base to initialize
Definition CommonClasses.h:225
Represents a symbolic note value (not necessarily a duration)
Definition CommonClasses.h:219
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:143
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:242
NoteValue(const std::shared_ptr< json > &root, json_pointer pointer)
Constructor for existing NoteValue instances.
Definition CommonClasses.h:233
MNX_REQUIRED_PROPERTY(NoteValueBase, base)
the type ("base") of note
Represents an MNX object, encapsulating property access.
Definition BaseTypes.h:421
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:292
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:295
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:305
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:198
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