/
EngravingRules.ts
1173 lines (1117 loc) · 59.5 KB
/
EngravingRules.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { PagePlacementEnum } from "./GraphicalMusicPage";
//import {MusicSymbol} from "./MusicSymbol";
import log from "loglevel";
import { TextAlignmentEnum } from "../../Common/Enums/TextAlignment";
import { PlacementEnum } from "../VoiceData/Expressions/AbstractExpression";
import {
AutoBeamOptions,
AlignRestOption,
FillEmptyMeasuresWithWholeRests,
SkyBottomLineBatchCalculatorBackendType
} from "../../OpenSheetMusicDisplay/OSMDOptions";
import { ColoringModes as ColoringMode } from "../../Common/Enums/ColoringModes";
import { Dictionary } from "typescript-collections";
import { FontStyles } from "../../Common/Enums";
import { NoteEnum, AccidentalEnum } from "../../Common/DataObjects/Pitch";
import { ChordSymbolEnum, CustomChord, DegreesInfo } from "../../MusicalScore/VoiceData/ChordSymbolContainer";
import { GraphicalNote } from "./GraphicalNote";
import { Note } from "../VoiceData/Note";
/** Rendering and Engraving options, more fine-grained than [[IOSMDOptions]].
* Not all of these options are meant to be modified by users of the library,
* full support is only given for [[IOSMDOptions]].
* Nevertheless, there are many useful options here,
* like Render* to (not) render certain elements (e.g. osmd.rules.RenderRehearsalMarks = false)
*/
export class EngravingRules {
/** A unit of distance. 1.0 is the distance between lines of a stave for OSMD, which is 10 pixels in Vexflow. */
public static unit: number = 1.0;
public SamplingUnit: number;
public StaccatoShorteningFactor: number;
/** Height (size) of the sheet title. */
public SheetTitleHeight: number;
public SheetSubtitleHeight: number;
public SheetMinimumDistanceBetweenTitleAndSubtitle: number;
public SheetComposerHeight: number;
public SheetAuthorHeight: number;
public SheetCopyrightHeight: number;
public SheetCopyrightMargin: number;
/** Whether to use the (deprecated) OSMD < 1.8.6 way of parsing and displaying subtitles and composer,
* which did not read multiple lines from XML credit-words tags.
* Option will probably be removed soon.
* @deprecated
*/
public SheetComposerSubtitleUseLegacyParsing: boolean;
public CompactMode: boolean;
public PagePlacementEnum: PagePlacementEnum;
public PageHeight: number;
public PageTopMargin: number;
public PageTopMarginNarrow: number;
public PageBottomMargin: number;
public PageLeftMargin: number;
public PageRightMargin: number;
public TitleTopDistance: number;
public TitleBottomDistance: number;
public SystemLeftMargin: number;
public SystemRightMargin: number;
public SystemLabelsRightMargin: number;
public SystemComposerDistance: number;
public SystemLyricistDistance: number;
public InstrumentLabelTextHeight: number;
public MinimumDistanceBetweenSystems: number;
public MinSkyBottomDistBetweenSystems: number;
public LastSystemMaxScalingFactor: number;
public StaffDistance: number;
public BetweenStaffDistance: number;
public StaffHeight: number;
public TabStaffInterlineHeight: number;
public BetweenStaffLinesDistance: number;
/** Whether to automatically beam notes that don't already have beams in XML. */
public AutoBeamNotes: boolean;
/** Options for autoBeaming like whether to beam over rests. See AutoBeamOptions interface. */
public AutoBeamOptions: AutoBeamOptions;
/** Whether to automatically generate new beams for tabs. Also see TabBeamsRendered for existing XML beams. */
public AutoBeamTabs: boolean;
public BeamWidth: number;
public BeamSpaceWidth: number;
public BeamForwardLength: number;
public FlatBeams: boolean;
public FlatBeamOffset: number;
public FlatBeamOffsetPerBeam: number;
public ClefLeftMargin: number;
public ClefRightMargin: number;
/** How many unique note positions a percussion score needs to have to not be rendered on one line.
* To always use 5 lines for percussion, set this to 0. (works unless the XML says <staff-lines>1)
*/
public PercussionOneLineCutoff: number;
public PercussionForceVoicesOneLineCutoff: number;
public PercussionUseXMLDisplayStep: boolean;
public PercussionXMLDisplayStepNoteValueShift: number;
public PercussionOneLineXMLDisplayStepOctaveOffset: number;
/** Makes the score position notes on the 2 cajon stafflines, and use 2 stafflines even if PercussionOneLineCutoff set.
* Should only be set for cajon scores, as this will disable the PercussionOneLineCutoff.
*/
public PercussionUseCajon2NoteSystem: boolean;
public BetweenKeySymbolsDistance: number;
public KeyRightMargin: number;
public RhythmRightMargin: number;
public ShowRhythmAgainAfterPartEndOrFinalBarline: boolean;
public NewPartAndSystemAfterFinalBarline: boolean;
public InStaffClefScalingFactor: number;
public DistanceBetweenNaturalAndSymbolWhenCancelling: number;
public NoteHelperLinesOffset: number;
public MeasureLeftMargin: number;
public MeasureRightMargin: number;
public DistanceBetweenLastInstructionAndRepetitionBarline: number;
public ArpeggioDistance: number;
public IdealStemLength: number;
public StemNoteHeadBorderYOffset: number;
public StemWidth: number;
public StemMargin: number;
public StemMinLength: number;
public StemMaxLength: number;
public BeamSlopeMaxAngle: number;
public StemMinAllowedDistanceBetweenNoteHeadAndBeamLine: number;
public SetWantedStemDirectionByXml: boolean;
public GraceNoteScalingFactor: number;
public GraceNoteXOffset: number;
public GraceNoteGroupXMargin: number;
public WedgeOpeningLength: number;
public WedgeMeasureEndOpeningLength: number;
public WedgeMeasureBeginOpeningLength: number;
public WedgePlacementAboveY: number;
public WedgePlacementBelowY: number;
public WedgeHorizontalMargin: number;
public WedgeVerticalMargin: number;
public DistanceOffsetBetweenTwoHorizontallyCrossedWedges: number;
public WedgeMinLength: number;
public WedgeEndDistanceBetweenTimestampsFactor: number;
public SoftAccentWedgePadding: number;
public SoftAccentSizeFactor: number;
public DistanceBetweenAdjacentDynamics: number;
public TempoChangeMeasureValidity: number;
public TempoContinousFactor: number;
public StaccatoScalingFactor: number;
public BetweenDotsDistance: number;
public OrnamentAccidentalScalingFactor: number;
public ChordSymbolTextHeight: number;
public ChordSymbolTextAlignment: TextAlignmentEnum;
public ChordSymbolRelativeXOffset: number;
/** Additional x-shift for short chord symbols (e.g. C, but not Eb/7), to appear more centered. */
public ChordSymbolExtraXShiftForShortChordSymbols: number;
/** Threshold width below which to apply ChordSymbolExtraXShiftForShortChordSymbols. */
public ChordSymbolExtraXShiftWidthThreshold: number;
public ChordSymbolXSpacing: number;
public ChordOverlapAllowedIntoNextMeasure: number;
public ChordSymbolYOffset: number;
public ChordSymbolYPadding: number;
public ChordSymbolYAlignment: boolean;
public ChordSymbolYAlignmentScope: string;
/** Offset to start of measure (barline) when chord symbol is on whole measure rest.
* An offset of 0 would place the chord symbol directly above the barline, so the default is ~1.2.
*/
public ChordSymbolWholeMeasureRestXOffset: number;
public ChordSymbolWholeMeasureRestXOffsetMeasure1: number;
public ChordSymbolLabelTexts: Dictionary<ChordSymbolEnum, string>;
public ChordAccidentalTexts: Dictionary<AccidentalEnum, string>;
public CustomChords: CustomChord[];
/** Not always a symbol, can also be text (RepetitionInstruction). Keeping the name for backwards compatibility. */
public RepetitionSymbolsYOffset: number;
/** Adds a percent of the stave's width (e.g. 0.4 = 40%) to the x position of end instructions like Fine or D.C. al fine */
public RepetitionEndInstructionXShiftAsPercentOfStaveWidth: number;
public RehearsalMarkXOffset: number;
public RehearsalMarkXOffsetDefault: number;
public RehearsalMarkXOffsetSystemStartMeasure: number;
public RehearsalMarkYOffset: number;
public RehearsalMarkYOffsetDefault: number;
public RehearsalMarkFontSize: number;
public MeasureNumberLabelHeight: number;
public MeasureNumberLabelOffset: number;
public MeasureNumberLabelXOffset: number;
/** Whether tuplets should display ratio (3:2 instead of 3 for triplet). Default false. */
public TupletsRatioed: boolean;
/** Whether tuplets (except triplets) should be bracketed (e.g. |--5--| instead of 5). Default false.
* Note that this doesn't affect triplets (|--3--|), which have their own setting TripletsBracketed.
* If false, only tuplets given as bracketed in XML (bracket="yes") will be bracketed.
* (If not given in XML, bracketing is implementation-dependent according to standard)
*/
public TupletsBracketed: boolean;
/** Whether all triplets should be bracketed. Overrides tupletsBracketed for triplets.
* If false, only triplets given as bracketed in XML (bracket="yes") will be bracketed.
* (Bracketing all triplets can be cluttering)
*/
public TripletsBracketed: boolean;
/** Whether to bracket like the XML says when 'bracket="no"' or "yes" is given.
* Otherwise, OSMD decides bracket usage.
* Note that sometimes the XML doesn't have any 'bracket' value. */
public TupletsBracketedUseXMLValue: boolean;
public TupletNumberLabelHeight: number;
public TupletNumberYOffset: number;
public TupletNumberLimitConsecutiveRepetitions: boolean;
public TupletNumberMaxConsecutiveRepetitions: number;
public TupletNumberAlwaysDisableAfterFirstMax: boolean;
/** Whether to use the <tuplet show-number="value"> value or to ignore it. */
public TupletNumberUseShowNoneXMLValue: boolean;
public LabelMarginBorderFactor: number;
public TupletVerticalLineLength: number;
/** Whether to show tuplet numbers (and brackets) in tabs. Brackets can be disabled via TabTupletsBracketed. */
public TupletNumbersInTabs: boolean;
/** Whether to show brackets in tab tuplets. To not render tab tuplets entirely, set TupletNumbersInTabs = false. */
public TabTupletsBracketed: boolean;
public TabTupletYOffsetBottom: number;
/** Additional offset applied to top tuplets (added to TabTupletYOffset).
* You could apply a negative offset if the piece doesn't have effects like bends,
* which often take some vertical space.
*/
public TabTupletYOffsetTop: number;
public TabTupletYOffsetEffects: number;
public TabBeamsRendered: boolean;
public TabKeySignatureRendered: boolean;
/** Whether space should be reserved as if there was a key signature.
* False basically only works for tab-only scores, as it prevents vertical x-alignment with other staves.
* False is more compact for tab-only scores.
*/
public TabKeySignatureSpacingAdded: boolean;
public TabTimeSignatureRendered: boolean;
/** Whether space should be reserved as if there was a key signature.
* False basically only works for tab-only scores, as it prevents vertical x-alignment with other staves.
* False is more compact for tab-only scores.
*/
public TabTimeSignatureSpacingAdded: boolean;
public TabFingeringsRendered: boolean;
public RepetitionAllowFirstMeasureBeginningRepeatBarline: boolean;
public RepetitionEndingLabelHeight: number;
public RepetitionEndingLabelXOffset: number;
public RepetitionEndingLabelYOffset: number;
public RepetitionEndingLineYLowerOffset: number;
public RepetitionEndingLineYUpperOffset: number;
public VoltaOffset: number;
/** Default alignment of lyrics.
* Left alignments will extend text to the right of the bounding box,
* which facilitates spacing by extending measure width.
*/
public LyricsAlignmentStandard: TextAlignmentEnum;
public LyricsHeight: number;
public LyricsYOffsetToStaffHeight: number;
public LyricsYMarginToBottomLine: number;
/** Extra x-shift (to the right) for short lyrics to be better vertically aligned.
* Also see ChordSymbolExtraXShiftForShortChordSymbols, same principle, same default value.
*/
public LyricsExtraXShiftForShortLyrics: number;
/** Threshold of the lyric entry's width below which the x-shift is applied. Default 1.4. */
public LyricsExtraXShiftForShortLyricsWidthThreshold: number;
/** Whether to enable x padding (to the right) for notes with long lyrics, see LyricsXPaddingFactorForLongLyrics for the degree.
* This helps avoid overlaps and shorten measures, because otherwise the whole measure needs to be stretched to avoid overlaps,
* see MaximumLyricsElongationFactor */
public LyricsUseXPaddingForLongLyrics: boolean;
/** How much spacing/padding should be added after notes with long lyrics on short notes
* (>4 characters on <8th note),
* so that the measure doesn't need to be elongated too much to avoid lyrics collisions.
* Default 1 = 10 pixels */
public LyricsXPaddingFactorForLongLyrics: number;
/** How wide a text needs to be to trigger lyrics padding for short notes.
* This is visual width, not number of characters, as e.g. 'zzz' is wider than 'iii'.
* Default 3.3.
*/
public LyricsXPaddingWidthThreshold: number;
/** Long notes need less padding than short ones, by default we use 0.7 less padding. */
public LyricsXPaddingReductionForLongNotes: number;
/** Last note in measure needs less padding because of measure bar and bar start/end padding. */
public LyricsXPaddingReductionForLastNoteInMeasure: number;
public LyricsXPaddingForLastNoteInMeasure: boolean;
public VerticalBetweenLyricsDistance: number;
public HorizontalBetweenLyricsDistance: number;
public BetweenSyllableMaximumDistance: number;
public BetweenSyllableMinimumDistance: number;
public LyricOverlapAllowedIntoNextMeasure: number;
public MinimumDistanceBetweenDashes: number;
public MaximumLyricsElongationFactor: number;
public SlurPlacementFromXML: boolean;
public SlurPlacementAtStems: boolean;
public SlurPlacementUseSkyBottomLine: boolean;
public BezierCurveStepSize: number;
public TPower3: number[];
public OneMinusTPower3: number[];
public FactorOne: number[];
public FactorTwo: number[];
public TieGhostObjectWidth: number;
public TieYPositionOffsetFactor: number;
public MinimumNeededXspaceForTieGhostObject: number;
public TieHeightMinimum: number;
public TieHeightMaximum: number;
public TieHeightInterpolationK: number;
public TieHeightInterpolationD: number;
public SlurNoteHeadYOffset: number;
public SlurEndArticulationYOffset: number;
public SlurStartArticulationYOffsetOfArticulation: number;
public SlurStemXOffset: number;
public SlurSlopeMaxAngle: number;
public SlurTangentMinAngle: number;
public SlurTangentMaxAngle: number;
public SlurHeightFactor: number;
public SlurHeightFlattenLongSlursFactorByWidth: number;
public SlurHeightFlattenLongSlursFactorByAngle: number;
public SlurHeightFlattenLongSlursCutoffAngle: number;
public SlurHeightFlattenLongSlursCutoffWidth: number;
public SlursStartingAtSameStaffEntryYOffset: number;
public SlurMaximumYControlPointDistance: number;
public GlissandoNoteOffset: number;
public GlissandoStafflineStartMinimumWidth: number;
public GlissandoStafflineStartYDistanceToNote: number;
public GlissandoStafflineEndOffset: number;
public GlissandoDefaultWidth: number;
public TempoYSpacing: number;
public InstantaneousTempoTextHeight: number;
public ContinuousDynamicTextHeight: number;
/** Whether to use the XML offset value for expressions, especially wedges (crescendo). See #1477 */
public UseEndOffsetForExpressions: boolean;
public MoodTextHeight: number;
public UnknownTextHeight: number;
public ContinuousTempoTextHeight: number;
public VexFlowDefaultNotationFontScale: number;
public VexFlowDefaultTabFontScale: number;
public TremoloStrokeScale: number;
public TremoloYSpacingScale: number;
public TremoloBuzzRollThickness: number;
public StaffLineWidth: number;
public StaffLineColor: string;
public LedgerLineWidth: number;
public LedgerLineStrokeStyle: string;
public LedgerLineColorDefault: string;
public WedgeLineWidth: number;
public TupletLineWidth: number;
public LyricUnderscoreLineWidth: number;
public SystemThinLineWidth: number;
public SystemBoldLineWidth: number;
public SystemRepetitionEndingLineWidth: number;
public SystemDotWidth: number;
public MultipleRestMeasureDefaultWidth: number;
public MultipleRestMeasureAddKeySignature: boolean;
/** Use the same measure width for all measures (experimental).
* Note that this will use the largest width of all measures,
* as Vexflow will mess up the layout with overlays if using less than minimum width.
* See formatter.preCalculateMinTotalWidth()
*/
public FixedMeasureWidth: boolean;
/** Use a fixed width for all measures (experimental).
* This is mostly for debugging or for when you already know how big the measures
* in the target score are, because using a too low width will cause overlaps in Vexflow.
*/
public FixedMeasureWidthFixedValue: number;
public FixedMeasureWidthUseForPickupMeasures: boolean;
public DistanceBetweenVerticalSystemLines: number;
public DistanceBetweenDotAndLine: number;
public RepeatEndStartPadding: number;
public OctaveShiftLineWidth: number;
public OctaveShiftVerticalLineLength: number;
public OctaveShiftOnWholeMeasureNoteUntilEndOfMeasure: boolean;
public GraceLineWidth: number;
public MinimumStaffLineDistance: number;
public MinSkyBottomDistBetweenStaves: number;
public MinimumCrossedBeamDifferenceMargin: number;
/** Maximum width of sheet / HTMLElement containing the score. Canvas is limited to 32767 in current browsers, though SVG isn't.
* Setting this to > 32767 will break the canvas backend (no problem if you only use SVG).
*/
public SheetMaximumWidth: number;
public VoiceSpacingMultiplierVexflow: number;
public VoiceSpacingAddendVexflow: number;
public PickupMeasureWidthMultiplier: number;
/** The spacing between a repetition that is followed by an implicit/pickup/incomplete measure.
* (E.g. in a 4/4 time signature, a measure that repeats after the 3rd beat, continuing with a pickup measure)
*/
public PickupMeasureRepetitionSpacing: number;
/** Multiplier for PickupMeasureRepetitionSpacing if there is only one note in the pickup measure. This usually needs a lot more space. */
public PickupMeasureSpacingSingleNoteAddend: number;
public DisplacedNoteMargin: number;
public MinNoteDistance: number;
public SubMeasureXSpacingThreshold: number;
public MeasureDynamicsMaxScalingFactor: number;
public WholeRestXShiftVexflow: number;
public MetronomeMarksDrawn: boolean;
public MetronomeMarkXShift: number;
public MetronomeMarkYShift: number;
public SoftmaxFactorVexFlow: number;
/** Stagger (x-shift) whole notes that are the same note, but in different voices (show 2 instead of 1). */
public StaggerSameWholeNotes: boolean;
public MaxInstructionsConstValue: number;
public NoteDistances: number[] = [1.0, 1.0, 1.3, 1.6, 2.0, 2.5, 3.0, 4.0];
public NoteDistancesScalingFactors: number[] = [1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0];
public DurationDistanceDict: {[_: number]: number } = {};
public DurationScalingDistanceDict: {[_: number]: number } = {};
/** Whether to align rests. 0 = Never, 1 = Always, 2 = Auto.
* Currently not recommended because rests are now positioned to avoid collisions with notes. */
public AlignRests: AlignRestOption; // 0 = false, 1 = true, 2 = auto
public RestCollisionYPadding: number;
public FillEmptyMeasuresWithWholeRest: FillEmptyMeasuresWithWholeRests | number;
public ArpeggiosGoAcrossVoices: boolean;
public RenderArpeggios: boolean;
public RenderSlurs: boolean;
public RenderGlissandi: boolean;
public ColoringMode: ColoringMode;
public ColoringEnabled: boolean;
public ColorStemsLikeNoteheads: boolean;
public ColorFlags: boolean;
public ColorBeams: boolean;
public ColoringSetCurrent: Dictionary<NoteEnum|number, string>;
/** Default color for all musical elements including key signature etc. Default undefined. */
public DefaultColorMusic: string;
public DefaultColorNotehead: string;
public DefaultColorRest: string;
public DefaultColorStem: string;
public DefaultColorLabel: string;
public DefaultColorLyrics: string;
public DefaultColorChordSymbol: string;
public DefaultColorTitle: string;
public DefaultColorCursor: string;
public DefaultFontFamily: string;
public DefaultFontStyle: FontStyles;
public DefaultVexFlowNoteFont: string;
public MaxMeasureToDrawIndex: number;
public MinMeasureToDrawIndex: number;
public MaxPageToDrawNumber: number;
public MaxSystemToDrawNumber: number;
/** Whether to render a label for the composer of the piece at the top of the sheet. */
public RenderComposer: boolean;
public RenderTitle: boolean;
public RenderSubtitle: boolean;
public RenderLyricist: boolean;
public RenderCopyright: boolean;
public RenderPartNames: boolean;
public RenderPartAbbreviations: boolean;
/** Whether two render system labels on page 2+. This doesn't affect the default endless PageFormat. */
public RenderSystemLabelsAfterFirstPage: boolean;
public RenderFingerings: boolean;
public RenderMeasureNumbers: boolean;
public RenderMeasureNumbersOnlyAtSystemStart: boolean;
public UseXMLMeasureNumbers: boolean;
public RenderLyrics: boolean;
public RenderChordSymbols: boolean;
public RenderMultipleRestMeasures: boolean;
public AutoGenerateMultipleRestMeasuresFromRestMeasures: boolean;
public RenderRehearsalMarks: boolean;
public RenderClefsAtBeginningOfStaffline: boolean;
public RenderKeySignatures: boolean;
public RenderTimeSignatures: boolean;
public RenderPedals: boolean;
public DynamicExpressionMaxDistance: number;
public DynamicExpressionSpacer: number;
public IgnoreRepeatedDynamics: boolean;
public ExpressionsUseXMLColor: boolean;
public ArticulationPlacementFromXML: boolean;
/** Percent distance of breath marks to next note or end of staff, e.g. 0.8 = 80%. */
public BreathMarkDistance: number;
/** Where to draw fingerings (Above, Below, AboveOrBelow, Left, Right, or Auto).
* Default AboveOrBelow. Auto experimental. */
public FingeringPosition: PlacementEnum;
public FingeringPositionFromXML: boolean;
public FingeringPositionGrace: PlacementEnum;
public FingeringInsideStafflines: boolean;
public FingeringLabelFontHeight: number;
public FingeringOffsetX: number;
public FingeringOffsetY: number;
public FingeringPaddingY: number;
public FingeringTextSize: number;
/** Whether to render string numbers in classical scores, i.e. not the string numbers in tabs, but e.g. for violin. */
public RenderStringNumbersClassical: boolean;
/** This is not for tabs, but for classical scores, especially violin. */
public StringNumberOffsetY: number;
public NewSystemAtXMLNewSystemAttribute: boolean;
/** Whether to begin a new system when a page break is given in XML ('new-page="yes"'), but newPageFromXML is false.
* Default false, because it can lead to nonsensical system breaks after a single measure,
* as OSMD does a different layout than the original music program exported from.
* */
public NewSystemAtXMLNewPageAttribute: boolean;
public NewPageAtXMLNewPageAttribute: boolean;
public PageFormat: PageFormat;
public PageBackgroundColor: string; // vexflow-color-string (#FFFFFF). Default undefined/transparent.
public RenderSingleHorizontalStaffline: boolean;
public RestoreCursorAfterRerender: boolean;
public StretchLastSystemLine: boolean;
/** Ignore brackets - e.g. `( )` - that were supposed to be around a note,
* but were inserted as a words element in the MusicXML, which can't be matched to the note anymore,
* and would otherwise just be placed somewhere else. See OSMD Issue 1251. */
public IgnoreBracketsWords: boolean;
public PlaceWordsInsideStafflineFromXml: boolean;
public PlaceWordsInsideStafflineYOffset: number;
// public PositionMarcatoCloseToNote: boolean;
public SpacingBetweenTextLines: number;
public NoteToGraphicalNoteMap: Dictionary<number, GraphicalNote>;
// this is basically a WeakMap, except we save the id in the Note instead of using a WeakMap.
public NoteToGraphicalNoteMapObjectCount: number = 0;
/** How many times osmd.render() was already called on the currently loaded score.
* Resets after osmd.load() (via osmd.reset()).
* Can be relevant for transposition or generally informative.
*/
public RenderCount: number = 0;
/** The skyline and bottom-line batch calculation algorithm to use.
* Note that this can be overridden if AlwaysSetPreferredSkyBottomLineBackendAutomatically is true (which is the default).
*/
public PreferredSkyBottomLineBatchCalculatorBackend: SkyBottomLineBatchCalculatorBackendType;
/** Whether to consider using WebGL in Firefox in EngravingRules.setPreferredSkyBottomLineBackendAutomatically() */
public DisableWebGLInFirefox: boolean;
/** Whether to consider using WebGL in Safari/iOS in EngravingRules.setPreferredSkyBottomLineBackendAutomatically() */
public DisableWebGLInSafariAndIOS: boolean;
/** The minimum number of measures in the sheet where the skyline and bottom-line batch calculation is enabled.
* Batch is faster for medium to large size scores, but slower for very short scores.
*/
public SkyBottomLineBatchMinMeasures: number;
/** The minimum number of measures in the sheet where WebGL will be used. WebGL is slower for short scores, but much faster for large ones.
* Note that WebGL is currently never used in Safari and Firefox, because it's always slower there.
*/
public SkyBottomLineWebGLMinMeasures: number;
/** Whether to always set preferred backend (WebGL or Plain) automatically, depending on browser and number of measures. */
public AlwaysSetPreferredSkyBottomLineBackendAutomatically: boolean;
constructor() {
this.loadDefaultValues();
}
public loadDefaultValues(): void {
// global variables
this.SamplingUnit = EngravingRules.unit * 3;
// Page Label Variables
this.SheetTitleHeight = 4.0;
this.SheetSubtitleHeight = 2.0;
this.SheetMinimumDistanceBetweenTitleAndSubtitle = 1.0;
this.SheetComposerHeight = 2.0;
this.SheetAuthorHeight = 2.0;
this.SheetCopyrightHeight = 1.5;
this.SheetCopyrightMargin = 2.0;
this.SheetComposerSubtitleUseLegacyParsing = false;
// Staff sizing Variables
this.CompactMode = false;
this.PagePlacementEnum = PagePlacementEnum.Down;
this.PageHeight = 100001.0;
this.PageTopMargin = 5.0;
this.PageTopMarginNarrow = 0.0; // for compact mode
this.PageBottomMargin = 5.0;
this.PageLeftMargin = 5.0;
this.PageRightMargin = 5.0;
this.TitleTopDistance = 5.0;
this.TitleBottomDistance = 1.0;
this.StaffDistance = 7.0;
this.BetweenStaffDistance = 5.0;
this.MinimumStaffLineDistance = 4.0;
this.MinSkyBottomDistBetweenStaves = 1.0; // default. compacttight mode sets it to 1.0 (as well).
// System Sizing and Label Variables
this.StaffHeight = 4.0;
this.TabStaffInterlineHeight = 1.1111;
this.BetweenStaffLinesDistance = EngravingRules.unit;
this.SystemLeftMargin = 0.0;
this.SystemRightMargin = 0.0;
this.SystemLabelsRightMargin = 2.0;
this.SystemComposerDistance = 2.0;
this.SystemLyricistDistance = 2.0;
this.InstrumentLabelTextHeight = 2;
this.MinimumDistanceBetweenSystems = 7.0;
this.MinSkyBottomDistBetweenSystems = 5.0;
this.LastSystemMaxScalingFactor = 1.4;
// autoBeam options
this.AutoBeamNotes = false;
this.AutoBeamOptions = {
beam_middle_rests_only: false,
beam_rests: false,
maintain_stem_directions: false
};
this.AutoBeamTabs = false;
// Beam Sizing Variables
this.BeamWidth = EngravingRules.unit / 2.0;
this.BeamSpaceWidth = EngravingRules.unit / 3.0;
this.BeamForwardLength = 1.25 * EngravingRules.unit;
this.FlatBeams = false;
this.FlatBeamOffset = 20;
this.FlatBeamOffsetPerBeam = 10;
// Beam Sizing Variables
this.ClefLeftMargin = 0.5;
this.ClefRightMargin = 0.75;
this.PercussionOneLineCutoff = 3; // percussion parts with <3 unique note positions rendered on one line
this.PercussionForceVoicesOneLineCutoff = 1;
this.PercussionUseXMLDisplayStep = true;
this.PercussionXMLDisplayStepNoteValueShift = 0;
this.PercussionOneLineXMLDisplayStepOctaveOffset = 0;
this.PercussionUseCajon2NoteSystem = false;
this.BetweenKeySymbolsDistance = 0.2;
this.KeyRightMargin = 0.75;
this.RhythmRightMargin = 1.25;
this.ShowRhythmAgainAfterPartEndOrFinalBarline = true;
this.NewPartAndSystemAfterFinalBarline = false;
this.InStaffClefScalingFactor = 0.8;
this.DistanceBetweenNaturalAndSymbolWhenCancelling = 0.4;
// Beam Sizing Variables
this.NoteHelperLinesOffset = 0.25;
this.MeasureLeftMargin = 0.7;
this.MeasureRightMargin = 0.0;
this.DistanceBetweenLastInstructionAndRepetitionBarline = 1.0;
this.ArpeggioDistance = 0.6;
// Stems Variables
this.StaccatoShorteningFactor = 2;
this.IdealStemLength = 3.0;
this.StemNoteHeadBorderYOffset = 0.2;
this.StemMargin = 0.2;
this.StemMinLength = 2.5;
this.StemMaxLength = 4.5;
this.BeamSlopeMaxAngle = 10.0;
this.StemMinAllowedDistanceBetweenNoteHeadAndBeamLine = 1.0;
this.SetWantedStemDirectionByXml = true;
// also see stemwidth further below
// GraceNote Variables
this.GraceNoteScalingFactor = 0.6;
this.GraceNoteXOffset = 0.2;
this.GraceNoteGroupXMargin = 0.0; // More than 0 leads to too much space in most cases.
// see test_end_clef_measure. only potential 'tight' case: test_graceslash_simple
// Wedge Variables
this.WedgeOpeningLength = 1.2;
this.WedgeMeasureEndOpeningLength = 0.75;
this.WedgeMeasureBeginOpeningLength = 0.75;
this.WedgePlacementAboveY = -1.5;
this.WedgePlacementBelowY = 1.5;
this.WedgeHorizontalMargin = 0.6;
this.WedgeVerticalMargin = 0.5;
this.DistanceOffsetBetweenTwoHorizontallyCrossedWedges = 0.3;
this.WedgeMinLength = 2.0;
this.WedgeEndDistanceBetweenTimestampsFactor = 1.75;
this.SoftAccentWedgePadding = 0.4;
this.SoftAccentSizeFactor = 0.6;
this.DistanceBetweenAdjacentDynamics = 0.75;
// Tempo Variables
this.TempoChangeMeasureValidity = 4;
this.TempoContinousFactor = 0.7;
// various
this.StaccatoScalingFactor = 0.8;
this.BetweenDotsDistance = 0.8;
this.OrnamentAccidentalScalingFactor = 0.65;
this.ChordSymbolTextHeight = 2.0;
this.ChordSymbolTextAlignment = TextAlignmentEnum.LeftBottom;
this.ChordSymbolRelativeXOffset = -1.0;
this.ChordSymbolExtraXShiftForShortChordSymbols = 0.3; // also see LyricsExtraXShiftForShortLyrics, same principle
this.ChordSymbolExtraXShiftWidthThreshold = 2.0;
this.ChordSymbolXSpacing = 1.0;
this.ChordOverlapAllowedIntoNextMeasure = 0;
this.ChordSymbolYOffset = 0.1;
this.ChordSymbolYPadding = 0.0;
this.ChordSymbolYAlignment = true;
this.ChordSymbolYAlignmentScope = "staffline"; // "measure" or "staffline"
this.ChordSymbolWholeMeasureRestXOffset = 0;
this.ChordSymbolWholeMeasureRestXOffsetMeasure1 = -2.0;
this.ChordAccidentalTexts = new Dictionary<AccidentalEnum, string>();
this.resetChordAccidentalTexts(this.ChordAccidentalTexts, false);
this.ChordSymbolLabelTexts = new Dictionary<ChordSymbolEnum, string>();
this.resetChordSymbolLabelTexts(this.ChordSymbolLabelTexts);
this.CustomChords = [];
this.resetChordNames();
this.RepetitionSymbolsYOffset = 0;
this.RepetitionEndInstructionXShiftAsPercentOfStaveWidth = 0.4; // 40%
this.RehearsalMarkXOffsetDefault = 10; // avoid collision with metronome number
this.RehearsalMarkXOffset = 0; // user defined
this.RehearsalMarkXOffsetSystemStartMeasure = -20; // good test: Haydn Concertante
this.RehearsalMarkYOffsetDefault = -15;
this.RehearsalMarkYOffset = 0; // user defined
this.RehearsalMarkFontSize = 10; // vexflow default: 12, too big with chord symbols
// Tuplets, MeasureNumber and TupletNumber Labels
this.MeasureNumberLabelHeight = 1.5 * EngravingRules.unit;
this.MeasureNumberLabelOffset = 2;
this.MeasureNumberLabelXOffset = -0.5;
this.TupletsRatioed = false;
this.TupletsBracketed = false;
this.TripletsBracketed = false; // special setting for triplets, overrides tuplet setting (for triplets only)
this.TupletsBracketedUseXMLValue = true;
this.TupletNumberLabelHeight = 1.5 * EngravingRules.unit;
this.TupletNumberYOffset = 0.5;
this.TupletNumberLimitConsecutiveRepetitions = true;
this.TupletNumberMaxConsecutiveRepetitions = 2;
this.TupletNumberAlwaysDisableAfterFirstMax = true;
this.TupletNumberUseShowNoneXMLValue = true;
this.LabelMarginBorderFactor = 0.1;
this.TupletVerticalLineLength = 0.5;
this.TupletNumbersInTabs = true; // disabled by default, nonstandard in tabs, at least how we show them in non-tabs.
this.TabTupletYOffsetBottom = 1.0; // OSMD units
this.TabTupletYOffsetTop = -3.5; // -3.5 is fine if you don't have effects like bends on top. Otherwise, e.g. -2 avoids overlaps.
this.TabTupletYOffsetEffects = 1.5;
this.TabTupletsBracketed = true;
this.TabBeamsRendered = true;
this.TabKeySignatureRendered = false; // standard not to render for tab scores
this.TabKeySignatureSpacingAdded = true; // false only works for tab-only scores, as it will prevent vertical x-alignment.
this.TabTimeSignatureRendered = false; // standard not to render for tab scores
this.TabTimeSignatureSpacingAdded = true; // false only works for tab-only scores, as it will prevent vertical x-alignment.
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;
this.SlurPlacementAtStems = false;
this.SlurPlacementUseSkyBottomLine = false;
this.BezierCurveStepSize = 1000;
this.calculateCurveParametersArrays();
this.TieGhostObjectWidth = 0.75;
this.TieYPositionOffsetFactor = 0.3;
this.MinimumNeededXspaceForTieGhostObject = 1.0;
this.TieHeightMinimum = 0.28;
this.TieHeightMaximum = 1.2;
this.TieHeightInterpolationK = 0.0288;
this.TieHeightInterpolationD = 0.136;
this.SlurNoteHeadYOffset = 0.5;
this.SlurEndArticulationYOffset = 0.8;
this.SlurStartArticulationYOffsetOfArticulation = 0.5;
this.SlurStemXOffset = 0.3;
this.SlurSlopeMaxAngle = 15.0;
this.SlurTangentMinAngle = 30.0;
this.SlurTangentMaxAngle = 80.0;
this.SlurHeightFactor = 1; // 1 = 100% (standard height). 2 = 100% flattening of all slurs.
this.SlurHeightFlattenLongSlursFactorByWidth = 0.24; // additional flattening for long slurs the longer they are.
this.SlurHeightFlattenLongSlursFactorByAngle = 0.36; // when one of these factors is high, increasing the other has a very strong effect.
this.SlurHeightFlattenLongSlursCutoffAngle = 47;
this.SlurHeightFlattenLongSlursCutoffWidth = 16; // 15 ~ slur between measure's first notes in 4/4. 14 -> problem with test_slurs_highNotes
this.SlursStartingAtSameStaffEntryYOffset = 0.8;
//Maximum y difference between control points. Forces slurs to have less 'weight' either way in the x direction
this.SlurMaximumYControlPointDistance = undefined;
// Glissandi
this.GlissandoNoteOffset = 0.5;
this.GlissandoStafflineStartMinimumWidth = 1;
this.GlissandoStafflineStartYDistanceToNote = 0.8; // just crossing the line above/below end note. should be similar to tab slide angle.
this.GlissandoStafflineEndOffset = 1;
this.GlissandoDefaultWidth = 0.1;
// Repetitions
this.RepetitionAllowFirstMeasureBeginningRepeatBarline = true;
this.RepetitionEndingLabelHeight = 2.0;
this.RepetitionEndingLabelXOffset = 0.5;
this.RepetitionEndingLabelYOffset = 0.3;
this.RepetitionEndingLineYLowerOffset = 0.5;
this.RepetitionEndingLineYUpperOffset = 0.3;
this.VoltaOffset = 2.5;
// Lyrics
this.LyricsAlignmentStandard = TextAlignmentEnum.LeftBottom; // CenterBottom and LeftBottom tested, spacing-optimized
this.LyricsHeight = 2.0; // actually size of lyrics
this.LyricsYOffsetToStaffHeight = 0.0; // distance between lyrics and staff. could partly be even lower/dynamic
this.LyricsYMarginToBottomLine = 0.2;
this.LyricsExtraXShiftForShortLyrics = 0.5; // also see ChordSymbolExtraXShiftForShortChordSymbols, same principle
this.LyricsExtraXShiftForShortLyricsWidthThreshold = 1.4; // width of '+': 1.12, 'II': 1.33 (benefits from x-shift), 'III': 1.99 (doesn't benefit)
this.LyricsUseXPaddingForLongLyrics = true;
this.LyricsXPaddingFactorForLongLyrics = 1.0;
this.LyricsXPaddingWidthThreshold = 1.7; // generateImages script with png might need more for 8th notes, e.g. Chloe
this.LyricsXPaddingReductionForLongNotes = 0.7;
this.LyricsXPaddingReductionForLastNoteInMeasure = 1.2;
this.LyricsXPaddingForLastNoteInMeasure = true;
this.VerticalBetweenLyricsDistance = 0.5;
this.HorizontalBetweenLyricsDistance = 0.2;
this.BetweenSyllableMaximumDistance = 10.0;
this.BetweenSyllableMinimumDistance = 0.5; // + 1.0 for CenterAlignment added in lyrics spacing
this.LyricOverlapAllowedIntoNextMeasure = 3.4; // optimal for dashed last lyric, see Land der Berge
this.MinimumDistanceBetweenDashes = 10;
this.MaximumLyricsElongationFactor = 2.5;
// expressions variables
this.TempoYSpacing = 0.5; // note this is correlated with MetronomeMarkYShift: one-sided change can cause collisions
this.InstantaneousTempoTextHeight = 2.3;
this.ContinuousDynamicTextHeight = 2.3;
this.UseEndOffsetForExpressions = true;
this.MoodTextHeight = 2.3;
this.UnknownTextHeight = 2.0;
this.ContinuousTempoTextHeight = 2.3;
this.DynamicExpressionMaxDistance = 2;
this.DynamicExpressionSpacer = 0.5;
this.IgnoreRepeatedDynamics = false;
this.ExpressionsUseXMLColor = true;
// Line Widths
this.VexFlowDefaultNotationFontScale = 39; // scales notes, including rests. default value 39 in Vexflow.
this.VexFlowDefaultTabFontScale = 39;
this.TremoloStrokeScale = 1;
this.TremoloYSpacingScale = 1;
this.TremoloBuzzRollThickness = 0.25;
this.StemWidth = 0.15; // originally 0.13. vexflow default 0.15. should probably be adjusted when increasing vexFlowDefaultNotationFontScale,
this.StaffLineWidth = 0.10; // originally 0.12, but this will be pixels in Vexflow (*10).
this.StaffLineColor = undefined; // if undefined, vexflow default (grey). not a width, but affects visual line clarity.
this.LedgerLineWidth = 1; // vexflow units (pixels). if not undefined, the vexflow default will be overwritten
this.LedgerLineStrokeStyle = undefined; // if not undefined, the vexflow default will be overwritten
this.LedgerLineColorDefault = "#000000"; // black, previously grey by default
this.WedgeLineWidth = 0.12;
this.TupletLineWidth = 0.12;
this.LyricUnderscoreLineWidth = 0.12;
this.SystemThinLineWidth = 0.12;
this.SystemBoldLineWidth = EngravingRules.unit / 2.0;
this.SystemRepetitionEndingLineWidth = 0.12;
this.SystemDotWidth = EngravingRules.unit / 2.0;
this.DistanceBetweenVerticalSystemLines = 0.35;
this.DistanceBetweenDotAndLine = 0.7;
this.RepeatEndStartPadding = 2.0; // set to 0.0 to restore old padding/width with :||: measures
this.OctaveShiftLineWidth = 0.12;
this.OctaveShiftVerticalLineLength = EngravingRules.unit;
this.OctaveShiftOnWholeMeasureNoteUntilEndOfMeasure = false;
this.GraceLineWidth = this.StaffLineWidth * this.GraceNoteScalingFactor;
this.MultipleRestMeasureDefaultWidth = 4;
this.MultipleRestMeasureAddKeySignature = true;
this.FixedMeasureWidth = false;
this.FixedMeasureWidthFixedValue = undefined; // only set to a number x if the width should be always x
this.FixedMeasureWidthUseForPickupMeasures = false;
// Line Widths
this.MinimumCrossedBeamDifferenceMargin = 0.0001;
// Canvas is limited to 32767 in most browsers, though SVG isn't.
this.SheetMaximumWidth = 32767;
// xSpacing Variables
this.VoiceSpacingMultiplierVexflow = 0.85;
this.VoiceSpacingAddendVexflow = 3.0;
this.PickupMeasureWidthMultiplier = 1.0;
this.PickupMeasureRepetitionSpacing = 0.8;
this.PickupMeasureSpacingSingleNoteAddend = 1.6;
this.DisplacedNoteMargin = 0.1;
this.MinNoteDistance = 2.0;
this.SubMeasureXSpacingThreshold = 35;
this.MeasureDynamicsMaxScalingFactor = 2.5;
this.WholeRestXShiftVexflow = -1.5; // VexFlow draws rest notes too far to the right
this.MetronomeMarksDrawn = true;
this.MetronomeMarkXShift = -6; // our unit, is taken * unitInPixels
this.MetronomeMarkYShift = -1.0; // note this is correlated with TempoYSpacing: one-sided change can cause collisions
this.SoftmaxFactorVexFlow = 15; // only applies to Vexflow 3.x. 15 seems like the sweet spot. Vexflow default is 100.
// if too high, score gets too big, especially half notes. with half note quarter quarter, the quarters get squeezed.
// if too low, smaller notes aren't positioned correctly.
this.StaggerSameWholeNotes = true;
// Render options (whether to render specific or invisible elements)
this.AlignRests = AlignRestOption.Never; // 0 = false, 1 = true, 2 = auto
this.RestCollisionYPadding = 0.0; // 1.0 = half distance between staff lines (e.g. E to F). will be rounded to whole numbers.
this.FillEmptyMeasuresWithWholeRest = FillEmptyMeasuresWithWholeRests.No;
this.ArpeggiosGoAcrossVoices = false; // safe option, as otherwise arpeggios will always go across all voices in Vexflow, which is often unwanted
this.RenderArpeggios = true;
this.RenderSlurs = true;
this.RenderGlissandi = true;
this.ColoringMode = ColoringMode.XML;
this.ColoringEnabled = true;
this.ColorStemsLikeNoteheads = false;
this.ColorBeams = true;
this.ColorFlags = true;
this.applyDefaultColorMusic("#000000"); // black. undefined is only black if a note's color hasn't been changed before.
this.DefaultColorCursor = "#33e02f"; // green
this.DefaultFontFamily = "Times New Roman"; // what OSMD was initially optimized for
this.DefaultFontStyle = FontStyles.Regular;
this.DefaultVexFlowNoteFont = "gonville"; // was the default vexflow font up to vexflow 1.2.93, now it's Bravura, which is more cursive/bold
this.MaxMeasureToDrawIndex = Number.MAX_VALUE;
this.MinMeasureToDrawIndex = 0;
this.MaxSystemToDrawNumber = Number.MAX_VALUE;
this.MaxPageToDrawNumber = Number.MAX_VALUE;
this.RenderComposer = true;
this.RenderTitle = true;
this.RenderSubtitle = true;
this.RenderLyricist = true;
this.RenderCopyright = false;
this.RenderPartNames = true;
this.RenderPartAbbreviations = true;
this.RenderSystemLabelsAfterFirstPage = true;
this.RenderFingerings = true;
this.RenderMeasureNumbers = true;
this.RenderMeasureNumbersOnlyAtSystemStart = false;
this.UseXMLMeasureNumbers = true;
this.RenderLyrics = true;
this.RenderChordSymbols = true;
this.RenderMultipleRestMeasures = true;
this.AutoGenerateMultipleRestMeasuresFromRestMeasures = true;
this.RenderRehearsalMarks = true;
this.RenderClefsAtBeginningOfStaffline = true;
this.RenderKeySignatures = true;
this.RenderTimeSignatures = true;
this.RenderPedals = true;
this.ArticulationPlacementFromXML = true;
this.BreathMarkDistance = 0.8;
this.FingeringPosition = PlacementEnum.AboveOrBelow; // AboveOrBelow = correct bounding boxes
this.FingeringPositionFromXML = true;
this.FingeringPositionGrace = PlacementEnum.Left;
this.FingeringInsideStafflines = false;
this.FingeringLabelFontHeight = 1.7;
this.FingeringOffsetX = 0.0;
this.FingeringOffsetY = 0.0;
this.FingeringPaddingY = -0.2;
this.FingeringTextSize = 1.5;
this.RenderStringNumbersClassical = true;
this.StringNumberOffsetY = 0.0;
this.NewSystemAtXMLNewSystemAttribute = false;
this.NewPageAtXMLNewPageAttribute = false;
this.NewSystemAtXMLNewPageAttribute = false;
this.RestoreCursorAfterRerender = true;
this.StretchLastSystemLine = false;
this.IgnoreBracketsWords = true;
this.PlaceWordsInsideStafflineFromXml = false;
this.PlaceWordsInsideStafflineYOffset = 0.9;
// this.PositionMarcatoCloseToNote = true;
this.PageFormat = PageFormat.UndefinedPageFormat; // default: undefined / 'infinite' height page, using the canvas'/container's width and height
this.PageBackgroundColor = undefined; // default: transparent. half-transparent white: #FFFFFF88"
this.RenderSingleHorizontalStaffline = false;
this.SpacingBetweenTextLines = 0;
this.NoteToGraphicalNoteMap = new Dictionary<number, GraphicalNote>();
this.NoteToGraphicalNoteMapObjectCount = 0;
this.SkyBottomLineBatchMinMeasures = 5;
this.SkyBottomLineWebGLMinMeasures = 80;
this.AlwaysSetPreferredSkyBottomLineBackendAutomatically = true;
this.DisableWebGLInFirefox = true;
this.DisableWebGLInSafariAndIOS = true;
this.setPreferredSkyBottomLineBackendAutomatically();
// this.populateDictionaries(); // these values aren't used currently
try {
this.MaxInstructionsConstValue = this.ClefLeftMargin + this.ClefRightMargin + this.KeyRightMargin + this.RhythmRightMargin + 11;
//if (FontInfo.Info) {
// this.maxInstructionsConstValue += FontInfo.Info.getBoundingBox(MusicSymbol.G_CLEF).width
// + FontInfo.Info.getBoundingBox(MusicSymbol.FOUR).width
// + 7 * FontInfo.Info.getBoundingBox(MusicSymbol.SHARP).width;
//}
} catch (ex) {
log.info("EngravingRules()", ex);
}
}
public setPreferredSkyBottomLineBackendAutomatically(numberOfGraphicalMeasures: number = -1): void {
let vendor: string = "";
let userAgent: string = "";
if (typeof globalThis === "object") { // it looks like globalThis can be undefined and cause build issues in es2017 (e.g. Android API 28), see #1299
vendor = globalThis.navigator?.vendor ?? "";
userAgent = globalThis.navigator?.userAgent ?? "";
}
let alwaysUsePlain: boolean = false;
if (this.DisableWebGLInSafariAndIOS && (/apple/i).test(vendor)) { // doesn't apply to Chrome on MacOS
alwaysUsePlain = true;
} else if (this.DisableWebGLInFirefox && userAgent.includes("Firefox")) {
alwaysUsePlain = true;
}
// In Safari (/iOS) and Firefox, the plain version is always faster (currently, Safari 15).
// WebGL is faster for large scores in Chrome and Edge (both Chromium based). See #1158
this.PreferredSkyBottomLineBatchCalculatorBackend = SkyBottomLineBatchCalculatorBackendType.Plain;
if (!alwaysUsePlain) {
if (numberOfGraphicalMeasures >= this.SkyBottomLineWebGLMinMeasures) {
this.PreferredSkyBottomLineBatchCalculatorBackend = SkyBottomLineBatchCalculatorBackendType.WebGL;
}
}
}
/** Makes it so that all musical elements (including key/time signature)
* are colored with the given color by default,
* unless an element has a different color set (e.g. VoiceEntry.StemColor).
*/
public applyDefaultColorMusic(color: string): void {
this.DefaultColorMusic = color;
this.DefaultColorNotehead = color;
this.DefaultColorRest = color;
this.DefaultColorStem = color;
this.DefaultColorLabel = color;
this.DefaultColorLyrics = color;
this.DefaultColorTitle = color;
this.LedgerLineColorDefault = color;
}
public addGraphicalNoteToNoteMap(note: Note, graphicalNote: GraphicalNote): void {
note.NoteToGraphicalNoteObjectId = this.NoteToGraphicalNoteMapObjectCount;
this.NoteToGraphicalNoteMap.setValue(note.NoteToGraphicalNoteObjectId, graphicalNote);
this.NoteToGraphicalNoteMapObjectCount++;
}
/** Returns the GraphicalNote corresponding to (its) note. Also used by Cursor.GNotesUnderCursor().
* We don't want to save a GraphicalNote reference in Note, see Note.NoteToGraphicalNoteObjectId.
*/
public GNote(note: Note): GraphicalNote {
return GraphicalNote.FromNote(note, this);
}
/** This should be done before a new sheet is loaded, not each re-render (otherwise the map would end empty). */
public clearMusicSheetObjects(): void {
this.NoteToGraphicalNoteMap = new Dictionary<number, GraphicalNote>();
this.NoteToGraphicalNoteMapObjectCount = 0;
}
public resetChordAccidentalTexts(chordAccidentalTexts: Dictionary<AccidentalEnum, string>, useChordAccidentalsUnicode: boolean): void {
chordAccidentalTexts.setValue(AccidentalEnum.SHARP, useChordAccidentalsUnicode ? "♯" : "#");
chordAccidentalTexts.setValue(AccidentalEnum.FLAT, useChordAccidentalsUnicode ? "♭" : "b");
chordAccidentalTexts.setValue(AccidentalEnum.DOUBLEFLAT, useChordAccidentalsUnicode ? "𝄫" : "bb");
chordAccidentalTexts.setValue(AccidentalEnum.DOUBLESHARP, useChordAccidentalsUnicode ? "𝄪" : "x");
}
public setChordSymbolLabelText(key: ChordSymbolEnum, value: string): void {
this.ChordSymbolLabelTexts.setValue(key, value);
}
public resetChordSymbolLabelTexts(chordtexts: Dictionary<ChordSymbolEnum, string>): Dictionary<ChordSymbolEnum, string> {