Class OpenSheetMusicDisplay

The main class and control point of OpenSheetMusicDisplay.
It can display MusicXML sheet music files in an HTML element container.
After the constructor, use load() and render() to load and render a MusicXML file.

Hierarchy

  • OpenSheetMusicDisplay

Constructors

  • Creates and attaches an OpenSheetMusicDisplay object to an HTML element container.
    After the constructor, use load() and render() to load and render a MusicXML file.

    Parameters

    • container: string | HTMLElement

      The container element OSMD will be rendered into.
      Either a string specifying the ID of an HTML container element,
      or a reference to the HTML element itself (e.g. div)

    • Optional options: IOSMDOptions

      An object for rendering options like the backend (svg/canvas) or autoResize.
      For defaults see the OSMDOptionsStandard method in the [[OSMDOptions]] class.

    Returns OpenSheetMusicDisplay

Properties

OnXMLRead: Function
PageFormatStandards: {
    [type: string]: PageFormat;
}

Standard page format options like A4 or Letter, in portrait and landscape. E.g. PageFormatStandards["A4_P"] or PageFormatStandards["Letter_L"].

Type declaration

  • [type: string]: PageFormat
autoResizeEnabled: boolean
backendType: BackendType
container: HTMLElement
cursors: Cursor[]
cursorsOptions: any
drawBottomLine: boolean
drawBoundingBox: string
drawSkyLine: boolean
drawer: VexFlowMusicSheetDrawer
drawingParameters: DrawingParameters
followCursor: boolean
graphic: GraphicalMusicSheet
loadUrlTimeout: number

Timeout in milliseconds used in osmd.load(string) when string is a URL.

needBackendUpdate: boolean
resizeHandlerAttached: boolean
rules: EngravingRules
sheet: MusicSheet
version: string
zoom: number
zoomUpdated: boolean

Accessors

  • get AutoResizeEnabled(): boolean
  • Returns boolean

  • set AutoResizeEnabled(value): void
  • Parameters

    • value: boolean

    Returns void

  • get DrawBottomLine(): boolean
  • Returns boolean

  • set DrawBottomLine(value): void
  • Parameters

    • value: boolean

    Returns void

  • get DrawBoundingBox(): string
  • Returns string

  • set DrawBoundingBox(value): void
  • Parameters

    • value: string

    Returns void

  • get DrawSkyLine(): boolean
  • Returns boolean

  • set DrawSkyLine(value): void
  • Parameters

    • value: boolean

    Returns void

  • get Drawer(): VexFlowMusicSheetDrawer
  • Returns VexFlowMusicSheetDrawer

  • get DrawingParameters(): DrawingParameters
  • Returns DrawingParameters

  • get EngravingRules(): EngravingRules
  • Returns EngravingRules

  • get FollowCursor(): boolean
  • Returns boolean

  • set FollowCursor(value): void
  • Parameters

    • value: boolean

    Returns void

  • get GraphicSheet(): GraphicalMusicSheet
  • Returns GraphicalMusicSheet

  • get Sheet(): MusicSheet
  • Returns MusicSheet

  • get TransposeCalculator(): ITransposeCalculator
  • Returns ITransposeCalculator

  • set TransposeCalculator(calculator): void
  • Parameters

    • calculator: ITransposeCalculator

    Returns void

  • get Version(): string
  • Returns the version of OSMD this object is built from (the version you are using).

    Returns string

  • get Zoom(): number
  • Returns number

  • set Zoom(value): void
  • Parameters

    • value: number

    Returns void

  • get cursor(): Cursor
  • Returns Cursor

Methods

  • States whether the render() function can be safely called.

    Returns boolean

  • Parameters

    • pageFormatString: string

    Returns PageFormat

  • Attach the appropriate handler to the window.onResize event

    Returns void

  • Clears what OSMD has drawn on its canvas.

    Returns void

  • Parameters

    • type: BackendType
    • page: GraphicalMusicPage

    Returns VexFlowBackend

  • Returns void

  • Enable or disable (hide) the cursor.

    Parameters

    • enable: boolean

      whether to enable (true) or disable (false) the cursor

    Returns void

  • Returns void

  • Returns number

  • Helper function for managing window's onResize events

    Parameters

    • startCallback: (() => void)

      is the function called when resizing starts

        • (): void
        • Returns void

    • endCallback: (() => void)

      is the function called when resizing (kind-of) ends

        • (): void
        • Returns void

    Returns void

  • Load a MusicXML file

    Parameters

    • content: string | Document

      is either the url of a file, or the root node of a MusicXML document, or the string content of a .xml/.mxl file

    • Optional tempTitle: string

      is used as the title for the piece if there is no title in the XML.

    Returns Promise<{}>

  • Render the music sheet in the container

    Returns void

  • Initialize this object to default values FIXME: Probably unnecessary

    Returns void

  • Parameters

    • options: IOSMDOptions

    Returns void

  • Parameters

    • width: number
    • height: number

    Returns void

  • Parameters

    • value: string
    • Optional render: boolean

    Returns void

  • Sets the logging level for this OSMD instance. By default, this is set to warn.

    @param: content can be trace, debug, info, warn or error.

    Parameters

    • level: string

    Returns void

  • Set OSMD rendering options using an IOSMDOptions object. Can be called during runtime. Also called by constructor. For example, setOptions({autoResize: false}) will disable autoResize even during runtime.

    Parameters

    • options: IOSMDOptions

    Returns void

  • Sets page format by string. Used by setOptions({pageFormat: "A4_P"}) for example.

    Parameters

    • formatId: string

    Returns void

  • (Re-)creates the graphic sheet from the music sheet

    Returns void