Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/include/mx/api/AccordionRegistrationData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// MusicXML Class Library
// Copyright (c) by Matthew James Briggs
// Distributed under the MIT License

#pragma once

#include "mx/api/ApiCommon.h"
#include "mx/api/ColorData.h"
#include "mx/api/FontData.h"
#include "mx/api/PositionData.h"

#include <optional>
#include <string>

namespace mx
{
namespace api
{
// An accordion registration symbol, MusicXML's <accordion-registration> element: the circular
// three-section diagram telling the player which reed ranks to engage. high engages the high
// (4') section, drawn as a dot in the top section; middle engages the middle (8') section with
// 1 to 3 dots; low engages the low (16') section, drawn as a dot in the bottom section. An
// absent middle means no middle-section dots. A registration with nothing engaged is legal and
// draws the empty diagram.
class AccordionRegistrationData
{
public:
bool high;
std::optional<int> middle;
bool low;
PositionData positionData;
FontData fontData;
std::optional<ColorData> color;
std::optional<std::string> id;

AccordionRegistrationData() : high{false}, middle{}, low{false}, positionData{}, fontData{}, color{}, id{}
{
}
};

MXAPI_EQUALS_BEGIN(AccordionRegistrationData)
MXAPI_EQUALS_MEMBER(high)
MXAPI_EQUALS_MEMBER(middle)
MXAPI_EQUALS_MEMBER(low)
MXAPI_EQUALS_MEMBER(positionData)
MXAPI_EQUALS_MEMBER(fontData)
MXAPI_EQUALS_MEMBER(color)
MXAPI_EQUALS_MEMBER(id)
MXAPI_EQUALS_END;
MXAPI_NOT_EQUALS_AND_VECTORS(AccordionRegistrationData);
} // namespace api
} // namespace mx
20 changes: 19 additions & 1 deletion src/include/mx/api/DirectionData.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

#pragma once

#include "mx/api/AccordionRegistrationData.h"
#include "mx/api/ApiCommon.h"
#include "mx/api/ChordData.h"
#include "mx/api/CodaData.h"
#include "mx/api/DampData.h"
#include "mx/api/EyeglassesData.h"
#include "mx/api/FiguredBassData.h"
#include "mx/api/ImageData.h"
#include "mx/api/MarkData.h"
#include "mx/api/OtherDirectionData.h"
#include "mx/api/OttavaData.h"
#include "mx/api/PrincipalVoiceData.h"
#include "mx/api/RehearsalData.h"
#include "mx/api/SegnoData.h"
#include "mx/api/SoundData.h"
Expand Down Expand Up @@ -48,7 +52,11 @@ enum class DirectionComponentKind
dampAll,
eyeglasses,
stringMute,
staffDivide
staffDivide,
principalVoice,
otherDirection,
image,
accordionRegistration
};

struct DirectionComponent
Expand Down Expand Up @@ -134,6 +142,10 @@ struct DirectionData
std::vector<EyeglassesData> eyeglasses;
std::vector<StringMuteData> stringMutes;
std::vector<StaffDivideData> staffDivides;
std::vector<PrincipalVoiceData> principalVoices;
std::vector<OtherDirectionData> otherDirections;
std::vector<ImageData> images;
std::vector<AccordionRegistrationData> accordionRegistrations;
// Preserves the original order of direction-type children from parsed XML
// for round-trip fidelity. Do NOT populate this when constructing
// DirectionData programmatically. If empty, the writer uses a default
Expand Down Expand Up @@ -163,6 +175,8 @@ inline bool isDirectionDataEmpty(const DirectionData &directionData)
directionData.rehearsals.size() == 0 && directionData.damps.size() == 0 &&
directionData.dampAlls.size() == 0 && directionData.eyeglasses.size() == 0 &&
directionData.stringMutes.size() == 0 && directionData.staffDivides.size() == 0 &&
directionData.principalVoices.size() == 0 && directionData.otherDirections.size() == 0 &&
directionData.images.size() == 0 && directionData.accordionRegistrations.size() == 0 &&
directionData.figuredBasses.size() == 0 && !directionData.isSoundDataSpecified &&
directionData.orderedComponents.size() == 0;
}
Expand Down Expand Up @@ -197,6 +211,10 @@ MXAPI_EQUALS_MEMBER(dampAlls)
MXAPI_EQUALS_MEMBER(eyeglasses)
MXAPI_EQUALS_MEMBER(stringMutes)
MXAPI_EQUALS_MEMBER(staffDivides)
MXAPI_EQUALS_MEMBER(principalVoices)
MXAPI_EQUALS_MEMBER(otherDirections)
MXAPI_EQUALS_MEMBER(images)
MXAPI_EQUALS_MEMBER(accordionRegistrations)
MXAPI_EQUALS_MEMBER(orderedComponents)
MXAPI_EQUALS_END;
MXAPI_NOT_EQUALS_AND_VECTORS(DirectionData);
Expand Down
49 changes: 49 additions & 0 deletions src/include/mx/api/ImageData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// MusicXML Class Library
// Copyright (c) by Matthew James Briggs
// Distributed under the MIT License

#pragma once

#include "mx/api/ApiCommon.h"
#include "mx/api/PositionData.h"

#include <optional>
#include <string>

