Skip to content

Commit

Permalink
v0.8.12
Browse files Browse the repository at this point in the history
- Enhancement of the processing of MEI `tie` element.
- Bugfix in method `meico.mei.Mei.processBreath()` that generated a wrong default articulation.
- Bugfix in method `meico.mpm.elements.maps.ArticulationMap.renderArticulationToMap_noMillisecondModifiers()`: NullPointerException in an error message.
- Optimization of methods `meico.mei.Helper.getPreviousSiblingElement()` and `getNextSiblingElement()`.
- An extensive overhaul of method `meico.mei.Mei.processMeasure()` which is now able to handle the situation that no global time signature is given (via `scoreDef`) and only locally defined in the `staffDef` elements.
- Some code polishing.
  • Loading branch information
axelberndt committed Jul 14, 2020
1 parent c5aa61b commit d5cf097
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 153 deletions.
9 changes: 9 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
### Version History


#### v0.8.12
- Enhancement of the processing of MEI `tie` element.
- Bugfix in method `meico.mei.Mei.processBreath()` that generated a wrong default articulation.
- Bugfix in method `meico.mpm.elements.maps.ArticulationMap.renderArticulationToMap_noMillisecondModifiers()`: NullPointerException in an error message.
- Optimization of methods `meico.mei.Helper.getPreviousSiblingElement()` and `getNextSiblingElement()`.
- An extensive overhaul of method `meico.mei.Mei.processMeasure()` which is now able to handle the situation that no global time signature is given (via `scoreDef`) and only locally defined in the `staffDef` elements.
- Some code polishing.


#### v0.8.11
- Another bugfix: The `endid` of MEI `tie` elements was not properly resolved.

