From 6922c009181cca82e2c4e73b6a670b19a6ca2bb4 Mon Sep 17 00:00:00 2001 From: axelberndt Date: Tue, 2 Jun 2020 12:32:03 +0200 Subject: [PATCH] v0.8.6 - Another bugfix in method `meico.mpm.elements.styles.defs.ArticulationDef.articulateNote()` so style switches with no attribute `defaultArticulation` (it is optional) are supported. --- history.md | 4 ++++ src/meico/Meico.java | 2 +- .../mpm/elements/maps/ArticulationMap.java | 21 ++++++++++++------- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/history.md b/history.md index 5b47008c..11275206 100644 --- a/history.md +++ b/history.md @@ -1,6 +1,10 @@ ### Version History +#### v0.8.6 +- Another bugfix in method `meico.mpm.elements.styles.defs.ArticulationDef.articulateNote()` so style switches with no attribute `defaultArticulation` (it is optional) are supported. + + #### v0.8.5 - New methods in class `meico.mei.Helper`: `pulseDuration2decimal()`, `decimalDuration2HtmlUnicode()`, `durationRemainder2UnicodeDots()`, `accidDecimal2unicodeString()`. These can beused to generate Unicode strings from note value and pitch information. - Bugfix in method `meico.mei.Mei.makeMovement()`. It checks for the file to be not null before accessing it. diff --git a/src/meico/Meico.java b/src/meico/Meico.java index f3bb8f1c..8b171cc5 100644 --- a/src/meico/Meico.java +++ b/src/meico/Meico.java @@ -5,7 +5,7 @@ * @author Axel Berndt */ public class Meico { - public static final String version = "0.8.5"; + public static final String version = "0.8.6"; public static void main(String[] args) { System.out.println("meico v" + Meico.version); diff --git a/src/meico/mpm/elements/maps/ArticulationMap.java b/src/meico/mpm/elements/maps/ArticulationMap.java index ccaddd9f..092375d1 100644 --- a/src/meico/mpm/elements/maps/ArticulationMap.java +++ b/src/meico/mpm/elements/maps/ArticulationMap.java @@ -404,12 +404,19 @@ public void renderArticulationToMap_noMillisecondModifiers(GenericMap map) { ArrayList> styleSwitchList = this.getAllElementsOfType("style"); // collect all style switches and put them into the list for (KeyValue styleEntry : styleSwitchList) { ArticulationStyle aStyle = (ArticulationStyle) this.getStyle(Mpm.ARTICULATION_STYLE, Helper.getAttributeValue("name.ref", styleEntry.getValue())); - if (aStyle != null) { - ArticulationDef aDef = aStyle.getArticulationDef(Helper.getAttributeValue("defaultArticulation", styleEntry.getValue())); - if (aDef == null) - System.err.println("Warning: attribute " + Helper.getAttribute("defaultArticulation", this.getXml()).toXML() + " in style element refers to an unknown articulationDef."); - defaultArticulations.add(new KeyValue<>(styleEntry.getKey(), aDef)); + if (aStyle == null) + continue; + + Attribute defaultArticulationAtt = Helper.getAttribute("defaultArticulation", styleEntry.getValue()); + if (defaultArticulationAtt == null) { // if no default articulation is specified (it is optional) + defaultArticulations.add(new KeyValue<>(styleEntry.getKey(), null)); // set the list entry for this date to null so it will not attempt to use the previous entry during rendering from the style's date on + continue; } + + ArticulationDef aDef = aStyle.getArticulationDef(defaultArticulationAtt.getValue()); + if (aDef == null) + System.err.println("Warning: attribute " + Helper.getAttribute("defaultArticulation", this.getXml()).toXML() + " in style element refers to an unknown articulationDef."); + defaultArticulations.add(new KeyValue<>(styleEntry.getKey(), aDef)); } // articulate the map elements @@ -420,7 +427,7 @@ public void renderArticulationToMap_noMillisecondModifiers(GenericMap map) { continue; // go on with the next element ArrayList artics = noteArtics.get(mapEntry.getValue()); - if (artics != null) { // apply the articulations to the associated note + if (artics != null) { // apply the articulations (if there is one or more) to the associated note for (ArticulationData artic : artics) { // each articulation that is associated with this note element mapTimingChanged |= artic.articulateNote(mapEntry.getValue()); // apply articulation } @@ -428,7 +435,7 @@ public void renderArticulationToMap_noMillisecondModifiers(GenericMap map) { } // otherwise apply the default articulation - if (defaultArticulations.isEmpty()) // if we have such data + if (defaultArticulations.isEmpty()) // if we have no such data continue; // make sure we use the latest default articulation