OSMDOptions.ts 5.5 KB

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