Expand Down
2 changes: 1 addition & 1 deletion src/meico/Meico.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author Axel Berndt
*/
public class Meico {
public static final String version = "0.8.11";
public static final String version = "0.8.12";

public static void main(String[] args) {
System.out.println("meico v" + Meico.version);
Expand Down
78 changes: 19 additions & 59 deletions src/meico/mei/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class Helper {
protected ArrayList<Element> accid = new ArrayList<>(); // holds accidentals that appear within measures to be considered during pitch computation
protected ArrayList<Element> endids = new ArrayList<>(); // msm and mpm elements that will be terminated at the time position of an mei element with a specified endid
protected ArrayList<Element> tstamp2s = new ArrayList<>(); // mpm elements that will be terminated at a position in another measure indicated by attribute tstamp2
protected ArrayList<Element> ties = new ArrayList<>(); // a list of pending MEI tie elements
protected ArrayList<Element> lyrics = new ArrayList<>(); // this is used to collect lyrics converted from mei syl elements to be added to an msm note
protected HashMap<String, Element> allNotesAndChords = new HashMap<>(); // when converting a new mdiv this hashmap is created first to accelarate lookup for notes and chords via xml:id
protected Performance currentPerformance = null; // a quick link to the current movement's current performance
Expand Down Expand Up @@ -80,7 +79,6 @@ protected void reset() {
this.accid.clear();
this.endids.clear();
this.tstamp2s.clear();
this.ties.clear();
this.lyrics.clear();
this.allNotesAndChords.clear();
}
Expand Down Expand Up @@ -188,20 +186,17 @@ public static LinkedList<Element> getAllChildElements(String name, Element ofThi
* @return
*/
public static Element getNextSiblingElement(Element ofThis) {
if (ofThis == null) return null;
if (ofThis == null)
return null;

if (ofThis == ofThis.getDocument().getRootElement()) // if we are at the root of the document
return null; // there can be no siblings, hence return null

Elements es = ((Element)ofThis.getParent()).getChildElements(); // get a list of all siblings

for (int i = es.size()-2; i >= 0; i--) { // go through all siblings starting at the element before the last (the last one cannot have a successor)
if (ofThis == es.get(i)) { // if ofThis was found
return es.get(i+1); // the successor is the next sibling
}
}
int index = ofThis.getParent().indexOf(ofThis);
if (index >= (ofThis.getParent().getChildCount() - 1))
return null;

return null; // ofThis is the final element and has no next sibling
return (Element) ofThis.getParent().getChild(index + 1);
}

/**
Expand All @@ -211,7 +206,8 @@ public static Element getNextSiblingElement(Element ofThis) {
* @return
*/
public static Element getNextSiblingElement(String name, Element ofThis) {
if (ofThis == null) return null;
if (ofThis == null)
return null;

if (ofThis == ofThis.getDocument().getRootElement()) // if we are at the root of the document
return null; // there can be no siblings, hence return null
Expand All @@ -237,20 +233,17 @@ public static Element getNextSiblingElement(String name, Element ofThis) {
* @return
*/
public static Element getPreviousSiblingElement(Element ofThis) {
if (ofThis == null) return null;
if (ofThis == null)
return null;

if (ofThis == ofThis.getDocument().getRootElement()) // if we are at the root of the document
return null; // there can be no siblings, hence return null

Elements es = ((Element)ofThis.getParent()).getChildElements(); // get a list of all siblings

for (int i=1; i < es.size(); ++i) { // go through all siblings starting at the second (the first cannot have a predecessor)
if (ofThis == es.get(i)) { // if ofThis was found
return es.get(i-1); // the predecessor is the previous sibling
}
}
int index = ofThis.getParent().indexOf(ofThis);
if (index == 0)
return null;

return null; // ofThis is the final element and has no next sibling
return (Element) ofThis.getParent().getChild(index - 1);
}

/**
Expand All @@ -260,7 +253,8 @@ public static Element getPreviousSiblingElement(Element ofThis) {
* @return
*/
public static Element getPreviousSiblingElement(String name, Element ofThis) {
if (ofThis == null) return null;
if (ofThis == null)
return null;

if (ofThis == ofThis.getDocument().getRootElement()) // if we are at the root of the document
return null; // there can be no siblings, hence return null
Expand Down Expand Up @@ -895,40 +889,6 @@ protected void checkEndid(Element e) {
}
}

/**
* return the first element in the ties list with an endid attribute value that equals id
* @param id
* @return the index in the ties list or -1 if not found
*/
private int getTie(String id) {
for (int i=0; i < this.ties.size(); ++i) { // go through the list of pending elements to be ended
if (this.ties.get(i).getAttributeValue("endid").equals(id)) // found
return i; // return it
}
return -1;
}

/**
* check for pending ties that might end at this note or chord
* @param e an MEI note or chord element
*/
protected void checkTies(Element e) {
String id = "#" + Helper.getAttributeValue("id", e); // get id of the current element
for (int j = this.getTie(id); j >= 0; j = this.getTie(id)) { // find all pending elements in the ties list to be finished at this element
Attribute a = e.getAttribute("tie"); // get its tie attribute if it has one
if (a != null) { // if the note has already a tie attribute
if (a.getValue().equals("i")) // but it says that the tie is initial
a.setValue("m"); // make an intermediate tie out of it
else if (a.getValue().equals("n")) // but it says "no tie"
a.setValue("t"); // make a terminal tie out of it
}
else { // otherwise the element had no tie attribute
e.addAttribute(new Attribute("tie", "t")); // hence, we add a terminal tie attribute
}
this.ties.remove(j); // remove element from list, it is finished
}
}

/**
* this method is for note elements to check whether one of the pending slurs applies for it
* @param e
Expand Down Expand Up @@ -1279,11 +1239,11 @@ protected Double computeDuration(Element ofThis) {
}

// tupletSpans
LinkedList<Element> tps = new LinkedList<>();
LinkedList<Element> tps;
if (this.currentPart != null) { // we have to be in a staff environment for this
tps = Helper.getAllChildElements("tupletSpan", this.currentPart.getFirstChildElement("dated").getFirstChildElement("miscMap").getFirstChildElement("tupletSpanMap")); // get al local tupletSpans
tps = Helper.getAllChildElements("tupletSpan", this.currentPart.getFirstChildElement("dated").getFirstChildElement("miscMap").getFirstChildElement("tupletSpanMap")); // get all local tupletSpans
} else {
tps = Helper.getAllChildElements("tupletSpan", this.currentMsmMovement.getFirstChildElement("global").getFirstChildElement("dated").getFirstChildElement("miscMap").getFirstChildElement("tupletSpanMap")); // get all globalo tipletSpans
tps = Helper.getAllChildElements("tupletSpan", this.currentMsmMovement.getFirstChildElement("global").getFirstChildElement("dated").getFirstChildElement("miscMap").getFirstChildElement("tupletSpanMap")); // get all globalo tupletSpans
}

for (int i = tps.size() - 1; i >= 0; --i) { // go through all these tupletSpans, starting with the last
Expand Down
Loading

0 comments on commit d5cf097

Please sign in to comment.