opensheetmusicdisplay
Version:
An open source JavaScript engine for displaying MusicXML based on VexFlow.
196 lines (195 loc) • 11.1 kB
TypeScript
import { MusicSheetCalculator } from "../MusicSheetCalculator";
import { GraphicalMeasure } from "../GraphicalMeasure";
import { StaffLine } from "../StaffLine";
import { VoiceEntry } from "../../VoiceData/VoiceEntry";
import { GraphicalNote } from "../GraphicalNote";
import { GraphicalStaffEntry } from "../GraphicalStaffEntry";
import { GraphicalTie } from "../GraphicalTie";
import { Tie } from "../../VoiceData/Tie";
import { SourceMeasure } from "../../VoiceData/SourceMeasure";
import { MultiExpression } from "../../VoiceData/Expressions/MultiExpression";
import { RepetitionInstruction } from "../../VoiceData/Instructions/RepetitionInstruction";
import { Beam } from "../../VoiceData/Beam";
import { ClefInstruction } from "../../VoiceData/Instructions/ClefInstruction";
import { OctaveEnum } from "../../VoiceData/Expressions/ContinuousExpressions/OctaveShift";
import { Fraction } from "../../../Common/DataObjects/Fraction";
import { LyricWord } from "../../VoiceData/Lyrics/LyricsWord";
import { OrnamentContainer } from "../../VoiceData/OrnamentContainer";
import { Articulation } from "../../VoiceData/Articulation";
import { Tuplet } from "../../VoiceData/Tuplet";
import { TechnicalInstruction } from "../../VoiceData/Instructions/TechnicalInstruction";
import { Slur } from "../../VoiceData/Expressions/ContinuousExpressions/Slur";
import { GraphicalSlur } from "../GraphicalSlur";
import { InstantaneousTempoExpression } from "../../VoiceData/Expressions/InstantaneousTempoExpression";
import { EngravingRules } from "../EngravingRules";
import { GraphicalGlissando } from "../GraphicalGlissando";
import { Glissando } from "../../VoiceData/Glissando";
export declare class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
/** space needed for a dash for lyrics spacing, calculated once */
private dashSpace;
beamsNeedUpdate: boolean;
/** Per-staff overflow (in pre-elongation units) of the previous measure's last lyric/chord
* past its bar line. Used to prevent the next measure's first lyric/chord from colliding
* with the overflow. Indexed first by Staff, then by verse/container index. */
private previousLyricOverflowsByStaff;
private previousChordOverflowsByStaff;
constructor(rules: EngravingRules);
protected clearRecreatedObjects(): void;
protected formatMeasures(): 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)
* @param measures
* @returns the minimum required x width of the source measure (=list of staff measures)
*/
protected calculateMeasureXLayout(measures: GraphicalMeasure[]): number;
private calculateElongationFactor;
/**
* @param previousLyricOverflows 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.
* @param previousChordOverflows Same as previousLyricOverflows but for chord symbols.
* @returns
* - `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.
*/
calculateElongationFactorFromStaffEntries(staffEntries: GraphicalStaffEntry[], oldMinimumStaffEntriesWidth: number, elongationFactorForMeasureWidth: number, measureNumber: number, previousLyricOverflows?: number[], previousChordOverflows?: number[]): {
factor: number;
lastLyricEntryDict: {
[i: number]: any;
};
lastChordEntryDict: {
[i: number]: any;
};
};
calculateMeasureWidthFromStaffEntries(measuresVertical: GraphicalMeasure[], oldMinimumStaffEntriesWidth: number): number;
private computeContainerOverflows;
protected createGraphicalTie(tie: Tie, startGse: GraphicalStaffEntry, endGse: GraphicalStaffEntry, startNote: GraphicalNote, endNote: GraphicalNote): GraphicalTie;
protected updateStaffLineBorders(staffLine: StaffLine): void;
protected graphicalMeasureCreatedCalculations(measure: GraphicalMeasure): void;
/**
* Can be used to calculate articulations, stem directions, helper(ledger) lines, and overlapping note x-displacement.
* Is Excecuted per voice entry of a staff entry.
* After that layoutStaffEntry is called.
* @param voiceEntry
* @param graphicalNotes
* @param graphicalStaffEntry
* @param hasPitchedNote
*/
protected layoutVoiceEntry(voiceEntry: VoiceEntry, graphicalNotes: GraphicalNote[], graphicalStaffEntry: GraphicalStaffEntry, hasPitchedNote: boolean): void;
/**
* Do all layout calculations that have to be done per staff entry, like dots, ornaments, arpeggios....
* This method is called after the voice entries are handled by layoutVoiceEntry().
* @param graphicalStaffEntry
*/
protected layoutStaffEntry(graphicalStaffEntry: GraphicalStaffEntry): void;
/**
* Is called at the begin of the method for creating the vertically aligned staff measures belonging to one source measure.
*/
protected initGraphicalMeasuresCreation(): void;
/**
* add here all given articulations to the VexFlowGraphicalStaffEntry and prepare them for rendering.
* @param articulations
* @param voiceEntry
* @param graphicalStaffEntry
*/
protected layoutArticulationMarks(articulations: Articulation[], voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry): void;
/**
* Calculate the shape (Bezier curve) for this tie.
* @param tie
* @param tieIsAtSystemBreak
* @param isTab Whether this tie is for a tab note (guitar tabulature)
*/
protected layoutGraphicalTie(tie: GraphicalTie, tieIsAtSystemBreak: boolean, isTab: boolean): void;
protected calculateDynamicExpressionsForMultiExpression(multiExpression: MultiExpression, measureIndex: number, staffIndex: number): void;
protected createMetronomeMark(metronomeExpression: InstantaneousTempoExpression): void;
/** Convert MetronomeNoteGroup data into the format expected by VexFlow's StaveTempo.drawNoteEquation(). */
private buildNoteEquationForVexFlow;
protected calculateRehearsalMark(measure: SourceMeasure): void;
/**
* Calculate a single OctaveShift for a [[MultiExpression]].
* @param sourceMeasure
* @param multiExpression
* @param measureIndex
* @param staffIndex
*/
protected calculateSingleOctaveShift(sourceMeasure: SourceMeasure, multiExpression: MultiExpression, measureIndex: number, staffIndex: number): void;
/** Finds the last staffline measure that has staffentries. (staffentries necessary for octaveshift and pedal) */
protected findLastStafflineMeasure(staffline: StaffLine): GraphicalMeasure;
protected calculateSinglePedal(sourceMeasure: SourceMeasure, multiExpression: MultiExpression, measureIndex: number, staffIndex: number): void;
protected calculateSingleWavyLine(sourceMeasure: SourceMeasure, multiExpression: MultiExpression, measureIndex: number, staffIndex: number): void;
private calculateWavyLineSkyBottomLine;
private calculatePedalSkyBottomLine;
private calculateOctaveShiftSkyBottomLine;
/**
* Calculate all the textual and symbolic [[RepetitionInstruction]]s (e.g. dal segno) for a single [[SourceMeasure]].
* @param repetitionInstruction
* @param measureIndex
*/
protected calculateWordRepetitionInstruction(repetitionInstruction: RepetitionInstruction, measureIndex: number): void;
protected calculateSkyBottomLines(): void;
/**
* Re-adjust the x positioning of expressions. Update the skyline afterwards
*/
protected calculateExpressionAlignements(): void;
/**
* Check if the tied graphical note belongs to any beams or tuplets and react accordingly.
* @param tiedGraphicalNote
* @param beams
* @param activeClef
* @param octaveShiftValue
* @param graphicalStaffEntry
* @param duration
* @param openTie
* @param isLastTieNote
*/
protected handleTiedGraphicalNote(tiedGraphicalNote: GraphicalNote, beams: Beam[], activeClef: ClefInstruction, octaveShiftValue: OctaveEnum, graphicalStaffEntry: GraphicalStaffEntry, duration: Fraction, openTie: Tie, isLastTieNote: boolean): void;
/**
* Is called if a note is part of a beam.
* @param graphicalNote
* @param beam
* @param openBeams a list of all currently open beams
*/
protected handleBeam(graphicalNote: GraphicalNote, beam: Beam, openBeams: Beam[]): void;
protected handleVoiceEntryLyrics(voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry, lyricWords: LyricWord[]): void;
protected handleVoiceEntryOrnaments(ornamentContainer: OrnamentContainer, voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry): void;
/**
* Add articulations to the given vexflow staff entry.
* @param articulations
* @param voiceEntry
* @param graphicalStaffEntry
*/
protected handleVoiceEntryArticulations(articulations: Articulation[], voiceEntry: VoiceEntry, staffEntry: GraphicalStaffEntry): void;
/**
* Add technical instructions to the given vexflow staff entry.
* @param technicalInstructions
* @param voiceEntry
* @param staffEntry
*/
protected handleVoiceEntryTechnicalInstructions(technicalInstructions: TechnicalInstruction[], voiceEntry: VoiceEntry, staffEntry: GraphicalStaffEntry): void;
/**
* Is called if a note is part of a tuplet.
* @param graphicalNote
* @param tuplet
* @param openTuplets a list of all currently open tuplets
*/
protected handleTuplet(graphicalNote: GraphicalNote, tuplet: Tuplet, openTuplets: Tuplet[]): void;
/**
* Find the Index of the item of the array of all VexFlow Slurs that holds a specified slur
* @param gSlurs
* @param slur
*/
findIndexGraphicalSlurFromSlur(gSlurs: GraphicalSlur[], slur: Slur): number;
indexOfGraphicalGlissFromGliss(gGlissandi: GraphicalGlissando[], glissando: Glissando): number;
protected calculateSlurs(): void;
calculateGlissandi(): void;
}