Skip to content

Commit

Permalink
Merge pull request #118 from DDMAL/blank-mei
Browse files Browse the repository at this point in the history
Read and edit blank MEI files
  • Loading branch information
yinanazhou authored Dec 13, 2023
2 parents 600b100 + fe3a052 commit 0e4af70
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/editortoolkit_neume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,28 +816,27 @@ bool EditorToolkitNeume::Insert(std::string elementType, std::string staffId, in
Layer *newLayer = new Layer();
newStaff->AddChild(newLayer);

// Find index to insert new staff
ListOfObjects staves = parent->FindAllDescendantsByType(STAFF, false);
std::vector<Object *> stavesVector(staves.begin(), staves.end());
stavesVector.push_back(newStaff);
StaffSort staffSort;
std::stable_sort(stavesVector.begin(), stavesVector.end(), staffSort);
for (int i = 0; i < (int)staves.size(); ++i) {
if (stavesVector.at(i) == newStaff) {
parent->InsertChild(newStaff, i);
parent->Modify();

m_editInfo.import("uuid", newStaff->GetID());
m_editInfo.import("status", status);
m_editInfo.import("message", message);

return true;
if (staff) {
// Find index to insert new staff
ListOfObjects staves = parent->FindAllDescendantsByType(STAFF, false);
std::vector<Object *> stavesVector(staves.begin(), staves.end());
stavesVector.push_back(newStaff);
StaffSort staffSort;
std::stable_sort(stavesVector.begin(), stavesVector.end(), staffSort);
for (int i = 0; i < (int)staves.size(); ++i) {
if (stavesVector.at(i) == newStaff) {
parent->InsertChild(newStaff, i);
parent->Modify();

m_editInfo.import("uuid", newStaff->GetID());
m_editInfo.import("status", status);
m_editInfo.import("message", message);

return true;
}
}
}
LogWarning("Failed to insert newStaff into staff");
message += "Failed to insert newStaff into staves.";
parent->AddChild(newStaff);
parent->Modify();

m_editInfo.import("uuid", newStaff->GetID());
m_editInfo.import("status", status);
Expand Down
7 changes: 7 additions & 0 deletions src/iomei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4467,6 +4467,13 @@ bool MEIInput::ReadSectionChildren(Object *parent, pugi::xml_node parentNode)
LogWarning("Unsupported '<%s>' within <section>", current.name());
}
}

// New <measure> for blank files in neume notation
if (!unmeasured && parent->Is(SECTION) && (m_doc->m_notationType == NOTATIONTYPE_neume)) {
unmeasured = new Measure(false);
m_doc->SetMensuralMusicOnly(true);
parent->AddChild(unmeasured);
}
return success;
}

Expand Down

0 comments on commit 0e4af70

Please sign in to comment.