OpenSheetMusicDisplay
    Preparing search index...

    Class VexFlowMeasure

    Represents a measure in the music sheet (one measure in one staff line)

    Hierarchy (View Summary)

    Index
    beginInstructionsWidth: number

    The x-width of possibly existing: repetition start line, clef, key, rhythm.

    boundingBox: BoundingBox
    connectors: StaveConnector[] = []

    VexFlow StaveConnectors (vertical lines)

    endInstructionsWidth: number

    The x-width of possibly existing: repetition end line, clef.

    ExtraGraphicalMeasurePreviousMeasure: GraphicalMeasure
    firstInstructionStaffEntry: GraphicalStaffEntry
    formatVoices?: (width: number, parent: VexFlowMeasure) => void

    Call this function (if present) to x-format all the voices in the measure

    hasError: boolean
    hasMetronomeMark: boolean = false

    Whether a metronome mark is drawn on this staff measure (they are drawn on the first visible staff).

    hasOnlyRests: boolean = false

    Whether or not this measure is nothing but rest(s). Also see SourceMeasure.allRests, which is not the same, because a source measure can have multiple staffs/graphicalMeasures.

    InitiallyActiveClef: ClefInstruction

    The clef of the first note of the measure (the clef the measure starts with).

    IsExtraGraphicalMeasure: boolean

    Used to show key, rhythm changes at the end of the system, has MeasureNumber < 0, because never set.

    isTabMeasure: boolean = false
    lastInstructionStaffEntry: GraphicalStaffEntry
    MeasureRepeat: VexFlowMeasureRepeat

    Repeat unit drawn in place of this measure's note content, if any.

    minimumStaffEntriesWidth: number

    The minimum possible x-width of all staff entries without overlapping.

    multiRestElement: any

    Only exists on multiple rest measure (VexFlowMultiRestMeasure). See isMultiRestMeasure() function.

    octaveOffset: number = 3

    octaveOffset according to active clef

    parentSourceMeasure: SourceMeasure
    ShowKeySignature: boolean = true
    ShowTimeSignature: boolean = true
    staffEntries: GraphicalStaffEntry[]
    staffEntriesScaleFactor: number

    Will be set by music system builder while building systems.

    stave: Stave

    The VexFlow Stave (= one measure in a staffline)

    svgGElement: SVGGElement = undefined

    The SVG group the measure was drawn into, see getSVGGElement(). Set by the backend's measure (VexFlowMeasure.draw()).

    tuplets: { [voiceID: number]: [Tuplet, VexFlowVoiceEntry[]][] } = {}

    Intermediate object to construct tuplets

    vfRepetitionWords: Repetition[] = []

    The repetition instructions given as words or symbols (coda, dal segno..)

    vfTies: StaveTie[] = []

    The VexFlow Ties in the measure

    vfVoices: { [voiceID: number]: Voice } = {}

    The VexFlow Voices in the measure

    • Adds a measure number to the top left corner of the measure This method is not used currently in favor of the calculateMeasureNumberPlacement method in the MusicSheetCalculator.ts

      Returns void

    • Does what draw() does to the notes besides drawing them: the beams extend their notes' stems (see postFormatBeams()), and the notes are placed at their note heads (see correctNotePositions()). For the lazy reuse of a skyline (SkyBottomLineCalculator.applyGeometricSkylineSideEffectsOnly()), which skips the draw of the skyline calculation: the beams would extend the stems when the measure is drawn instead, at the stave's final position rather than the skyline calculation's, so a few stems and beams would end a few trillionths of a pixel off where render() draws them.

      Returns void

    • Places each note at the height of its drawn note head, relative to its voice entry, e.g. where a click finds it (GraphicalMusicSheet.GetNearestNote()). A voice entry is at the top of its Vexflow note's bounding box (see VexFlowVoiceEntry.applyBordersFromVexflow()), e.g. the stem tip of a note with its stem up, and stems differ in length: the stems of grace notes and cue notes are shorter, those of 32nd notes longer. A note's x: see VexFlowStaffEntry.calculateXPosition(). Called at the end of draw() (note.setIndex() needs to have been called).

      Returns void

    • Draws the beams across staves whose last staff is this measure's (see isCrossStaffBeam()), with the stems of their notes. Called after all staves of the system are drawn: the beam's slope and the stems' lengths come from the notes' y, which follows their stave's final position only once the notes are drawn (Voice.draw() sets their stave).

      Parameters

      • ctx: IRenderContext

      Returns void

    • Draws the tuplets of notes on a beam across staves (see drawNotes()), after drawCrossStaffBeams() of all measures of the system has extended their stems.

      Parameters

      • ctx: IRenderContext

      Returns void

    • Formats the voices of this measure's vertical measure, i.e. of all its staves (see VexFlowMusicSheetCalculator.formatMeasures()), to the width of this measure's stave.

      Parameters

      • OptionallastFormats: Map<SourceMeasure, IVerticalMeasureFormat>

        For a series of formats, like the skyline calculation's (see SkyBottomLineCalculator), which formats every measure, and so each vertical measure once per staff: the last format of each vertical measure in the series. A format that would just repeat the last one of its vertical measure is skipped: it would compute the same result again (see isRepeatedFormat()). Without lastFormats, the measure is always formatted.

      Returns void

    • Finds the gaps between the existing notes within a measure. Problem here is, that the graphicalVoiceEntry does not exist yet and that Tied notes are not present in the normal voiceEntries. To handle this, calculation with absolute timestamps is needed. And the graphical notes have to be analysed directly (and not the voiceEntries, as it actually should be -> needs refactoring)

      Parameters

      • voice: Voice

        the voice for which the ghost notes shall be searched.

      Returns GraphicalVoiceEntry[]

    • Gets the SVG group (g.vf-measure) this measure was drawn into, with the SVG backend: its staff lines (g.vf-stave), barlines, clef, key and time signature, notes, and the ties that end in it. Each group has an id of its own in the sheet's drawing, e.g. "osmd-m11-1" for the group of MeasureList[11][1], the 12th measure of the second staff (see getSVGGElementId()). Several OSMD instances on a web page give their measures the same ids, so find a group by its id in the instance's container, or with this method.

      Returns SVGGElement

      The group, or undefined with the canvas backend and for a measure that isn't drawn.

      // the staff lines of the second staff's first measure in red
      osmd.GraphicSheet.MeasureList[0][1].getSVGGElement()?.querySelector(".vf-stave")?.setAttribute("stroke", "#FF0000");
    • Gets the id of the SVG group this measure is drawn into (see getSVGGElement()), unique in the sheet's drawing: "osmd-m", the measure's index in Sheet.SourceMeasures, "-" and its staff's index in Sheet.Staves, both counted from 0, which are the measure's indices in GraphicSheet.MeasureList: "osmd-m11-1" is MeasureList[11][1], the 12th measure of the second staff. A multiple rest measure has the index of its first measure. An extra instruction measure (the key or time signature of the next system at the end of a system) has the index of the measure it follows and an "x": "osmd-m1x-0" follows "osmd-m1-0". The index, not the measure number, which can repeat (e.g. 0 for a pickup and for an implicit measure after it).

      Returns string

    • Reserves the room of the beams across staves in the sky and bottom lines, which don't have these beams and their stems: they are drawn after all staves (see drawCrossStaffBeams()). Called after the sky and bottom lines are calculated, before what is placed from them, e.g. dynamics and wedges, and before the staff distances are calculated from them.

      • Stems pointing both ways (see placeBeamBetweenStems()): the beam with CrossStaffBeamMinStemLength above it below the upper staff's notes with stems down, where the beam is drawn, and CrossStaffBeamMinStemLength above the lower staff's notes with stems up. So what is placed below the upper staff goes below the beam, and the staves are kept far enough apart for the beam and the minimum stem length.
      • Stems all pointing one way: the beam at the stems' default length beyond the notes of the staff on that side, where VexFlow lays it out (about: VexFlow slopes it), as a beam of one staff is in that staff's sky or bottom line.

      Returns void

    • The default beam groups for automatic beaming in a time signature, as fractions of a whole note: compound meters (6/8, 9/8, 12/8, 6/4, 6/16...) per dotted beat, 3/8 and 3/16 per measure, 5/8 as 3+2 and 7/8 as 3+2+2 (like MuseScore; the music may also be grouped 2+3 or 2+2+3, which can be given in AutoBeamOptions.groups), other meters with eighths or shorter as the beat in twos (2/8, 4/8), and simple meters per beat (2/4, 3/4, 4/4, 2/2...).

      Parameters

      Returns Fraction[]