MusicSheetCalculator.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import { GraphicalStaffEntry } from "./GraphicalStaffEntry";
  2. import { StaffLine } from "./StaffLine";
  3. import { GraphicalMusicSheet } from "./GraphicalMusicSheet";
  4. import { EngravingRules } from "./EngravingRules";
  5. import { Tie } from "../VoiceData/Tie";
  6. import { Fraction } from "../../Common/DataObjects/fraction";
  7. import { Note } from "../VoiceData/Note";
  8. import { StaffMeasure } from "./StaffMeasure";
  9. import { ClefInstruction } from "../VoiceData/Instructions/ClefInstruction";
  10. import { LyricWord } from "../VoiceData/Lyrics/LyricsWord";
  11. import { SourceMeasure } from "../VoiceData/SourceMeasure";
  12. import { GraphicalMusicPage } from "./GraphicalMusicPage";
  13. import { GraphicalNote } from "./GraphicalNote";
  14. import { Beam } from "../VoiceData/Beam";
  15. import { OctaveEnum } from "../VoiceData/Expressions/ContinuousExpressions/octaveShift";
  16. import { LyricsEntry } from "../VoiceData/Lyrics/LyricsEntry";
  17. import { VoiceEntry } from "../VoiceData/VoiceEntry";
  18. import { OrnamentContainer } from "../VoiceData/OrnamentContainer";
  19. import { ArticulationEnum } from "../VoiceData/VoiceEntry";
  20. import { Tuplet } from "../VoiceData/Tuplet";
  21. import { MusicSystem } from "./MusicSystem";
  22. import { GraphicalTie } from "./GraphicalTie";
  23. import { RepetitionInstruction } from "../VoiceData/Instructions/RepetitionInstruction";
  24. import { MultiExpression } from "../VoiceData/Expressions/multiExpression";
  25. import { StaffEntryLink } from "../VoiceData/StaffEntryLink";
  26. import { MultiTempoExpression } from "../VoiceData/Expressions/multiTempoExpression";
  27. import { Repetition } from "../MusicSource/Repetition";
  28. import { PointF2D } from "../../Common/DataObjects/PointF2D";
  29. import { SourceStaffEntry } from "../VoiceData/SourceStaffEntry";
  30. import { BoundingBox } from "./BoundingBox";
  31. import { IGraphicalSymbolFactory } from "../Interfaces/IGraphicalSymbolFactory";
  32. import { ITextMeasurer } from "../Interfaces/ITextMeasurer";
  33. import { ITransposeCalculator } from "../Interfaces/ITransposeCalculator";
  34. import { OctaveShiftParams } from "./OctaveShiftParams";
  35. import { AccidentalCalculator } from "./AccidentalCalculator";
  36. import Dictionary from "typescript-collections/dist/lib/Dictionary";
  37. export declare abstract class MusicSheetCalculator {
  38. static transposeCalculator: ITransposeCalculator;
  39. protected static textMeasurer: ITextMeasurer;
  40. protected staffEntriesWithGraphicalTies: GraphicalStaffEntry[];
  41. protected staffEntriesWithOrnaments: GraphicalStaffEntry[];
  42. protected staffEntriesWithChordSymbols: GraphicalStaffEntry[];
  43. protected staffLinesWithLyricWords: StaffLine[];
  44. protected staffLinesWithGraphicalExpressions: StaffLine[];
  45. protected graphicalMusicSheet: GraphicalMusicSheet;
  46. protected rules: EngravingRules;
  47. protected symbolFactory: IGraphicalSymbolFactory;
  48. constructor(symbolFactory: IGraphicalSymbolFactory);
  49. static TextMeasurer: ITextMeasurer;
  50. protected leadSheet: boolean;
  51. private static addTieToTieTimestampsDict(tieTimestampListDict, note);
  52. private static setMeasuresMinStaffEntriesWidth(measures, minimumStaffEntriesWidth);
  53. initialize(graphicalMusicSheet: GraphicalMusicSheet): void;
  54. prepareGraphicalMusicSheet(): void;
  55. calculate(): void;
  56. calculateXLayout(graphicalMusicSheet: GraphicalMusicSheet, maxInstrNameLabelLength: number): void;
  57. protected calculateMeasureXLayout(measures: StaffMeasure[]): number;
  58. protected calculateSystemYLayout(): void;
  59. protected initStaffMeasuresCreation(): void;
  60. protected handleBeam(graphicalNote: GraphicalNote, beam: Beam, openBeams: Beam[]): void;
  61. protected createGraphicalTieNote(beams: Beam[], activeClef: ClefInstruction, octaveShiftValue: OctaveEnum, graphicalStaffEntry: GraphicalStaffEntry, duration: Fraction, numberOfDots: number, openTie: Tie, isLastTieNote: boolean): void;
  62. protected handleVoiceEntryLyrics(lyricsEntries: Dictionary<number, LyricsEntry>, voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry, openLyricWords: LyricWord[]): void;
  63. protected handleVoiceEntryOrnaments(ornamentContainer: OrnamentContainer, voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry): void;
  64. protected handleVoiceEntryArticulations(articulations: ArticulationEnum[], voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry): void;
  65. protected handleTuplet(graphicalNote: GraphicalNote, tuplet: Tuplet, openTuplets: Tuplet[]): void;
  66. protected layoutVoiceEntry(voiceEntry: VoiceEntry, graphicalNotes: GraphicalNote[], graphicalStaffEntry: GraphicalStaffEntry, hasPitchedNote: boolean, isGraceStaffEntry: boolean): void;
  67. protected layoutStaffEntry(graphicalStaffEntry: GraphicalStaffEntry): void;
  68. protected handleTie(tie: Tie, startGraphicalStaffEntry: GraphicalStaffEntry, staffIndex: number, measureIndex: number): void;
  69. protected updateStaffLineBorders(staffLine: StaffLine): void;
  70. protected calculateMeasureNumberPlacement(musicSystem: MusicSystem): void;
  71. protected layoutGraphicalTie(tie: GraphicalTie, tieIsAtSystemBreak: boolean): void;
  72. protected calculateSingleStaffLineLyricsPosition(staffLine: StaffLine, lyricVersesNumber: number[]): void;
  73. protected calculateSingleOctaveShift(sourceMeasure: SourceMeasure, multiExpression: MultiExpression, measureIndex: number, staffIndex: number): void;
  74. protected calculateWordRepetitionInstruction(repetitionInstruction: RepetitionInstruction, measureIndex: number): void;
  75. protected calculateMoodAndUnknownExpression(multiExpression: MultiExpression, measureIndex: number, staffIndex: number): void;
  76. protected clearRecreatedObjects(): void;
  77. protected handleStaffEntryLink(graphicalStaffEntry: GraphicalStaffEntry, staffEntryLinks: StaffEntryLink[]): void;
  78. protected calculateMusicSystems(): void;
  79. protected updateSkyBottomLine(staffLine: StaffLine): void;
  80. protected calculateSkyBottomLine(staffLine: StaffLine): void;
  81. protected calculateMarkedAreas(): void;
  82. protected calculateComments(): void;
  83. protected optimizeStaffLineDynamicExpressionsPositions(): void;
  84. protected calculateChordSymbols(): void;
  85. protected layoutMeasureWithWholeRest(rest: GraphicalNote, gse: GraphicalStaffEntry, measure: StaffMeasure): void;
  86. protected layoutBeams(staffEntry: GraphicalStaffEntry): void;
  87. protected layoutArticulationMarks(articulations: ArticulationEnum[], voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry): void;
  88. protected layoutOrnament(ornaments: OrnamentContainer, voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry): void;
  89. protected calculateRestNotePlacementWithinGraphicalBeam(graphicalStaffEntry: GraphicalStaffEntry, restNote: GraphicalNote, previousNote: GraphicalNote, nextStaffEntry: GraphicalStaffEntry, nextNote: GraphicalNote): void;
  90. protected calculateTupletNumbers(): void;
  91. protected calculateSlurs(): void;
  92. protected calculateDynamicExpressionsForSingleMultiExpression(multiExpression: MultiExpression, measureIndex: number, staffIndex: number): void;
  93. protected calcGraphicalRepetitionEndingsRecursively(repetition: Repetition): void;
  94. protected layoutSingleRepetitionEnding(start: StaffMeasure, end: StaffMeasure, numberText: string, offset: number, leftOpen: boolean, rightOpen: boolean): void;
  95. protected calculateTempoExpressionsForSingleMultiTempoExpression(sourceMeasure: SourceMeasure, multiTempoExpression: MultiTempoExpression, measureIndex: number): void;
  96. protected clearSystemsAndMeasures(): void;
  97. protected handleVoiceEntry(voiceEntry: VoiceEntry, graphicalStaffEntry: GraphicalStaffEntry, accidentalCalculator: AccidentalCalculator, openLyricWords: LyricWord[], tieTimestampListDict: Dictionary<Tie, Fraction[]>, activeClef: ClefInstruction, openTuplets: Tuplet[], openBeams: Beam[], octaveShiftValue: OctaveEnum, grace?: boolean, linkedNotes?: Note[], sourceStaffEntry?: SourceStaffEntry): OctaveEnum;
  98. protected handleVoiceEntryGraceNotes(graceEntries: VoiceEntry[], graphicalGraceEntries: GraphicalStaffEntry[], graphicalStaffEntry: GraphicalStaffEntry, accidentalCalculator: AccidentalCalculator, activeClef: ClefInstruction, octaveShiftValue: OctaveEnum, lyricWords: LyricWord[], tieTimestampListDict: Dictionary<Tie, Fraction[]>, tuplets: Tuplet[], beams: Beam[]): void;
  99. protected handleOpenTies(measure: StaffMeasure, beams: Beam[], tieTimestampListDict: Dictionary<Tie, Fraction[]>, activeClef: ClefInstruction, octaveShiftParams: OctaveShiftParams): void;
  100. protected resetYPositionForLeadSheet(psi: BoundingBox): void;
  101. protected layoutVoiceEntries(graphicalStaffEntry: GraphicalStaffEntry): void;
  102. protected maxInstrNameLabelLength(): number;
  103. protected calculateSheetLabelBoundingBoxes(): void;
  104. protected checkMeasuresForWholeRestNotes(): void;
  105. protected optimizeRestNotePlacement(graphicalStaffEntry: GraphicalStaffEntry, measure: StaffMeasure): void;
  106. protected getRelativePositionInStaffLineFromTimestamp(timestamp: Fraction, verticalIndex: number, staffLine: StaffLine, multiStaffInstrument: boolean, firstVisibleMeasureRelativeX?: number): PointF2D;
  107. protected getRelativeXPositionFromTimestamp(timestamp: Fraction): number;
  108. protected calculatePageLabels(page: GraphicalMusicPage): void;
  109. protected createGraphicalTies(): void;
  110. private createAccidentalCalculators();
  111. private calculateVerticalContainersList();
  112. private setIndecesToVerticalGraphicalContainers();
  113. private createGraphicalMeasuresForSourceMeasure(sourceMeasure, accidentalCalculators, openLyricWords, tieTimestampListDictList, openOctaveShifts, activeClefs);
  114. private createGraphicalMeasure(sourceMeasure, tieTimestampListDict, openTuplets, openBeams, accidentalCalculator, activeClefs, openOctaveShifts, openLyricWords, staffIndex, staffEntryLinks);
  115. private checkVoiceEntriesForTechnicalInstructions(voiceEntry, graphicalStaffEntry);
  116. private checkNoteForAccidental(graphicalNote, accidentalCalculator, activeClef, octaveEnum, grace?);
  117. private createStaffEntryForTieNote(measure, absoluteTimestamp, openTie);
  118. private updateSkyBottomLines();
  119. private handleStaffEntries();
  120. private calculateSkyBottomLines();
  121. private calculateBeams();
  122. private calculateStaffEntryArticulationMarks();
  123. private calculateOrnaments();
  124. private optimizeRestPlacement();
  125. private calculateTwoRestNotesPlacementWithCollisionDetection(graphicalStaffEntry);
  126. private calculateRestNotePlacementWithCollisionDetectionFromGraphicalNote(graphicalStaffEntry);
  127. private calculateTieCurves();
  128. private calculateLyricsPosition();
  129. private calculateDynamicExpressions();
  130. private calculateOctaveShifts();
  131. private getFirstLeftNotNullStaffEntryFromContainer(horizontalIndex, verticalIndex, multiStaffInstrument);
  132. private getFirstRightNotNullStaffEntryFromContainer(horizontalIndex, verticalIndex, multiStaffInstrument);
  133. private calculateWordRepetitionInstructions();
  134. private calculateRepetitionEndings();
  135. private calculateTempoExpressions();
  136. private calculateMoodAndUnknownExpressions();
  137. }