@@ -169,8 +169,9 @@ auto parse_note(boost::json::value const& value) -> std::expected<vamp_zero::sco
|
||||
auto lyric = optional_string_value(**object, "lyric", {});
|
||||
auto tie_to_next = optional_bool_value(**object, "tie_to_next", false);
|
||||
auto tie_from_previous = optional_bool_value(**object, "tie_from_previous", false);
|
||||
if (!id || !kind || !hidden || !duration || !display || !notehead || !chord || !lyric || !tie_to_next || !tie_from_previous) {
|
||||
return std::unexpected(!id ? id.error() : (!kind ? kind.error() : (!hidden ? hidden.error() : (!duration ? duration.error() : (!display ? display.error() : (!notehead ? notehead.error() : (!chord ? chord.error() : (!lyric ? lyric.error() : (!tie_to_next ? tie_to_next.error() : tie_from_previous.error())))))))));
|
||||
auto tuplet_id = optional_string_value(**object, "tuplet_id", {});
|
||||
if (!id || !kind || !hidden || !duration || !display || !notehead || !chord || !lyric || !tie_to_next || !tie_from_previous || !tuplet_id) {
|
||||
return std::unexpected(!id ? id.error() : (!kind ? kind.error() : (!hidden ? hidden.error() : (!duration ? duration.error() : (!display ? display.error() : (!notehead ? notehead.error() : (!chord ? chord.error() : (!lyric ? lyric.error() : (!tie_to_next ? tie_to_next.error() : (!tie_from_previous ? tie_from_previous.error() : tuplet_id.error()))))))))));
|
||||
}
|
||||
auto note = vamp_zero::score_note{
|
||||
.id = std::move(*id),
|
||||
@@ -183,6 +184,7 @@ auto parse_note(boost::json::value const& value) -> std::expected<vamp_zero::sco
|
||||
.lyric = std::move(*lyric),
|
||||
.tie_to_next = *tie_to_next,
|
||||
.tie_from_previous = *tie_from_previous,
|
||||
.tuplet_id = std::move(*tuplet_id),
|
||||
};
|
||||
if (auto found = (*object)->find("pitches"); found != (*object)->end()) {
|
||||
if (!found->value().is_array()) {
|
||||
@@ -199,6 +201,24 @@ auto parse_note(boost::json::value const& value) -> std::expected<vamp_zero::sco
|
||||
return note;
|
||||
}
|
||||
|
||||
auto parse_tuplet(boost::json::value const& value) -> std::expected<vamp_zero::score_tuplet, modulus::error> {
|
||||
auto object = require_object(value, "tuplet");
|
||||
if (!object) {
|
||||
return std::unexpected(object.error());
|
||||
}
|
||||
auto id = required_string(**object, "id");
|
||||
auto note_count = optional_int64_value(**object, "note_count", 0);
|
||||
auto space_count = optional_int64_value(**object, "space_count", 0);
|
||||
if (!id || !note_count || !space_count) {
|
||||
return std::unexpected(!id ? id.error() : (!note_count ? note_count.error() : space_count.error()));
|
||||
}
|
||||
return vamp_zero::score_tuplet{
|
||||
.id = std::move(*id),
|
||||
.note_count = static_cast<std::int32_t>(*note_count),
|
||||
.space_count = static_cast<std::int32_t>(*space_count),
|
||||
};
|
||||
}
|
||||
|
||||
auto parse_measure(boost::json::value const& value) -> std::expected<vamp_zero::score_measure, modulus::error> {
|
||||
auto object = require_object(value, "measure");
|
||||
if (!object) {
|
||||
@@ -237,6 +257,18 @@ auto parse_measure(boost::json::value const& value) -> std::expected<vamp_zero::
|
||||
}
|
||||
measure.notes.push_back(std::move(*note));
|
||||
}
|
||||
if (auto tuplets_value = (*voice)->find("tuplets"); tuplets_value != (*voice)->end()) {
|
||||
if (!tuplets_value->value().is_array()) {
|
||||
return std::unexpected(invalid("tuplets must be an array"));
|
||||
}
|
||||
for (auto const& tuplet_value : tuplets_value->value().as_array()) {
|
||||
auto tuplet = parse_tuplet(tuplet_value);
|
||||
if (!tuplet) {
|
||||
return std::unexpected(tuplet.error());
|
||||
}
|
||||
measure.tuplets.push_back(std::move(*tuplet));
|
||||
}
|
||||
}
|
||||
}
|
||||
return measure;
|
||||
}
|
||||
|
||||
+1166
-235
File diff suppressed because it is too large
Load Diff
@@ -416,7 +416,7 @@ public:
|
||||
.x = area.x,
|
||||
.y = area.y + 80.0F,
|
||||
.width = area.width,
|
||||
.height = std::max(0.0F, area.height - 80.0F),
|
||||
.height = std::max<std::float32_t>(0.0F, area.height - 80.0F),
|
||||
};
|
||||
if (state_.app.mode == vamp_zero::app_mode::MAIN_MENU) {
|
||||
draw_main_menu(context, content, state_.app);
|
||||
|
||||
Reference in New Issue
Block a user