Explorar o código

merge osmd-public/develop: fix whole+half rests outside staff lines not having ledger lines, fix tabs showing time and key signature and fingerings by default

sschmidTU hai 1 ano
pai
achega
51bcb9a0c4

+ 6 - 0
demo/index.js

@@ -107,6 +107,7 @@ import { TransposeCalculator } from '../src/Plugins/Transpose/TransposeCalculato
         printPdfBtns,
         transpose,
         transposeBtn,
+        versionDiv,
         performanceMode,
         performanceModeBtn,
         playbackControlsButton,
@@ -282,6 +283,7 @@ import { TransposeCalculator } from '../src/Plugins/Transpose/TransposeCalculato
         printPdfBtns.push(document.getElementById("print-pdf-btn-optional"));
         transpose = document.getElementById('transpose');
         transposeBtn = document.getElementById('transpose-btn');
+        versionDiv = document.getElementById('versionDiv');
         playbackControlsButton = document.getElementById("playback-settings-button");
         // unmuteButton = document.getElementById("unmute-button");
 
@@ -523,6 +525,10 @@ import { TransposeCalculator } from '../src/Plugins/Transpose/TransposeCalculato
         openSheetMusicDisplay.setLogLevel('info'); // set this to 'debug' if you want to see more detailed control flow information in console
         document.body.appendChild(canvas);
 
