diff --git a/history.md b/history.md
index 4cd1f22e..7b1d816f 100644
--- a/history.md
+++ b/history.md
@@ -1,6 +1,11 @@
### Version History
+#### v0.7.4
+- Enhancement in method `meico.mei.Mei.processMeasure()`. If a measure does not comply with the underlying time signature meico needs to add another `timeSignature` element in the `timeSignatureMap`. However, the subsequent measure may comply with the original time signature. Hence, at the end of the non-compliant measure meico should switch back to the original time signature. This is what it does now.
+- Minor stability fix in method `meico.mei.Mei.addDynamicsToMpm()`.
+
+
#### v0.7.3
- MPM attributes `startStyle` and `defaultArticulation` have been removed from all `...-Map` elements. Initial styles are indicated by style switches (e.g. `` and for articulation maps ``) at the beginning of of the map. The corresponding code changes are in classes `meico.mei.Mei`, `meico.mpm.maps.ArticulationMap`, `DynamicsMap`, `GenericMap`, `MetricalAccentuationMap`, `RubatoMap`, `TempoMap`.
- In class `meico.mpm.Mpm` element `referenceMusic` is renamed to `relatedResources` and element `reference` has been renamed to `resource`.
diff --git a/src/meico/mei/Mei.java b/src/meico/mei/Mei.java
index 39980346..b8df03ba 100644
--- a/src/meico/mei/Mei.java
+++ b/src/meico/mei/Mei.java
@@ -1475,7 +1475,7 @@ else if (this.helper.currentMsmMovement.getFirstChildElement("global").getFirstC
durNotTimeSig = true;
}
- // the measure length does not confirm the time signature, hence we need a new time signature entry at the measure's startDate
+ // the measure length does not confirm the time signature, hence we need a new time signature entry at the measure's startDate and another one ate the end so the next measure has the official time signature again
if (durNotTimeSig) {
double[] numDenom = this.helper.getCurrentTimeSignature(); // get the current time signature numerator and denominator
double num = (dur2 * numDenom[1]) / (this.helper.ppq * 4.0); // from the actual duration of the measure and the denominator of the time signature compute the new numerator
@@ -1490,10 +1490,12 @@ else if (this.helper.currentMsmMovement.getFirstChildElement("global").getFirstC
}
tsMap.appendChild(ts); // add the new timeSignature element to the global timeSignatureMap
+ Element tsBack = Msm.makeTimeSignature(endDate, numDenom[0], (int)numDenom[1], null); // generate a timeSignature element to switch back to the official time signature at the end of the measure
+ tsMap.appendChild(tsBack); // add it to the map
}
// go through all msm parts and set the currentDate attribute to endDate
- Elements parts = this.helper.currentMsmMovement.getChildElements("part"); // get all parts
+ Elements parts = this.helper.currentMsmMovement.getChildElements("part"); // get all parts
for (int i=0; i < parts.size(); ++i) // go through all the parts
parts.get(i).getAttribute("currentDate").setValue(Double.toString(endDate)); // set their currentDate attribute
@@ -2137,7 +2139,6 @@ else if (form.getValue().equals("dim"))
if ((dd.xmlId != null) && multiIDs)
ddd.xmlId = dd.xmlId + "_meico_" + UUID.randomUUID().toString();
-
this.addDynamicsToMpm(ddd, dynamicsMap, endid, tstamp2);
multiIDs = true;
@@ -2176,11 +2177,15 @@ private int addDynamicsToMpm(DynamicsData dynamicsData, DynamicsMap dynamicsMap,
}
break; // done, no need to search for further previous dynamics instructions
}
+ if (dynamicsData.volumeString == null) // no volume found
+ dynamicsData.volumeString = "?"; // set placeholder volume
int index = dynamicsMap.addDynamics(dynamicsData); // add it to the map
+ if (index < 0)
+ return index;
Element dynamics = dynamicsMap.getElement(index); // get the element just created
if (dynamicsData.endDate != null) {
- dynamics.addAttribute(new Attribute("date.end", dynamicsData.endDate.toString())); // add the date.end attribute to the element (will be resolved during mpmPostprocessing())
+ dynamics.addAttribute(new Attribute("date.end", dynamicsData.endDate.toString())); // add the date.end attribute to the element (will be resolved during mpmPostprocessing())
} else if (tstamp2 != null) { // if this element must be terminated in another measure via a tstamp2.ges or tstamp2 attribute
dynamics.addAttribute(new Attribute("tstamp2", tstamp2.getValue())); // add the tstamp2 attribute to the element (must be deleted later!)
this.helper.tstamp2s.add(dynamics); // add the element to the helper's tstamp2s list
diff --git a/src/meico/mpm/elements/maps/GenericMap.java b/src/meico/mpm/elements/maps/GenericMap.java
index 01c99d17..4870162d 100644
--- a/src/meico/mpm/elements/maps/GenericMap.java
+++ b/src/meico/mpm/elements/maps/GenericMap.java
@@ -249,7 +249,7 @@ public ArrayList> getAllElementsAt(double date) {
* @return
*/
public Element getElement(int index) {
- if (index >= this.elements.size())
+ if ((index >= this.elements.size()) || (index < 0))
return null;
return this.elements.get(index).getValue();