namespace mx
{
namespace api
{
// A graphic placed in the music, MusicXML's <image> direction: source locates the graphic file
// (a URL or file reference) and type gives its MIME type, e.g. "image/png". height and width,
// in tenths, scale the image; give one alone to scale proportionally. positionData captures
// default/relative x-y plus the horizontal and vertical alignment of the image relative to its
// position point; an image's vertical alignment has no baseline variant, so a baseline value
// here is not written. positionData's placement member is unused because <image> has no
// placement attribute (placement lives on the parent <direction>).
class ImageData
{
public:
std::string source;
std::string type;
std::optional<double> height;
std::optional<double> width;
PositionData positionData;
std::optional<std::string> id;

ImageData() : source{}, type{}, height{}, width{}, positionData{}, id{}
{
}
};

MXAPI_EQUALS_BEGIN(ImageData)
MXAPI_EQUALS_MEMBER(source)
MXAPI_EQUALS_MEMBER(type)
MXAPI_EQUALS_MEMBER(height)
MXAPI_EQUALS_MEMBER(width)
MXAPI_EQUALS_MEMBER(positionData)
MXAPI_EQUALS_MEMBER(id)
MXAPI_EQUALS_END;
MXAPI_NOT_EQUALS_AND_VECTORS(ImageData);
} // namespace api
} // namespace mx
51 changes: 51 additions & 0 deletions src/include/mx/api/OtherDirectionData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// MusicXML Class Library
// Copyright (c) by Matthew James Briggs
// Distributed under the MIT License

#pragma once

#include "mx/api/ApiCommon.h"
#include "mx/api/ColorData.h"
#include "mx/api/FontData.h"
#include "mx/api/PositionData.h"

#include <optional>
#include <string>

namespace mx
{
namespace api
{
// A direction that has no dedicated MusicXML element, carried by the <other-direction>
// catch-all. The text is the direction's content; when the direction is best shown as a
// standard SMuFL glyph, smufl names that glyph (a canonical SMuFL glyph name) and the text
// serves as a fallback description. Set printObject to no for a direction that affects
// playback or analysis but should not be drawn.
class OtherDirectionData
{
public:
std::string text;
Bool printObject;
std::optional<std::string> smufl;
PositionData positionData;
FontData fontData;
std::optional<ColorData> color;
std::optional<std::string> id;

OtherDirectionData() : text{}, printObject{Bool::unspecified}, smufl{}, positionData{}, fontData{}, color{}, id{}
{
}
};

MXAPI_EQUALS_BEGIN(OtherDirectionData)
MXAPI_EQUALS_MEMBER(text)
MXAPI_EQUALS_MEMBER(printObject)
MXAPI_EQUALS_MEMBER(smufl)
MXAPI_EQUALS_MEMBER(positionData)
MXAPI_EQUALS_MEMBER(fontData)
MXAPI_EQUALS_MEMBER(color)
MXAPI_EQUALS_MEMBER(id)
MXAPI_EQUALS_END;
MXAPI_NOT_EQUALS_AND_VECTORS(OtherDirectionData);
} // namespace api
} // namespace mx
72 changes: 72 additions & 0 deletions src/include/mx/api/PrincipalVoiceData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// MusicXML Class Library
// Copyright (c) by Matthew James Briggs
// Distributed under the MIT License

#pragma once

#include "mx/api/ApiCommon.h"
#include "mx/api/ColorData.h"
#include "mx/api/FontData.h"
#include "mx/api/PositionData.h"

#include <optional>
#include <string>

namespace mx
{
namespace api
{
// Whether a PrincipalVoiceData marks where the designation begins or where it ends.
enum class PrincipalVoiceType
{
start,
stop
};

// How a principal-voice marking is displayed: the Hauptstimme or Nebenstimme bracket symbols
// used in Schoenberg's and Berg's scores, a plain bracket, or no visible symbol at all.
enum class PrincipalVoiceSymbol
{
hauptstimme,
nebenstimme,
plain,
none
};

// A principal-voice designation, MusicXML's <principal-voice> element: marks a passage as the
// principal (Hauptstimme) or secondary (Nebenstimme) voice of the texture, a practice from the
// Second Viennese School. The marking spans from a start to the matching stop; the symbol
// chooses what is drawn at the start (the stop is drawn as the end of the bracket).
class PrincipalVoiceData
{
public:
PrincipalVoiceType type;
PrincipalVoiceSymbol symbol;

// Optional text content carried by the element, used for analysis rather than display.
std::string text;

PositionData positionData;
FontData fontData;
std::optional<ColorData> color;
std::optional<std::string> id;

PrincipalVoiceData()
: type{PrincipalVoiceType::start}, symbol{PrincipalVoiceSymbol::hauptstimme}, text{}, positionData{},
fontData{}, color{}, id{}
{
}
};

MXAPI_EQUALS_BEGIN(PrincipalVoiceData)
MXAPI_EQUALS_MEMBER(type)
MXAPI_EQUALS_MEMBER(symbol)
MXAPI_EQUALS_MEMBER(text)
MXAPI_EQUALS_MEMBER(positionData)
MXAPI_EQUALS_MEMBER(fontData)
MXAPI_EQUALS_MEMBER(color)
MXAPI_EQUALS_MEMBER(id)
MXAPI_EQUALS_END;
MXAPI_NOT_EQUALS_AND_VECTORS(PrincipalVoiceData);
} // namespace api
} // namespace mx
Loading
Loading