浏览代码

fix(Stems): respect <stem>None, don't display stems (#964)

drawn transparently for now, ideally we should make vexflow not draw them at all,
e.g. using (vfStaveNote as any).shouldRenderStem = false,
see #951.

* Modify various chord test to include slash notes

* Make stem transparent for stem direction none

Co-authored-by: sschmid <s.schmid@phonicscore.com>
Michael P Hartman 4 年之前
父节点
当前提交
941c50b6f0
共有 2 个文件被更改,包括 169 次插入128 次删除
  1. 3 0
      src/MusicalScore/ScoreIO/VoiceGenerator.ts
  2. 166 128
      test/data/OSMD_function_test_chord_tests_various.musicxml

+ 3 - 0
src/MusicalScore/ScoreIO/VoiceGenerator.ts

@@ -471,6 +471,9 @@ export class VoiceGenerator {
     if ((noteheadShapeXml !== undefined && noteheadShapeXml !== "normal") || noteheadFilledXml !== undefined) {
       note.Notehead = new Notehead(note, noteheadShapeXml, noteheadFilledXml);
     } // if normal, leave note head undefined to save processing/runtime
+    if (stemDirectionXml === StemDirectionType.None) {
+      stemColorXml = "#00000000";  // just setting this to transparent for now
+    }
     this.currentVoiceEntry.Notes.push(note);
     this.currentVoiceEntry.StemDirectionXml = stemDirectionXml;
     if (stemColorXml) {

+ 166 - 128
test/data/OSMD_function_test_chord_tests_various.musicxml

@@ -8,7 +8,7 @@
     <rights>Copyright © </rights>
     <encoding>
       <software>MuseScore 3.4.2</software>
-      <encoding-date>2021-01-21</encoding-date>
+      <encoding-date>2021-02-09</encoding-date>
       <supports element="accidental" type="yes"/>
       <supports element="beam" type="yes"/>
       <supports element="print" attribute="new-page" type="yes" value="yes"/>
@@ -64,18 +64,18 @@
       </score-part>
     </part-list>
   <part id="P1">
-    <measure number="1" width="185.91">
+    <measure number="1" width="176.63">
       <print>
         <system-layout>
           <system-margins>
-            <left-margin>20.76</left-margin>
+            <left-margin>0.00</left-margin>
             <right-margin>0.00</right-margin>
             </system-margins>
           <top-system-distance>170.00</top-system-distance>
           </system-layout>
         </print>
       <attributes>
-        <divisions>1</divisions>
+        <divisions>2</divisions>
         <key>
           <fifths>0</fifths>
           </key>
@@ -99,7 +99,7 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
@@ -116,13 +116,13 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
         </note>
       </measure>
-    <measure number="2" width="141.67">
+    <measure number="2" width="158.79">
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
@@ -139,15 +139,27 @@
           <degree-type>subtract</degree-type>
           </degree>
         </harmony>
-      <note default-x="11.73" default-y="-15.00">
+      <note default-x="11.99" default-y="-20.00">
         <pitch>
-          <step>C</step>
-          <octave>5</octave>
+          <step>B</step>
+          <octave>4</octave>
           </pitch>
         <duration>2</duration>
         <voice>1</voice>
-        <type>half</type>
-        <stem>down</stem>
+        <type>quarter</type>
+        <stem>none</stem>
+        <notehead>slash</notehead>
+        </note>
+      <note default-x="47.79" default-y="-20.00">
+        <pitch>
+          <step>B</step>
+          <octave>4</octave>
+          </pitch>
+        <duration>2</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <stem>none</stem>
+        <notehead>slash</notehead>
         </note>
       <harmony print-frame="no">
         <root>
@@ -165,90 +177,136 @@
           <degree-type>subtract</degree-type>
           </degree>
         </harmony>
-      <note default-x="83.33" default-y="-15.00">
+      <note default-x="83.59" default-y="-20.00">
         <pitch>
-          <step>C</step>
-          <octave>5</octave>
+          <step>B</step>
+          <octave>4</octave>
           </pitch>
         <duration>2</duration>
         <voice>1</voice>
-        <type>half</type>
-        <stem>down</stem>
+        <type>quarter</type>
+        <stem>none</stem>
+        <notehead>slash</notehead>
+        </note>
+      <note default-x="119.40" default-y="-20.00">
+        <pitch>
+          <step>B</step>
+          <octave>4</octave>
+          </pitch>
+        <duration>2</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <stem>none</stem>
+        <notehead>slash</notehead>
         </note>
       </measure>
-    <measure number="3" width="160.57">
+    <measure number="3" width="210.56">
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
           </root>
-        <kind text="11sus4">suspended-fourth</kind>
+        <kind>suspended-fourth</kind>
         <degree>
-          <degree-value text="">7</degree-value>
+          <degree-value>7</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">9</degree-value>
+          <degree-value>9</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">11</degree-value>
+          <degree-value>11</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         </harmony>
-      <note default-x="11.73" default-y="-15.00">
+      <note default-x="15.14" default-y="-20.00">
         <pitch>
-          <step>C</step>
-          <octave>5</octave>
+          <step>B</step>
+          <octave>4</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
+        <notehead>slash</notehead>
         </note>
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
           </root>
-        <kind text="13sus4">suspended-fourth</kind>
+        <kind>suspended-fourth</kind>
         <degree>
-          <degree-value text="">7</degree-value>
+          <degree-value>7</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">9</degree-value>
+          <degree-value>9</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">11</degree-value>
+          <degree-value>11</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">13</degree-value>
+          <degree-value>13</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         </harmony>
-      <note default-x="94.42" default-y="-15.00">
+      <note default-x="102.61" default-y="-20.00">
         <pitch>
-          <step>C</step>
-          <octave>5</octave>
+          <step>B</step>
+          <octave>4</octave>
+          </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>eighth</type>
+        <stem>down</stem>
+        <notehead>slash</notehead>
+        <beam number="1">begin</beam>
+        </note>
+      <note default-x="130.04" default-y="-20.00">
+        <pitch>
+          <step>B</step>
+          <octave>4</octave>
+          </pitch>
+        <duration>1</duration>
+        <tie type="start"/>
+        <voice>1</voice>
+        <type>eighth</type>
+        <stem>down</stem>
+        <notehead>slash</notehead>
+        <beam number="1">end</beam>
+        <notations>
+          <tied type="start"/>
+          </notations>
+        </note>
+      <note default-x="157.48" default-y="-20.00">
+        <pitch>
+          <step>B</step>
+          <octave>4</octave>
           </pitch>
         <duration>2</duration>
+        <tie type="stop"/>
         <voice>1</voice>
-        <type>half</type>
+        <type>quarter</type>
         <stem>down</stem>
+        <notehead>slash</notehead>
+        <notations>
+          <tied type="stop"/>
+          </notations>
         </note>
       <barline location="right">
         <bar-style>light-light</bar-style>
         </barline>
       </measure>
-    <measure number="4" width="128.44">
+    <measure number="4" width="119.17">
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
@@ -260,7 +318,7 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
@@ -277,22 +335,22 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
         </note>
       </measure>
-    <measure number="5" width="141.74">
+    <measure number="5" width="132.47">
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
           </root>
-        <kind text="7sus2">suspended-second</kind>
+        <kind>suspended-second</kind>
         <degree>
-          <degree-value text="">7</degree-value>
+          <degree-value>7</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         </harmony>
       <note default-x="11.73" default-y="-15.00">
@@ -300,7 +358,7 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
@@ -309,16 +367,16 @@
         <root>
           <root-step>C</root-step>
           </root>
-        <kind text="9sus2">suspended-second</kind>
+        <kind>suspended-second</kind>
         <degree>
-          <degree-value text="">7</degree-value>
+          <degree-value>7</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">9</degree-value>
+          <degree-value>9</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         </harmony>
       <note default-x="83.40" default-y="-15.00">
@@ -326,32 +384,32 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
         </note>
       </measure>
-    <measure number="6" width="155.05">
+    <measure number="6" width="145.78">
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
           </root>
-        <kind text="11sus2">suspended-second</kind>
+        <kind>suspended-second</kind>
         <degree>
-          <degree-value text="">7</degree-value>
+          <degree-value>7</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">9</degree-value>
+          <degree-value>9</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">11</degree-value>
+          <degree-value>11</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         </harmony>
       <note default-x="11.73" default-y="-15.00">
@@ -359,7 +417,7 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
@@ -368,26 +426,26 @@
         <root>
           <root-step>C</root-step>
           </root>
-        <kind text="13sus2">suspended-second</kind>
+        <kind>suspended-second</kind>
         <degree>
-          <degree-value text="">7</degree-value>
+          <degree-value>7</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">9</degree-value>
+          <degree-value>9</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">11</degree-value>
+          <degree-value>11</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         <degree>
-          <degree-value text="">13</degree-value>
+          <degree-value>13</degree-value>
           <degree-alter>0</degree-alter>
-          <degree-type text="">add</degree-type>
+          <degree-type>add</degree-type>
           </degree>
         </harmony>
       <note default-x="94.49" default-y="-15.00">
@@ -395,13 +453,13 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
         </note>
       </measure>
-    <measure number="7" width="151.59">
+    <measure number="7" width="142.32">
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
@@ -413,14 +471,14 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         <stem>down</stem>
         </note>
       <note>
         <rest/>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         </note>
@@ -432,22 +490,22 @@
         </harmony>
       <note>
         <rest/>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         </note>
       <note>
         <rest/>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         </note>
       </measure>
-    <measure number="8" width="297.32">
+    <measure number="8" width="282.73">
       <print new-system="yes">
         <system-layout>
           <system-margins>
-            <left-margin>20.76</left-margin>
+            <left-margin>0.00</left-margin>
             <right-margin>0.00</right-margin>
             </system-margins>
           <system-distance>150.00</system-distance>
@@ -458,67 +516,62 @@
           <root-step>C</root-step>
           </root>
         <kind text="mmaj7" parentheses-degrees="yes">major-minor</kind>
-        <degree>
-          <degree-value>9</degree-value>
-          <degree-alter>0</degree-alter>
-          <degree-type>add</degree-type>
-          </degree>
         </harmony>
-      <note default-x="58.17" default-y="-15.00">
+      <note default-x="58.18" default-y="-15.00">
         <pitch>
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         <stem>down</stem>
         </note>
       <note>
         <rest/>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         </note>
       <harmony print-frame="no">
         <root>
-          <root-step text="">C</root-step>
+          <root-step>C</root-step>
           </root>
         <kind text="N.C.">none</kind>
         </harmony>
       <note>
         <rest/>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         </note>
       <note>
         <rest/>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         </note>
       </measure>
-    <measure number="9" width="177.17">
+    <measure number="9" width="181.69">
       <harmony print-frame="no">
         <root>
-          <root-step text="">C</root-step>
+          <root-step>C</root-step>
           </root>
         <kind text="NC">none</kind>
         </harmony>
-      <note default-x="12.17" default-y="-15.00">
+      <note default-x="11.73" default-y="-15.00">
         <pitch>
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         <stem>down</stem>
         </note>
       <note>
         <rest/>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         </note>
@@ -533,24 +586,24 @@
           <degree-type>add</degree-type>
           </degree>
         </harmony>
-      <note default-x="93.87" default-y="-15.00">
+      <note default-x="95.91" default-y="-15.00">
         <pitch>
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         <stem>down</stem>
         </note>
       <note>
         <rest/>
-        <duration>1</duration>
+        <duration>2</duration>
         <voice>1</voice>
         <type>quarter</type>
         </note>
       </measure>
-    <measure number="10" width="181.13">
+    <measure number="10" width="167.07">
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
@@ -567,7 +620,7 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
@@ -583,18 +636,18 @@
           <degree-type>add</degree-type>
           </degree>
         </harmony>
-      <note default-x="95.45" default-y="-15.00">
+      <note default-x="88.42" default-y="-15.00">
         <pitch>
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
         </note>
       </measure>
-    <measure number="11" width="230.65">
+    <measure number="11" width="204.76">
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
@@ -605,18 +658,13 @@
           <degree-alter>0</degree-alter>
           <degree-type>add</degree-type>
           </degree>
-        <degree>
-          <degree-value>11</degree-value>
-          <degree-alter>0</degree-alter>
-          <degree-type>add</degree-type>
-          </degree>
         </harmony>
       <note default-x="11.73" default-y="-15.00">
         <pitch>
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
@@ -631,29 +679,19 @@
           <degree-alter>0</degree-alter>
           <degree-type>add</degree-type>
           </degree>
-        <degree>
-          <degree-value>11</degree-value>
-          <degree-alter>0</degree-alter>
-          <degree-type>add</degree-type>
-          </degree>
-        <degree>
-          <degree-value>13</degree-value>
-          <degree-alter>0</degree-alter>
-          <degree-type>add</degree-type>
-          </degree>
         </harmony>
-      <note default-x="120.21" default-y="-15.00">
+      <note default-x="107.26" default-y="-15.00">
         <pitch>
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
         </note>
       </measure>
-    <measure number="12" width="178.69">
+    <measure number="12" width="249.46">
       <harmony print-frame="no">
         <root>
           <root-step>C</root-step>
@@ -685,7 +723,7 @@
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>
@@ -716,12 +754,12 @@
           <degree-type>add</degree-type>
           </degree>
         </harmony>
-      <note default-x="89.73" default-y="-15.00">
+      <note default-x="126.98" default-y="-15.00">
         <pitch>
           <step>C</step>
           <octave>5</octave>
           </pitch>
-        <duration>2</duration>
+        <duration>4</duration>
         <voice>1</voice>
         <type>half</type>
         <stem>down</stem>