OSMDOptions.ts 5.8 KB

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