UNPKG

orpheus-osmd

Version:

An open source JavaScript engine for displaying MusicXML based on VexFlow.

212 lines (211 loc) 7.57 kB
import { GraphicalMeasure } from "./GraphicalMeasure"; import { MusicSystem } from "./MusicSystem"; import { SystemLinesEnum } from "./SystemLinesEnum"; import { GraphicalMusicSheet } from "./GraphicalMusicSheet"; export declare class MusicSystemBuilder { private measureList; private graphicalMusicSheet; private currentSystemParams; private numberOfVisibleStaffLines; private rules; private measureListIndex; private musicSystems; /** * Does the mapping from the currently visible staves to the global staff-list of the music sheet. */ private visibleStaffIndices; private activeRhythm; private activeKeys; private activeClefs; private globalSystemIndex; private leadSheet; initialize(graphicalMusicSheet: GraphicalMusicSheet, measureList: GraphicalMeasure[][], numberOfStaffLines: number): void; buildMusicSystems(): MusicSystem[]; /** * calculates the y positions of the staff lines within a system and * furthermore the y positions of the systems themselves. */ calculateSystemYLayout(): void; /** * Set the Width of the staff-Measures of one source measure. * @param graphicalMeasures * @param width * @param beginInstrWidth * @param endInstrWidth */ private setMeasureWidth; /** * When the actual source measure doesn't fit any more, this method finalizes the current system and * opens up a new empty system, where the actual measure will be added in the next iteration. * @param measures * @param isPartEndingSystem */ private finalizeCurrentAndCreateNewSystem; /** * If a line repetition is ending and a new line repetition is starting at the end of the system, * the double repetition line has to be split into two: one at the currently ending system and * one at the next system. * (this should be refactored at some point to not use a combined end/start line but always separated lines) */ private adaptRepetitionLineWithIfNeeded; private addMeasureToSystem; /** * Initialize a new [[MusicSystem]]. * @returns {MusicSystem} */ private initMusicSystem; /** * Get the width the system should have for a given page width. * @returns {number} */ private getFullPageSystemWidth; private layoutSystemStaves; /** * Calculate the [[StaffLine]](s) needed for a [[MusicSystem]]. * @param musicSystem * @param relativeYPosition * @param staff */ private addStaffLineToMusicSystem; /** * Initialize the active Instructions from the first [[SourceMeasure]] of first [[SourceMusicPart]]. * @param measureList */ private initializeActiveInstructions; private transposeKeyInstruction; /** * Calculate the width needed for Instructions (Key, Clef, Rhythm, Repetition) for the measure. * @param measures * @param isSystemFirstMeasure * @param isFirstSourceMeasure * @returns {number} */ private addBeginInstructions; /** * Calculates the width needed for Instructions (Clef, Repetition) for the measure. * @param measures * @returns {number} */ private addEndInstructions; private AddInstructionsAtMeasureBegin; private addInstructionsAtMeasureEnd; /** * Track down and update the active ClefInstruction in Measure's StaffEntries. * This has to be done after the measure is added to a system * (otherwise already the check if the measure fits to the system would update the active clefs..) * @param measure * @param graphicalMeasures */ private updateActiveClefs; /** * Check if an extra Instruction [[Measure]] is needed. * @param measures */ private checkAndCreateExtraInstructionMeasure; private addExtraInstructionMeasure; /** * Add all current vertical Measures to currentSystem. * @param graphicalMeasures */ private addStaveMeasuresToSystem; /** * Return the width of the corresponding [[SystemLine]] and set the corresponding [[SystemLineEnum]]. * @returns {SystemLinesEnum} */ private getMeasureStartLine; private getMeasureEndLine; /** * Return the width of the corresponding [[SystemLine]] and sets the corresponding [[SystemLineEnum]]. * @param measure * @param systemLineEnum * @param isSystemStartMeasure * @returns {number} */ private getLineWidth; private previousMeasureEndsLineRepetition; /** * Check if at this [[Measure]] starts a [[Repetition]]. * @returns {boolean} */ private thisMeasureBeginsLineRepetition; /** * Check if a [[Repetition]] starts at the next [[Measure]]. * @returns {boolean} */ private nextMeasureBeginsLineRepetition; /** * Check if this [[Measure]] is a [[Repetition]] ending. * @returns {boolean} */ private thisMeasureEndsLineRepetition; /** * Check if a [[Repetition]] starts at the next [[Measure]]. * @returns {boolean} */ private nextMeasureBeginsWordRepetition; /** * Check if this [[Measure]] is a [[Repetition]] ending. * @returns {boolean} */ private thisMeasureEndsWordRepetition; /** * Check if the next [[Measure]] has a [[KeyInstruction]] change. * @returns {boolean} */ private nextMeasureHasKeyInstructionChange; private getNextMeasureKeyInstruction; /** * Calculate the X ScalingFactor in order to strech the whole System. * @param systemFixWidth * @param systemVarWidth * @returns {number} */ private calculateXScalingFactor; /** * Stretch the whole System so that no white space is left at the end. * @param isPartEndingSystem */ private stretchMusicSystem; /** * If the last [[MusicSystem]] doesn't need stretching, then this method decreases the System's Width, * the [[StaffLine]]'s Width and the 5 [[StaffLine]]s length. */ private decreaseMusicSystemBorders; /** * This method checks the distances between any two consecutive StaffLines of a System and if needed, shifts the lower one down. * @param musicSystem */ private optimizeDistanceBetweenStaffLines; /** * This method updates the System's StaffLine's RelativePosition (starting from the given index). * @param musicSystem * @param index * @param value */ private updateStaffLinesRelativePosition; /** * Create a new [[GraphicalMusicPage]] * (for now only one long page is used per music sheet, as we scroll down and have no page flips) * @returns {GraphicalMusicPage} */ private createMusicPage; private addSystemToPage; /** Calculates the relative Positions of all MusicSystems. * */ private calculateMusicSystemsRelativePositions; } export declare class SystemBuildParameters { currentSystem: MusicSystem; systemMeasures: MeasureBuildParameters[]; systemMeasureIndex: number; currentWidth: number; currentSystemFixWidth: number; currentSystemVarWidth: number; maxLabelLength: number; IsSystemStartMeasure(): boolean; } export declare class MeasureBuildParameters { beginLine: SystemLinesEnum; endLine: SystemLinesEnum; }