Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read and edit blank MEI files #118

Merged
merged 2 commits into from
Dec 13, 2023
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
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