Skip to content

Commit

Permalink
v0.10.0
Browse files Browse the repository at this point in the history
- Conversion of MEI to MusicXML implemented. Thanks to [Matthias Nowakowski](https://github.com/mnowakow).
  - `meiHead` nearly completely.
  - `music` most of the note-related data.
  - See `MEI2MusixXml_Coverage_Documentation.md` for more detail.
  • Loading branch information
axelberndt committed Aug 19, 2024
1 parent 3da3d41 commit 773d9cf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Author: [Axel Berndt](https://github.com/axelberndt) ([Paderborn University](https://www.muwi-detmold-paderborn.de/personen/professorinnen-und-professoren/prof-dr-ing-axel-berndt), Detmold)<br>
MEI support: [Benjamin W. Bohl](https://github.com/bwbohl), [Johannes Kepper](https://github.com/kepper)<br>
Contributor: [Simon Waloschek](https://github.com/sonovice)<br>
Contributor: [Matthias Nowakowski](https://github.com/mnowakow), [Simon Waloschek](https://github.com/sonovice)<br>

#### Java Compatibility
- meico ![Java compatibility 1.8+](https://img.shields.io/badge/java-1.8%2B-blue.svg)
Expand Down
7 changes: 7 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
### Version History


#### v0.10.0
- Conversion of MEI to MusicXML implemented. Thanks to [Matthias Nowakowski](https://github.com/mnowakow).
- `meiHead` nearly completely.
- `music` most of the note-related data.
- See `MEI2MusixXml_Coverage_Documentation.md` for more detail.


#### v0.9.4
- Conversion of MEI to MusicXML has been added to the commandline interface of meicoApp.

Expand Down
32 changes: 10 additions & 22 deletions src/meico/mei/Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,12 @@
import java.util.regex.Pattern;

import com.thaiopensource.relaxng.jaxp.XMLSyntaxSchemaFactory;
import meico.mpm.Mpm;
import meico.mpm.elements.Part;
import meico.mpm.elements.Performance;
import meico.mpm.elements.maps.GenericMap;
import meico.mpm.elements.maps.data.TempoData;
import meico.mpm.elements.styles.TempoStyle;
import meico.mpm.elements.styles.defs.TempoDef;
import meico.msm.Msm;
import meico.supplementary.KeyValue;
import net.sf.saxon.s9api.*;
import net.sf.saxon.s9api.Serializer;
import nu.xom.*;
import org.audiveris.proxymusic.Attributes;
import org.w3c.dom.Attr;
import org.xml.sax.SAXException;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;

Expand Down Expand Up @@ -125,14 +112,14 @@ public static LinkedList<Element> getAllChildElements(String name, Element ofThi
* @param ofThis
* @return
*/
public static LinkedList<Element> getAllDescendants(String name, Element ofThis) {
public static LinkedList<Element> getAllDescendantsByName(String name, Element ofThis) {
if ((ofThis == null) || name.isEmpty()) return null;
LinkedList<Element> children = new LinkedList<>();
for(Element ch : Helper.getAllChildElements(ofThis)){
children.addAll(Helper.getAllDescendants(name, ch));
for(Element ch : Helper.getAllChildElements(ofThis)) {
if(ch.getLocalName().equals(name))
children.add(ch);
children.addAll(Helper.getAllDescendantsByName(name, ch));
}
List<Element> c = getAllChildElements(name, ofThis);
if(c != null) children.addAll(c);
return children;
}

Expand All @@ -142,12 +129,13 @@ public static LinkedList<Element> getAllDescendants(String name, Element ofThis)
* @param ofThis
* @return
*/
public static LinkedList<Element> getAllDescendantsByAttribute(String attrName, Element ofThis) {
public static LinkedList<Element> getAllDescendantsWithAttribute(String attrName, Element ofThis) {
if ((ofThis == null) || attrName.isEmpty()) return null;
LinkedList<Element> children = new LinkedList<>();
for(Element ch : Helper.getAllChildElements(ofThis)){
children.addAll(Helper.getAllDescendantsByAttribute(attrName, ch));
if(ch.getAttribute(attrName) != null) children.add(ch);
for(Element ch : Helper.getAllChildElements(ofThis)) {
if(ch.getAttribute(attrName) != null)
children.add(ch);
children.addAll(Helper.getAllDescendantsWithAttribute(attrName, ch));
}
return children;
}
Expand Down
6 changes: 3 additions & 3 deletions src/meico/mei/Mei2MusicXmlConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2220,7 +2220,7 @@ private boolean isPrevAttributeDifferent(Element e){
Element prevSection = Helper.getPreviousSiblingElement("section", section); // find previous section
if(prevSection != null){
List<Element> measureChildren = Helper.getAllChildElements("measure", prevSection);
measureChildren = measureChildren == null || measureChildren.isEmpty() ? Helper.getAllDescendants("measure", prevSection) : measureChildren; // measures can be hidden in endings
measureChildren = measureChildren == null || measureChildren.isEmpty() ? Helper.getAllDescendantsByName("measure", prevSection) : measureChildren; // measures can be hidden in endings
if(measureChildren != null && !measureChildren.isEmpty()) prevMeasure = measureChildren.get(measureChildren.size() - 1); // get last measure in measure list
}
}
Expand Down Expand Up @@ -3193,7 +3193,7 @@ private void processTuplet(Note note, Element e){
if(num == null || num.isEmpty()) return; // tuplet parent may be present but cannot process ratios
int numInt = Integer.parseInt(num);
numbase = (numbase == null || numbase.isEmpty()) && (numInt & (numInt - 1)) == 0 ? "" + numInt : "" + (Integer.highestOneBit(numInt) );
List<Element> descendants = Helper.getAllDescendantsByAttribute("dur", parentTuplet);
List<Element> descendants = Helper.getAllDescendantsWithAttribute("dur", parentTuplet);
isFirst = descendants.indexOf(e) == 0;
Collections.reverse(descendants); // reverse list to find last element
isLast = descendants.indexOf(e) == 0;
Expand All @@ -3203,7 +3203,7 @@ private void processTuplet(Note note, Element e){
for(String tVal : tupletVals) {
Element parentLayer = Helper.getClosest("layer", e); // search beginning with layer, since e may be e.g. in a beam.
// all tuplet elements have to be in same descendant tree; tuplets can't cross measure boundaries
List<Element> tupletElements = Helper.getAllDescendantsByAttribute("tuplet", parentLayer);
List<Element> tupletElements = Helper.getAllDescendantsWithAttribute("tuplet", parentLayer);
if (tupletElements == null || tupletElements.isEmpty()) break;
num = "" + tupletElements.size();
int numInt = Integer.parseInt(num);
Expand Down

0 comments on commit 773d9cf

Please sign in to comment.