OpenSheetMusicDisplay
    Preparing search index...

    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.

    Index

    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)

      • 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

    autoResizeEnabled: boolean
    backendType: BackendType
    container: HTMLElement
    cursors: Cursor[] = []
    cursorsOptions: CursorOptions[] = []

    Options from which OSMD creates cursors in enableOrDisableCursors().

    drawBottomLine: boolean
    drawBoundingBox: string
    drawingParameters: DrawingParameters
    drawSkyLine: boolean
    followCursor: boolean
    loadUrlTimeout: number = 5000

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

    needBackendUpdate: boolean
    OnXMLRead: (xml: string) => string

    A function that is executed when the XML has been read. The return value will be used as the actual XML OSMD parses, so you can make modifications to the xml that OSMD will use. Note that this is (re-)set on osmd.setOptions as {return xml}, unless you specify the function in the options.

    resizeHandlerAttached: boolean
    sheet: MusicSheet
    version: string = "1.9.2-release"
    zoom: number = 1.0
    zoomUpdated: boolean = false
    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"].

    Accessors

    Methods

    • Helper function for managing window's onResize events

      Parameters

      • startCallback: () => void

        is the function called when resizing starts

      • endCallback: () => void

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

      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

      • tempTitle: string = "Untitled Score"

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

      Returns Promise<{}>

    • Re-render and scroll back to previous scroll bar y position in percent. If the document keeps the same height/length, the scroll bar position will basically be unchanged. For example, if you scroll to the bottom of the page, resize by one pixel (or enable dark mode) and call this, for the human eye there will be no detectable scrolling or change in the scroll position at all. If you just call render() instead of renderAndScrollBack(), it will scroll you back to the top of the page, even if you were scrolled to the bottom before.

      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