OpenSheetMusicDisplay
    Preparing search index...

    Class VexFlowMusicSheetCalculator

    Class used to do all the calculations in a MusicSheet, which in the end populates a GraphicalMusicSheet.

    Hierarchy (View Summary)

    Index
    calcGraphicalRepetitionEndingsRecursively calculate calculateAlignedChordSymbolsOffset calculateChordSymbols calculateChordSymbolsXPositions calculateComments calculateDashedLinesAfterTexts calculateDashesOfLabel calculateDynamicExpressionsForMultiExpression calculateElongationFactorFromStaffEntries calculateExpressionAlignements calculateFingerings calculateGlissandi calculateGraphicalContinuousDynamic calculateGraphicalInstantaneousDynamicExpression calculateGraphicalVerbalContinuousDynamic calculateLabel calculateLyricsExtendsAndDashes calculateMarkedAreas calculateMeasureNumberPlacement calculateMeasureWidthFromStaffEntries calculateMeasureXLayout calculateMoodAndUnknownExpression calculateMusicSystems calculatePageLabels calculateRehearsalMark calculateRestNotePlacementWithinGraphicalBeam calculateSheetLabelBoundingBoxes calculateSingleOctaveShift calculateSinglePedal calculateSingleStaffLineLyricsPosition calculateSingleWavyLine calculateSkyBottomLines calculateSlurs calculateTempoExpressionsForMultiTempoExpression calculateTupletNumbers calculateWedgeStartingBeforeDrawingRange calculateWordRepetitionInstruction calculateXLayout checkMeasuresForWholeRestNotes clearRecreatedObjects clearSkyBottomLineCache clearSystemsAndMeasures createExpressionLabel createGraphicalTie createGraphicalTies createMetronomeMark findFirstStafflineMeasure findIndexGraphicalSlurFromSlur findLastStafflineMeasure formatMeasures getDashesEnd getDashesEndXInStaffLine getRelativePositionInStaffLineFromTimestamp getRelativeXPositionFromTimestamp graphicalMeasureCreatedCalculations handleBeam handleStaffEntryLink handleTiedGraphicalNote handleTuplet handleVoiceEntry handleVoiceEntryArticulations handleVoiceEntryLyrics handleVoiceEntryOrnaments handleVoiceEntryTechnicalInstructions indexOfGraphicalGlissFromGliss initGraphicalMeasuresCreation initialize isSameMetronomeMark isTempoMarkingAlreadyRendered layoutArticulationMarks layoutBeams layoutGraphicalTie layoutMeasureWithWholeRest layoutMetronomeMarks layoutOrnament layoutSingleRepetitionEnding layoutStaffEntry layoutTieWithoutStartNote layoutVoiceEntries layoutVoiceEntry maxInstrNameLabelLength multiRestsFitDrawRange optimizeRestNotePlacement placeWordRepetitionInSkyline placeWordsBesideSameTimeDynamic prepareGraphicalMusicSheet reserveSkyBottomLinesForCrossStaffBeams reserveSkylineForMeasureRepeats resetYPositionForLeadSheet skyBottomLineCacheKey updateBottomLinesWithPedals updateStaffLineBorders labelBaselineOffset setMeasuresMinStaffEntriesWidth
    beamsNeedUpdate: boolean = false
    dynamicExpressionMap: Map<number, BoundingBox> = ...
    graphicalLyricWords: GraphicalLyricWord[] = []
    graphicalMusicSheet: GraphicalMusicSheet
    musicSystems: MusicSystem[]
    skyBottomLineCache: Map<string, { bottom: number[]; sky: number[] }> = ...

    Lazy rendering: cache of computed sky/bottom lines, keyed per staff line by its system's measure range + staff index. A growing-prefix batch re-runs the (expensive) skyline pass over the whole prefix; this lets stable interior systems reuse the lines computed in an earlier batch instead of re-measuring them. Only used when EngravingRules.LazyConsistentGraphic; cleared per lazy session.

    staffEntriesWithChordSymbols: GraphicalStaffEntry[] = []
    staffEntriesWithGraphicalTies: GraphicalStaffEntry[] = []
    staffEntriesWithOrnaments: GraphicalStaffEntry[] = []
    stafflineNoteCalculator: IStafflineNoteCalculator

    Tracks the pitches on each percussion staff, to put them on one line if there are few of them (PercussionOneLineCutoff).

    staffLinesWithLyricWords: StaffLine[] = []
    • Returns the highest (minimum) skyline and lowest (maximum) bottom line value under the chord symbols of the given staff entries, where they are drawn (see calculateChordSymbolsXPositions(), called before), to place them at one y position.

      Parameters

      • staffEntries: GraphicalStaffEntry[]

        The staff entries whose chord symbols to align, e.g. of a staffline or measure (ChordSymbolYAlignmentScope).

      • sbc: SkyBottomLineCalculator

        The sky and bottom line calculator of the staffline of the staff entries.

      Returns { maxOffset: number; minOffset: number }

      The minimum skyline value under chord symbols placed above, and the maximum bottom line value under chord symbols placed below (Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER if there are none).

    • Sets the x positions of the chord symbols of a measure (relative to their parent bounding boxes), before their y positions: a chord symbol not over a note goes from its staff entry (which has no x position without notes) to the measure, at an x proportional to its timestamp in the measure, and a chord symbol over a whole measure rest after the begin instructions.

      Parameters

      • measure: GraphicalMeasure

        The measure whose chord symbols to position.

      • measureStafflineIndex: number

        The index of the measure in its staffline, to find the measures of the other staves in musicSystem.

      • musicSystem: MusicSystem

        The system of the measure: chord symbols without a staff entry x position take the x position of a staff entry with the same timestamp in the other staves.

      Returns void

    • Calculates the dashed lines after texts (MusicXML <dashes>, e.g. "cresc. - - - -" or "rit. - - - -", see Dashes) for the texts placed so far, unless their line is calculated already. Called after each kind of text is placed (verbal dynamics, words, tempo words), so that what is placed later stays clear of the lines (they update the sky/bottom line). The line starts after its text, on the text's baseline (ExpressionDashesYOffsetFromTextCenter), and ends before its stop position. In the systems after its text's, it goes on from the start of the staffline, placed by the sky/bottom line there, with the text again in brackets if RenderExpressionDashesContinuationText is set.

      Returns void

    • Parameters

      • staffEntries: GraphicalStaffEntry[]
      • oldMinimumStaffEntriesWidth: number
      • elongationFactorForMeasureWidth: number
      • measureNumber: number
      • OptionalpreviousLyricOverflows: number[]

        Per-verse-index array ([verseIndex]) holding how far the previous measure's last lyric extends past its bar line into this measure (in pre-elongation units, +dashSpace if mid-word). Used to seed lastLyricEntryDict so the first lyric in this measure is forced to leave clearance from the overhang.

      • OptionalpreviousChordOverflows: number[]

        Same as previousLyricOverflows but for chord symbols.

      Returns {
          factor: number;
          lastChordEntryDict: { [i: number]: any };
          lastLyricEntryDict: { [i: number]: any };
      }

      • factor: regular elongation factor from within-measure spacing constraints (subject to MaximumLyricsElongationFactor cap by the caller).
        • lastLyricEntryDict / lastChordEntryDict: final state of the per-verse last-entry dicts after processing. The caller uses these (with the post-cap measure width) to compute the overflows passed into the next measure's call.
    • Creates the labels of the fingerings above or below the notes (GraphicalStaffEntry.FingeringEntries), or removes the ones of the layout before when they aren't drawn anymore (EngravingRules.RenderFingerings off, e.g. by osmd.setOptions({drawFingerings: false}) after a render), or are drawn left or right of the notes instead.

      Returns void

    • Calculates the x layout of the staff entries within the staff measures belonging to one source measure. All staff entries are x-aligned throughout all vertically aligned staff measures. This method is called within calculateXLayout. The staff entries are aligned with minimum needed x distances. The MinimumStaffEntriesWidth of every measure will be set - needed for system building. Prepares the VexFlow formatter for later formatting Does not calculate measure width from lyrics (which is called from MusicSheetCalculator)

      Parameters

      Returns number

      the minimum required x width of the source measure (=list of staff measures)

    • Returns where a dashed line after a text (see Dashes) ends: the last measure it reaches and the x position of its end relative to that measure's staffline, ExpressionDashesEndPadding before the notes at its stop position or before the barline. A line that stops in a measure that isn't drawn ends with the last measure drawn before it. Undefined if the line has no stop or none of its measures is drawn.

      Parameters

      • dashes: Dashes

        the line

      • staffIndex: number

        the index of the staff in the sheet

      Returns { measure: GraphicalMeasure; x: number }

    • Whether the multiple rest measures fit the draw range from the first to the last measure to draw (source measure indices, see EngravingRules.MinMeasureToDrawIndex and MaxMeasureToDrawIndex): they begin and end with the measures to draw they were made for (see prepareGraphicalMusicSheet()), so they have to be made again (osmd.render() creates the graphic again) for a draw range that begins or ends inside one, or after one was divided for the previous draw range.

      Parameters

      • firstIndex: number
      • lastIndex: number

      Returns boolean

    • Shifts a repetition instruction (VF.Repetition, e.g. Coda sign or "D.S. al Fine" text) above other objects in its range, e.g. chord symbols, which are calculated before the repetition instructions, or previously placed repetition instructions (see #1689). Shifted instructions reserve their space in the skyline, so that the staffline borders account for them. The horizontal and default vertical position replicate the drawing code in VexFlowPatch/src/staverepetition.js (drawSymbolText() etc).

      Parameters

      • measure: VexFlowMeasure

        the (uppermost) measure the repetition instruction was added to

      • repetition: Repetition

        the VexFlow repetition (stave modifier) to place, created by addWordRepetition()

      Returns void

    • Words and an instantaneous dynamic of the same staff, placement and time are one phrase, engraved on one line, e.g. "più f" or "p dolce": the words go on the dynamic's line, next to it, in the order of the file: the order of the <direction-type>s in a <direction>, which MusicXML defines as their visual order, or of two <direction>s. Before, the words were placed at the bottom (sky) line, which the dynamic had raised there, and went under (over) it, e.g. "f" with "piu" below it (#1913). The dynamic stays at its note. Words before the dynamic reach to the left of it, also across the barline (Gould, Behind Bars, p. 103), words after it to the right. Where the notes, slurs etc. of the measure reach into the words on that line, the words and the dynamic move away from the staff together. The words keep the current placement (under or over the dynamic) where there's no room on the line: at the start of the staff or beyond its end, where the words would run into another expression (a dynamic, wedge or words placed before them), and where the move away from the staff would take the dynamic off the line of words placed beside it before (a second words at the dynamic). Words that the file puts more than a staff space from the dynamic (default-y and relative-y, e.g. a fingering written as words under the dynamic) and words of several lines stay on their own line.

      Parameters

      Returns GraphicalLabel

      the words' label, positioned, or undefined if the words aren't placed beside a dynamic

    • Stable per-staff-line key for the lazy sky/bottom-line cache: the system's measure range pins the system (systems partition the measures), the staff index picks the line within it. Returns undefined for a staff line with no usable measures (so it is never cached/reused). The measures are named by their index in SourceMeasures, not their number, which can repeat (e.g. it starts again at 1 after a final barline with EngravingRules.NewPartAndSystemAfterFinalBarline: a system of the second part got the lines of the first part's system with the same measure numbers), an extra measure at the system end (a key or time signature of the next system) by the index of the measure it follows and an "x", as in its SVG group's id.

      Parameters

      • staffLine: StaffLine
      • staffIndexInSystem: number

      Returns string

    • Where the baseline of a label's first line of text is, relative to the label's position: the drawer puts the text's top at the position, shifted up for a bottom or center alignment so that the text is in the label's box, with 0.2 font heights under the last baseline for the descenders (see MusicSheetDrawer.drawLabel()), and draws the text with its baseline a font height below its top.

      Parameters

      Returns number