OSMDOptions.ts 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { DrawingParametersEnum, ColoringModes } from "../MusicalScore/Graphical/DrawingParameters";
  2. /** Possible options for the OpenSheetMusicDisplay constructor, none are mandatory. */
  3. export interface IOSMDOptions {
  4. /** Whether to automatically create beams for notes that don't have beams set in XML. */
  5. autoBeam?: boolean;
  6. /** Options for autoBeaming like whether to beam over rests. See AutoBeamOptions interface. */
  7. autoBeamOptions?: AutoBeamOptions;
  8. /** Automatically resize score with canvas size. Default is true. */
  9. autoResize?: boolean;
  10. /** Render Backend, will be SVG if given undefined, SVG or svg, otherwise Canvas. */
  11. backend?: string;
  12. /** Defines the mode that is used for coloring: XML, Boomwhacker. Default XML (0).
  13. * If coloringMode.CustomColorSet (2) is chosen, a coloringSetCustom parameter must be added.
  14. */
  15. coloringMode?: ColoringModes;
  16. /** Set of 7 colors for automatic coloring of notes from C to B in HTML form (e.g. #00ff00). */
  17. coloringSetCustom?: string[];
  18. /** Whether to enable coloring noteheads and stems by their XML color attribute. */
  19. coloringEnabled?: boolean;
  20. /** Default color for a note head (without stem). Default black (undefined). */
  21. defaultColorNotehead?: string;
  22. /** Default color for a note stem. Default black (undefined). */
  23. defaultColorStem?: string;
  24. /** Default color for rests. Default black (undefined). */
  25. defaultColorRest?: string;
  26. /** Default color for Labels like title or lyrics. Default black (undefined). */
  27. defaultColorLabel?: string;
  28. /** Default color for labels in the title. Overrides defaultColorLabel for title labels like composer. Default black (undefined). */
  29. defaultColorTitle?: string;
  30. /** Don't show/load cursor. Will override disableCursor in drawingParameters. */
  31. disableCursor?: boolean;
  32. /** Broad Parameters like compact or preview mode. */
  33. drawingParameters?: string | DrawingParametersEnum;
  34. /** Whether to draw the title of the piece. If false, disables drawing Subtitle as well. */
  35. drawTitle?: boolean;
  36. /** Whether to draw the subtitle of the piece. If true, enables drawing Title as well. */
  37. drawSubtitle?: boolean;
  38. /** Whether to draw credits (title, composer, arranger, copyright etc., see <credit>. Not yet supported. */ // TODO
  39. drawCredits?: boolean;
  40. /** Whether to draw the lyricist's name, if given. */
  41. drawLyricist?: boolean;
  42. /** Whether to draw part (instrument) names. */
  43. drawPartNames?: boolean;
  44. /** Whether to draw part (instrument) name abbreviations each system after the first. Only draws if drawPartNames. Default true. */
  45. drawPartAbbreviations?: boolean;
  46. /** Whether to draw fingerings (only left to the note for now). Default true (unless solo part). */
  47. drawFingerings?: boolean;
  48. /** Where to draw fingerings (left, right, above, below, auto).
  49. * Default left. Auto, above, below experimental (potential collisions because bounding box not correct)
  50. */
  51. fingeringPosition?: string;
  52. /** For above/below fingerings, whether to draw them directly above/below notes (default), or above/below staffline. */
  53. fingeringInsideStafflines?: boolean;
  54. /** Only draw measure 1 to n, where n is the number you specify. */
  55. drawUpToMeasureNumber?: number;
  56. /** Whether to set the wanted stem direction by xml (default) or automatically. */
  57. setWantedStemDirectionByXml?: boolean;
  58. /** Whether tuplets are labeled with ratio (e.g. 5:2 instead of 5 for quintuplets). Default false. */
  59. tupletsRatioed?: boolean;
  60. /** Whether all tuplets should be bracketed (e.g. |--5--| instead of 5). Default false.
  61. * If false, only tuplets given as bracketed in XML (bracket="yes") will be bracketed.
  62. */
  63. tupletsBracketed?: boolean;
  64. /** Whether all triplets should be bracketed. Overrides tupletsBracketed for triplets.
  65. * If false, only triplets given as bracketed in XML (bracket="yes") will be bracketed.
  66. * (Bracketing all triplets can be cluttering)
  67. */
  68. tripletsBracketed?: boolean;
  69. /** Whether to draw hidden/invisible notes (print-object="no" in XML). Default false. Not yet supported. */ // TODO
  70. drawHiddenNotes?: boolean;
  71. }
  72. /** Handles [[IOSMDOptions]], e.g. returning default options with OSMDOptionsStandard() */
  73. export class OSMDOptions {
  74. /** Returns the default options for OSMD.
  75. * These are e.g. used if no options are given in the [[OpenSheetMusicDisplay]] constructor.
  76. */
  77. public static OSMDOptionsStandard(): IOSMDOptions {
  78. return {
  79. autoResize: true,
  80. backend: "svg",
  81. drawingParameters: DrawingParametersEnum.default,
  82. };
  83. }
  84. }
  85. export interface AutoBeamOptions {
  86. /** Whether to extend beams over rests. Default false. */
  87. beam_rests?: boolean;
  88. /** Whether to extend beams only over rests that are in the middle of a potential beam. Default false. */
  89. beam_middle_rests_only?: boolean;
  90. /** Whether to maintain stem direction of autoBeamed notes. Discouraged, reduces beams. Default false. */
  91. maintain_stem_directions?: boolean;
  92. /** Groups of notes (fractions) to beam within a measure.
  93. * List of fractions, each fraction being [nominator, denominator].
  94. * E.g. [[3,4],[1,4]] will beam the first 3 quarters of a measure, then the last quarter.
  95. */
  96. groups?: [number[]];
  97. }