OpenSheetMusicDisplay
    Preparing search index...

    Class GraphicalMusicSheet

    The graphical counterpart of a [[MusicSheet]]

    Index
    • get TranspositionChanged(): boolean

      Whether the transposition changed since the graphical notes and chord symbols were created: osmd.Sheet.Transpose, an instrument's Transpose, or, while one of them isn't 0, osmd.TransposeCalculator. The notes and chord symbols are transposed when they are created, the key signatures in each layout (reCalculate()), so osmd.render() creates the graphic again when the transposition changed. A changed option of the same calculator (e.g. IntervalTransposeCalculator.AvoidDoubleAccidentals) doesn't count: call osmd.updateGraphic() after that.

      Returns boolean

    • get VoiceVisibilityChanged(): boolean

      Whether a voice was shown or hidden (Voice.Visible, also set by Instrument.Visible) since the graphical notes were created. The notes of hidden voices are left out when they are created, or created invisible with EngravingRules.HiddenVoicesKeepLayout, and the multiple rest measures follow the visible voices, so osmd.render() creates the graphic again when this changed.

      Returns boolean

    • Find a measure by its zero-based source index and staff index. Collapsed multiple-rest members resolve to their representative measure (the multiple rest measure), and an index beyond the score's end (e.g. from the cursor) resolves to the last measure.

      Parameters

      • measureIndex: number
      • staffIndex: number

      Returns GraphicalMeasure

    • Returns the object of the class whose bounding box contains the position, e.g. of a click, or undefined: e.g. getClickedObjectOfType(position, GraphicalStaffEntry) returns the staff entry there. Of objects containing each other, the innermost one, e.g. without a class, at a lyric, its label rather than its staff entry, measure or page. For the object nearest to the position, see GetNearestObject().

      Type Parameters

      • T

      Parameters

      • positionOnMusicSheet: PointF2D

        The position in units

      • OptionalclassOrName: string | ClassType<T>

        The class of the object, e.g. GraphicalStaffEntry: the type parameter T alone doesn't select it, types don't exist at runtime. Or its name, which is unreliable in minified builds (see AClassHierarchyTrackable.isInstanceOfClass()). By default, any graphical object.

      • Optionalpage: GraphicalMusicPage

        The page to search, e.g. the one clicked on: each page has its own coordinates, so the position is on every page. By default, all pages: the object on the first page that has one there.

      Returns T

    • Returns nearest object of type T near clickPosition. E.g. GetNearestObject(pos, GraphicalMeasure) returns the nearest measure. Note that there is also GetNearestStaffEntry(), which has a bit more specific code for staff entries.

      Type Parameters

      Parameters

      • clickPosition: PointF2D
      • classOrName: string | ClassType<T>

        The class of the object, e.g. GraphicalMeasure. Or its name (e.g. GraphicalMeasure.name), which is unreliable in minified builds: they can give other classes the same name, e.g. GraphicalNote (see AClassHierarchyTrackable.isInstanceOfClass()).

      • Optionalpage: GraphicalMusicPage

        The page to search, e.g. the one clicked on: each page has its own coordinates, so the position is on every page. By default, all pages.

      Returns T

    • Returns the index of the closest next (later) vertical container which has at least some visible staff entry, with respect to the given index.

      Parameters

      • index: number

      Returns number

    • Returns the index of the closest previous (earlier) vertical container which has at least some visible staff entry, with respect to the given index.

      Parameters

      • index: number

      Returns number

    • Get a List with the indices of all the visible GraphicalMeasures and calculates their corresponding indices in the first SourceMeasure, taking into account Instruments with multiple Staves. Hidden staves (Staff.Visible = false) of a visible instrument are left out, so the list matches the drawn staff lines (see MusicSystemBuilder.layoutSystemStaves()).

      Parameters

      Returns number[]

    • Whether a staff entry's x position is a reliable anchor for mapping a timestamp to an x position (cursor positioning during playback, see calculateXPositionFromTimestamp). Two kinds of entries are excluded:

      • Entries without any graphical notes, e.g. staff entries only carrying a chord symbol (MusicXML harmony). These are never positioned by the layout (their relative x stays at the measure's left border regardless of their timestamp), so using them as anchors makes the cursor jump backwards to the measure start (e.g. chord symbols above a centered whole rest).
      • Entries positioned outside their measure's horizontal bounds. These occur when a note was never actually formatted/laid out (e.g. rests in some tablature edge cases) and carry meaningless coordinates.

      Parameters

      Returns boolean

    • Returns the timestamp of the staff entry at the position, e.g. of a click (whose bounding box contains it), or undefined. For the timestamp of the nearest staff entry, see tryGetTimeStampFromPosition() (with a capital S).

      Parameters

      • positionOnMusicSheet: PointF2D

        The position in units

      • Optionalpage: GraphicalMusicPage

        The page to search, e.g. the one clicked on: each page has its own coordinates, so the position is on every page. By default, all pages.

      Returns Fraction