Skip to content

Commit

Permalink
v0.1.13
Browse files Browse the repository at this point in the history
- Meico update to v0.8.35 with added support for MEI element `arpeg` for arpeggios and new MPM features for ornamentation. These, however, are not yet editable in MPM Toolbox. Full integration of MPM ornamentation features is pending. The update further contains a little enhancement in meico's MEI to MSM and MPM export, namely that IDs of MEI `staffDef` elements will recur in MSM and MPM `part` elements.
- Enhancement in the constructor of class `mpmToolbox.projectData.score.Score` that parses a project file's XML to generate its data structure. Now it is able to handle occurrences of a note or performance instruction on multiple score pages.
  • Loading branch information
axelberndt committed Apr 7, 2022
1 parent 20c640a commit 4bc979f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
Binary file modified externals/meico.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
### Version History


#### v0.1.13
- Meico update to v0.8.35 with added support for MEI element `arpeg` for arpeggios and new MPM features for ornamentation. These, however, are not yet editable in MPM Toolbox. Full integration of MPM ornamentation features is pending. The update further contains a little enhancement in meico's MEI to MSM and MPM export, namely that IDs of MEI `staffDef` elements will recur in MSM and MPM `part` elements.
- Enhancement in the constructor of class `mpmToolbox.projectData.score.Score` that parses a project file's XML to generate its data structure. Now it is able to handle occurrences of a note or performance instruction on multiple score pages.


#### v0.1.12
- In the MPM tree, the context menus of `articulationStyles`, `dynamicsStyles` and `tempoStyles` have an additional option to create default styles. These serve as convenient starter styles to be further refined.

Expand Down
48 changes: 22 additions & 26 deletions src/mpmToolbox/projectData/score/Score.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ public Score(@NotNull ProjectData project) {
if (overlayElementSizeAtt != null)
this.overlayElementSize = Integer.parseInt(overlayElementSizeAtt.getValue());

// make a hashmap for note ids and elements
HashMap<String, Element> notes = new HashMap<>();
for (Element part : this.parentProject.getMsm().getParts()) {
Element score = part.getFirstChildElement("dated").getFirstChildElement("score"); // get the part's score
if (score == null) // if it has none
continue; // we are done with this part

for (Element note : score.getChildElements("note")) // for each note in the MSM part
notes.put(Helper.getAttributeValue("id", note), note); // add it to the hashmap
}

// make a similar hashmap for performance instructions
HashMap<String, Element> perfs = new HashMap<>();
Nodes nodes = this.parentProject.getMpm().getRootElement().query("descendant::*[@date and @xml:id]"); // get all children with attributes date and xml:id, i.e. all performance instructions with an id
for (Node node : nodes) {
Element n = (Element) node;
String id = Helper.getAttributeValue("id", n);
perfs.put(id, n);
}

// parse the score data
HashMap<String, KeyValue<ScorePage, KeyValue<Double, Double>>> noteAnnotations = new HashMap<>();
HashMap<String, KeyValue<ScorePage, KeyValue<Double, Double>>> performanceAnnotations = new HashMap<>();
Expand All @@ -69,48 +89,24 @@ public Score(@NotNull ProjectData project) {
continue;
}
this.pages.add(page);
}

// find the MSM note elements that correspond to the above ID strings
if (!noteAnnotations.isEmpty()) {
HashMap<String, Element> notes = new HashMap<>();
for (Element part : this.parentProject.getMsm().getParts()) {
Element score = part.getFirstChildElement("dated").getFirstChildElement("score"); // get the part's score
if (score == null) // if it has none
continue; // we are done with this part

for (Element note : score.getChildElements("note")) // for each note in the MSM part
notes.put(Helper.getAttributeValue("id", note), note); // add it to the hashmap
}

// for each note annotation make an entry in the corresponding ScorePage data structure
for (Map.Entry<String, KeyValue<ScorePage, KeyValue<Double, Double>>> noteAnnotation : noteAnnotations.entrySet()) { // for each note annotation
Element note = notes.get(noteAnnotation.getKey()); // get the corresponding note element
if (note == null) // if there is none
continue; // go on with the next association
ScorePage page = noteAnnotation.getValue().getKey(); // get the page where the note association should be added
page.addEntry(noteAnnotation.getValue().getValue().getKey(), noteAnnotation.getValue().getValue().getValue(), note); // add the note association to the page
}
}

// find the MPM elements that correspond to the above ID strings
if (!performanceAnnotations.isEmpty()) {
HashMap<String, Element> perfs = new HashMap<>();
Nodes nodes = this.parentProject.getMpm().getRootElement().query("descendant::*[@date and @xml:id]"); // get all children with attributes date and xml:id, i.e. all performance instructions with an id
for (Node node : nodes) {
Element n = (Element) node;
String id = Helper.getAttributeValue("id", n);
perfs.put(id, n);
}
noteAnnotations.clear();

// for each performance annotation make an entry in the corresponding ScorePage data structure
for (Map.Entry<String, KeyValue<ScorePage, KeyValue<Double, Double>>> perfAssociation : performanceAnnotations.entrySet()) {
Element perf = perfs.get(perfAssociation.getKey());
if (perf == null)
continue;
ScorePage page = perfAssociation.getValue().getKey();
page.addEntry(perfAssociation.getValue().getValue().getKey(), perfAssociation.getValue().getValue().getValue(), perf);
}
performanceAnnotations.clear();
}
}

Expand Down

0 comments on commit 4bc979f

Please sign in to comment.