+        if (versionDiv) {
+            versionDiv.innerHTML = "OSMD Version: " + openSheetMusicDisplay.Version.replace("-release", "").replace("-dev", "");
+        }
+
         window.addEventListener("keydown", function (e) {
             var event = window.event ? window.event : e;
             // left arrow key

+ 6 - 0
src/MusicalScore/Graphical/EngravingRules.ts

@@ -186,6 +186,9 @@ export class EngravingRules {
     public TupletVerticalLineLength: number;
     public TupletNumbersInTabs: boolean;
     public TabBeamsRendered: boolean;
+    public TabKeySignatureRendered: boolean;
+    public TabTimeSignatureRendered: boolean;
+    public TabFingeringsRendered: boolean;
 
     public RepetitionAllowFirstMeasureBeginningRepeatBarline: boolean;
     public RepetitionEndingLabelHeight: number;
@@ -659,6 +662,9 @@ export class EngravingRules {
         this.TupletVerticalLineLength = 0.5;
         this.TupletNumbersInTabs = false; // disabled by default, nonstandard in tabs, at least how we show them in non-tabs.
         this.TabBeamsRendered = true;
+        this.TabKeySignatureRendered = false; // standard not to render for tab scores
+        this.TabTimeSignatureRendered = false; // standard not to render for tab scores
+        this.TabFingeringsRendered = false; // tabs usually don't show fingering. This can also be duplicated when you have a classical+tab score.
 
         // Slur and Tie variables
         this.SlurPlacementFromXML = true;

+ 1 - 0
src/MusicalScore/Graphical/GraphicalMeasure.ts

@@ -76,6 +76,7 @@ export abstract class GraphicalMeasure extends GraphicalObject {
     public ExtraGraphicalMeasurePreviousMeasure: GraphicalMeasure;
     public ShowTimeSignature: boolean = true;
     public ShowKeySignature: boolean = true;
+    public isTabMeasure: boolean = false;
 
     public get ParentStaff(): Staff {
         return this.parentStaff;

+ 3 - 0
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -3033,6 +3033,9 @@ export abstract class MusicSheetCalculator {
         for (const system of this.musicSystems) {
             for (const line of system.StaffLines) {
                 for (const measure of line.Measures) {
+                    if (measure.isTabMeasure && !this.rules.TabFingeringsRendered) {
+                        continue; // don't duplicate fingerings into tab measures. tab notes are already
+                    }
                     const placement: PlacementEnum = this.getFingeringPlacement(measure);
                     for (const gse of measure.staffEntries) {
                         gse.FingeringEntries = [];

+ 6 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowMeasure.ts

@@ -61,7 +61,6 @@ export class VexFlowMeasure extends GraphicalMeasure {
         this.resetLayout();
     }
 
-    public isTabMeasure: boolean = false;
     /** octaveOffset according to active clef */
     public octaveOffset: number = 3;
     /** The VexFlow Voices in the measure */
@@ -257,6 +256,9 @@ export class VexFlowMeasure extends GraphicalMeasure {
         if (!this.rules.RenderKeySignatures || !this.ShowKeySignature) {
             return;
         }
+        if (this.isTabMeasure && !this.rules.TabKeySignatureRendered) {
+            return;
+        }
         if (this.parentSourceMeasure?.isReducedToMultiRest && !this.rules.MultipleRestMeasureAddKeySignature) {
             return;
         }
@@ -274,6 +276,9 @@ export class VexFlowMeasure extends GraphicalMeasure {
      * @param rhythm
      */
     public addRhythmAtBegin(rhythm: RhythmInstruction): void {
+        if (this.isTabMeasure && !this.rules.TabTimeSignatureRendered) {
+            return;
+        }
         const timeSig: VF.TimeSignature = VexFlowConverter.TimeSignature(rhythm);
         this.stave.addModifier(
             timeSig,

+ 4 - 0
src/VexFlowPatch/readme.txt

@@ -21,6 +21,10 @@ able to add svg node id+class to beam (not yet in vexflow 4)
 clef.js (merged vexflow 4):
 open group to get SVG group+class for clef
 
+font/vexflow_font.js (merged vexflow 4):
+add glyphs for whole and half rests with ledger lines (#1142)
+  note that custom_glyphs.js is not used in the build, so it's unnecessary to modify it.
+
 formatter.js:
 comment out unnecessary error thrown, which prevents the fix to
   layouting improvements with whole measure rests and e.g. 12/8 rhythm in #1187.

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 34 - 0
src/VexFlowPatch/src/fonts/vexflow_font.js


+ 19 - 2
src/VexFlowPatch/src/notehead.js

@@ -92,7 +92,22 @@ export class NoteHead extends Note {
     }
 
     this.glyph_code = this.glyph.code_head;
+
+    this.x_shift_ledger_rest = 0; // somehow some percussion glyphs need to not apply this.x_shift
+    this.y_shift_ledger_rest = 0;
     this.x_shift = head_options.x_shift || 0;
+    // Swap out the glyph with ledger lines
+    if (this.glyph.rest && (this.line > 5 || this.line < 0)) {
+      if (this.duration === 'h') {
+        head_options.custom_glyph_code = 'rhl';
+        this.x_shift_ledger_rest -= 4;
+        this.y_shift_ledger_rest = -5; // was too far down
+      } else if (this.duration === 'w') {
+        head_options.custom_glyph_code = 'rwl';
+        this.x_shift_ledger_rest -= 4;
+        this.y_shift_ledger_rest = 5; // was too far up
+      }
+    }
     if (head_options.custom_glyph_code) {
       this.custom_glyph = true;
       this.glyph_code = head_options.custom_glyph_code;
@@ -198,15 +213,17 @@ export class NoteHead extends Note {
     let head_x = this.getAbsoluteX();
     let y = this.y;
     if (this.custom_glyph) {
-      // head_x += this.x_shift;
+      // head_x += this.x_shift; // somehow some new percussion glyphs need to not apply this.x_shift
+      head_x += this.x_shift_ledger_rest;
       if (this.stem_direction === Stem.UP) {
         head_x += this.stem_up_x_offset;
         // VexFlowPatch: also allow notehead shift independent of stem length
         y += (this.stem_up_y_shift || 0);
-      } else {
+      } else if (this.stem_direction === Stem.DOWN) {
         head_x += this.stem_down_x_offset
         y += (this.stem_down_y_shift || 0)
       }
+      y += this.y_shift_ledger_rest;
     }
 
     L("Drawing note head '", this.note_type, this.duration, "' at", head_x, y);

+ 4 - 0
src/VexFlowPatch/src/tables.js

@@ -230,6 +230,10 @@ Flow.keyProperties.customNoteHeads = {
   /* Rectangle */
   'R1': { code: 'vd5', shift_right: 0 },
   'R2': { code: 'vd4', shift_right: 0 },
+
+  /* Whole and Half Rests with ledger line */
+  'rwl': { code: 'rwl', shift_right: 0 },
+  'rhl': { code: 'rhl', shift_right: 0 },
 };
 
 Flow.integerToNote = integer => {

+ 169 - 0
test/data/test_ledger_line_rest.musicxml

@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
+<score-partwise version="3.1">
+  <work>
+    <work-title>test_ledger_line_rest</work-title>
+    </work>
+  <identification>
+    <encoding>
+      <software>MuseScore 3.6.2</software>
+      <encoding-date>2023-10-04</encoding-date>
+      <supports element="accidental" type="yes"/>
+      <supports element="beam" type="yes"/>
+      <supports element="print" attribute="new-page" type="yes" value="yes"/>
+      <supports element="print" attribute="new-system" type="yes" value="yes"/>
+      <supports element="stem" type="yes"/>
+      </encoding>
+    </identification>
+  <defaults>
+    <scaling>
+      <millimeters>6.99911</millimeters>
+      <tenths>40</tenths>
+      </scaling>
+    <page-layout>
+      <page-height>1596.77</page-height>
+      <page-width>1233.87</page-width>
+      <page-margins type="even">
+        <left-margin>85.7252</left-margin>
+        <right-margin>85.7252</right-margin>
+        <top-margin>85.7252</top-margin>
+        <bottom-margin>85.7252</bottom-margin>
+        </page-margins>
+      <page-margins type="odd">
+        <left-margin>85.7252</left-margin>
+        <right-margin>85.7252</right-margin>
+        <top-margin>85.7252</top-margin>
+        <bottom-margin>85.7252</bottom-margin>
+        </page-margins>
+      </page-layout>
+    <word-font font-family="Edwin" font-size="10"/>
+    <lyric-font font-family="Edwin" font-size="10"/>
+    </defaults>
+  <credit page="1">
+    <credit-type>title</credit-type>
+    <credit-words default-x="616.935" default-y="1511.09" justify="center" valign="top" font-size="22">test_ledger_line_rest</credit-words>
+    </credit>
+  <part-list>
+    <score-part id="P1">
+      <part-name>Piano</part-name>
+      <part-abbreviation>Pno.</part-abbreviation>
+      <score-instrument id="P1-I1">
+        <instrument-name>Piano</instrument-name>
+        </score-instrument>
+      <midi-device id="P1-I1" port="1"></midi-device>
+      <midi-instrument id="P1-I1">
+        <midi-channel>1</midi-channel>
+        <midi-program>1</midi-program>
+        <volume>78.7402</volume>
+        <pan>0</pan>
+        </midi-instrument>
+      </score-part>
+    </part-list>
+  <part id="P1">
+    <measure number="1" width="289.74">
+      <print>
+        <system-layout>
+          <system-margins>
+            <left-margin>50.00</left-margin>
+            <right-margin>483.89</right-margin>
+            </system-margins>
+          <top-system-distance>170.00</top-system-distance>
+          </system-layout>
+        </print>
+      <attributes>
+        <divisions>1</divisions>
+        <key>
+          <fifths>0</fifths>
+          </key>
+        <time>
+          <beats>4</beats>
+          <beat-type>4</beat-type>
+          </time>
+        <clef>
+          <sign>G</sign>
+          <line>2</line>
+          </clef>
+        </attributes>
+      <note default-x="73.72" default-y="0.00">
+        <pitch>
+          <step>F</step>
+          <octave>5</octave>
+          </pitch>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        <stem>down</stem>
+        </note>
+      <note>
+        <rest/>
+        <duration>1</duration>
+        <voice>1</voice>
+        <type>quarter</type>
+        </note>
+      <note>
+        <rest/>
+        <duration>2</duration>
+        <voice>1</voice>
+        <type>half</type>
+        </note>
+      <backup>
+        <duration>4</duration>
+        </backup>
+      <note>
+        <rest>
+          <display-step>B</display-step>
+          <display-octave>6</display-octave>
+          </rest>
+        <duration>4</duration>
+        <voice>2</voice>
+        <type>whole</type>
+        </note>
+      </measure>
+    <measure number="2" width="238.79">
+      <note default-x="18.56" default-y="-65.00">
+        <pitch>
+          <step>G</step>
+          <octave>3</octave>
+          </pitch>
+        <duration>2</duration>
+        <voice>1</voice>
+        <type>half</type>
+        <stem>up</stem>
+        </note>
+      <note default-x="123.35" default-y="-60.00">
+        <pitch>
+          <step>A</step>
+          <octave>3</octave>
+          </pitch>
+        <duration>2</duration>
+        <voice>1</voice>
+        <type>half</type>
+        <stem>up</stem>
+        </note>
+      <backup>
+        <duration>4</duration>
+        </backup>
+      <note>
+        <rest>
+          <display-step>D</display-step>
+          <display-octave>3</display-octave>
+          </rest>
+        <duration>2</duration>
+        <voice>2</voice>
+        <type>half</type>
+        </note>
+      <note>
+        <rest>
+          <display-step>D</display-step>
+          <display-octave>3</display-octave>
+          </rest>
+        <duration>2</duration>
+        <voice>2</voice>
+        <type>half</type>
+        </note>
+      <barline location="right">
+        <bar-style>light-heavy</bar-style>
+        </barline>
+      </measure>
+    </part>
+  </score-partwise>

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio