Quellcode durchsuchen

Muzio Clementi fix

Andrea Condoluci vor 9 Jahren
Ursprung
Commit
9773bbe40f

+ 5 - 2
src/Common/FileIO/Xml.ts

@@ -52,10 +52,13 @@ export class IXmlElement {
     if (!nameUnset) {
       nodeName = nodeName.toLowerCase();
     }
-    console.log("-", nodes.length, this.elem.childElementCount);
+    // console.log("-", nodeName, nodes.length, this.elem.childElementCount, this.elem.getElementsByTagName(nodeName).length);
+    // if (nodeName === "measure") {
+    //   console.log(this.elem);
+    // }
     for (let i: number = 0; i < nodes.length; i += 1) {
       let node: Node = nodes[i];
-      console.log("node: ", this.elem.nodeName, ">>", node.nodeName, node.nodeType === Node.ELEMENT_NODE);
+      // console.log("node: ", this.elem.nodeName, ">>", node.nodeName, node.nodeType === Node.ELEMENT_NODE);
       if (node.nodeType === Node.ELEMENT_NODE &&
         (nameUnset || node.nodeName.toLowerCase() === nodeName)) {
           ret.push(new IXmlElement(node as Element));

+ 4 - 8
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -535,7 +535,7 @@ export class InstrumentReader {
         let signNode: IXmlElement = nodeList.element("sign");
         if (signNode !== undefined) {
           try {
-            // (*) clefEnum = <ClefEnum>Enum.Parse(/*typeof*/ClefEnum, signNode.value);
+            clefEnum = ClefEnum[signNode.value];
             if (!ClefInstruction.isSupportedClef(clefEnum)) {
               if (clefEnum === ClefEnum.TAB && guitarPro) {
                 clefOctaveOffset = -1;
@@ -613,7 +613,7 @@ export class InstrumentReader {
       if (modeNode !== undefined) { modeNode = modeNode.element("mode"); }
       if (modeNode !== undefined) {
         try {
-          // (*) keyEnum = <KeyEnum>Enum.Parse(/*typeof*/KeyEnum, modeNode.value);
+          keyEnum = KeyEnum[modeNode.value];
         } catch (ex) {
           errorMsg = ITextTranslation.translateText(
             "ReaderErrorMessages/KeyError",
@@ -631,12 +631,8 @@ export class InstrumentReader {
     if (node.element("time") !== undefined) {
       let symbolEnum: RhythmSymbolEnum = RhythmSymbolEnum.NONE;
       let timeNode: IXmlElement = node.element("time");
-      if (
-        timeNode !== undefined &&
-        timeNode.hasAttributes &&
-        timeNode.attributes() !== undefined
-      ) {
-        let firstAttr: IXmlAttribute = timeNode.attributes()[0];
+      if (timeNode !== undefined && timeNode.hasAttributes) {
+        let firstAttr: IXmlAttribute = timeNode.firstAttribute;
         if (firstAttr.name === "symbol") {
           if (firstAttr.value === "common") {
             symbolEnum = RhythmSymbolEnum.COMMON;

+ 2 - 3
src/MusicalScore/ScoreIO/MusicSheetReader.ts

@@ -117,9 +117,9 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
     let partInst: IXmlElement[] = root.elements("part");
     console.log(partInst.length + " parts");
     let partList: IXmlElement[] = partlistNode.elements();
-    Logging.debug("Starting initializeReading");
+    //Logging.debug("Starting initializeReading");
     this.initializeReading(partList, partInst, instrumentReaders);
-    Logging.debug("Done initializeReading");
+    //Logging.debug("Done initializeReading");
     let couldReadMeasure: boolean = true;
     this.currentFraction = new Fraction(0, 1);
     let guitarPro: boolean = false;
@@ -135,7 +135,6 @@ export class MusicSheetReader /*implements IMusicSheetReader*/ {
     }
 
     while (couldReadMeasure) {
-      Logging.debug("+couldReadMeasure");
       if (this.currentMeasure !== undefined && this.currentMeasure.endsPiece) {
         sourceMeasureCounter = 0;
       }

+ 9 - 0
test/MusicalScore/ScoreIO/MusicSheetReader.ts

@@ -26,6 +26,15 @@ describe("Music Sheet Reader Tests", () => {
         let documentElement: IXmlElement = new IXmlElement(container);
         chai.expect(documentElement.elements("score-partwise").length).to.equal(1);
         let root: IXmlElement = documentElement.element("score-partwise");
+        //
+        // let elem: Element = (root as any).elem;
+        // console.log(
+        //   "@",
+        //   elem.getElementsByTagName("part")[0].getElementsByTagName("measure").length,
+        //   root.element("part").elements("measure").length
+        // );
+
+
         chai.expect(root).to.not.be.undefined;
         chai.expect(root.elements("part").length).to.equal(2);
         chai.expect(root.element("part").elements("measure").length).to.equal(38);

+ 3 - 3
test/data/MuzioClementi_SonatinaOpus36No1_Part1.xml

@@ -379,7 +379,7 @@
       <direction placement="below">
         <direction-type>
           <dynamics>
-            <p/>
+            <p></p>
             </dynamics>
           </direction-type>
         <sound dynamics="54.44"/>
@@ -1185,7 +1185,7 @@
       <direction placement="below">
         <direction-type>
           <dynamics>
-            <p/>
+            <p></p>
             </dynamics>
           </direction-type>
         <sound dynamics="54.44"/>
@@ -1749,7 +1749,7 @@
       <direction placement="below">
         <direction-type>
           <dynamics>
-            <p/>
+            <p></p>
             </dynamics>
           </direction-type>
         <sound dynamics="54.44"/>