OpenSheetMusicDisplay
    Preparing search index...

    Class MusicSheetCalculatorAbstract

    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 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 formatMeasures getDashesEnd getDashesEndXInStaffLine getRelativePositionInStaffLineFromTimestamp getRelativeXPositionFromTimestamp graphicalMeasureCreatedCalculations handleBeam handleStaffEntryLink handleTiedGraphicalNote handleTuplet handleVoiceEntry handleVoiceEntryArticulations handleVoiceEntryLyrics handleVoiceEntryOrnaments handleVoiceEntryTechnicalInstructions initGraphicalMeasuresCreation initialize isSameMetronomeMark isTempoMarkingAlreadyRendered layoutArticulationMarks layoutBeams layoutGraphicalTie layoutMeasureWithWholeRest layoutMetronomeMarks layoutOrnament layoutSingleRepetitionEnding layoutStaffEntry layoutTieWithoutStartNote layoutVoiceEntries layoutVoiceEntry maxInstrNameLabelLength multiRestsFitDrawRange optimizeRestNotePlacement placeWordsBesideSameTimeDynamic prepareGraphicalMusicSheet reserveSkyBottomLinesForCrossStaffBeams reserveSkylineForMeasureRepeats resetYPositionForLeadSheet skyBottomLineCacheKey updateBottomLinesWithPedals updateStaffLineBorders labelBaselineOffset setMeasuresMinStaffEntriesWidth
    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

    • Calculates the dashed line after a placed text (see calculateDashedLinesAfterTexts()): its part in the text's staffline and the parts in the stafflines of the following systems up to its end, and updates the sky/bottom lines with them.

      Parameters

      Returns void

    • 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

    • Calculate all the Mood and Unknown Expressions for a single [[MultiExpression]]: its words, drawn together in one label. A verbal crescendo or diminuendo at the same position (e.g. "cresc.") is not part of the label: it's drawn as a dynamic of its own (see calculateDynamicExpressions()).

      Parameters

      Returns void

    • Delete all Objects that must be recalculated. If graphicalMusicSheet.reCalculate has been called, then this method will be called to reset or remove all flexible graphical music symbols (e.g. Ornaments, Lyrics, Slurs) graphicalMusicSheet will have MusicPages, they will have MusicSystems etc...

      Returns void

    • 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 }

    • Returns the x position (relative to the staffline) up to which a dashed line after a text (see Dashes) runs in the staffline of its text: its end, or the end of the staffline if it goes on in a later system. Undefined if no line is drawn (RenderExpressionDashes, a line without a stop).

      Parameters

      Returns number

    • Parameters

      • timestamp: Fraction
      • verticalIndex: number
      • staffLine: StaffLine
      • multiStaffInstrument: boolean
      • firstVisibleMeasureRelativeX: number = 0.0
      • useLeftStaffEntryBorder: boolean = false

      Returns PointF2D

    • 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

    • 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

    • Build the 2D [[GraphicalMeasure]] list needed for the [[MusicSheetCalculator]]. Internally it creates [[GraphicalMeasure]]s, [[GraphicalStaffEntry]]'s and [[GraphicalNote]]s.

      Returns void

    • 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