EngravingRules.ts 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709
  1. import { PagePlacementEnum } from "./GraphicalMusicPage";
  2. //import {MusicSymbol} from "./MusicSymbol";
  3. import log from "loglevel";
  4. import { TextAlignmentEnum } from "../../Common/Enums/TextAlignment";
  5. import { PlacementEnum } from "../VoiceData/Expressions/AbstractExpression";
  6. import { AutoBeamOptions, AlignRestOption, FillEmptyMeasuresWithWholeRests } from "../../OpenSheetMusicDisplay/OSMDOptions";
  7. import { ColoringModes as ColoringMode } from "./DrawingParameters";
  8. import { Dictionary } from "typescript-collections";
  9. import { NoteEnum } from "../..";
  10. export class EngravingRules {
  11. /** A unit of distance. 1.0 is the distance between lines of a stave for OSMD, which is 10 pixels in Vexflow. */
  12. private static unit: number = 1.0;
  13. private samplingUnit: number;
  14. private staccatoShorteningFactor: number;
  15. /** Height (size) of the sheet title. */
  16. private sheetTitleHeight: number;
  17. private sheetSubtitleHeight: number;
  18. private sheetMinimumDistanceBetweenTitleAndSubtitle: number;
  19. private sheetComposerHeight: number;
  20. private sheetAuthorHeight: number;
  21. private compactMode: boolean;
  22. private pagePlacementEnum: PagePlacementEnum;
  23. private pageHeight: number;
  24. private pageTopMargin: number;
  25. private pageTopMarginNarrow: number;
  26. private pageBottomMargin: number;
  27. private pageLeftMargin: number;
  28. private pageRightMargin: number;
  29. private titleTopDistance: number;
  30. private titleBottomDistance: number;
  31. private systemLeftMargin: number;
  32. private systemRightMargin: number;
  33. private firstSystemMargin: number;
  34. private systemLabelsRightMargin: number;
  35. private systemComposerDistance: number;
  36. private instrumentLabelTextHeight: number;
  37. private minimumDistanceBetweenSystems: number;
  38. private lastSystemMaxScalingFactor: number;
  39. private staffDistance: number;
  40. private betweenStaffDistance: number;
  41. private staffHeight: number;
  42. private tabStaffHeight: number;
  43. private betweenStaffLinesDistance: number;
  44. /** Whether to automatically beam notes that don't already have beams in XML. */
  45. private autoBeamNotes: boolean;
  46. /** Options for autoBeaming like whether to beam over rests. See AutoBeamOptions interface. */
  47. private autoBeamOptions: AutoBeamOptions;
  48. private beamWidth: number;
  49. private beamSpaceWidth: number;
  50. private beamForwardLength: number;
  51. private clefLeftMargin: number;
  52. private clefRightMargin: number;
  53. private betweenKeySymbolsDistance: number;
  54. private keyRightMargin: number;
  55. private rhythmRightMargin: number;
  56. private inStaffClefScalingFactor: number;
  57. private distanceBetweenNaturalAndSymbolWhenCancelling: number;
  58. private noteHelperLinesOffset: number;
  59. private measureLeftMargin: number;
  60. private measureRightMargin: number;
  61. private distanceBetweenLastInstructionAndRepetitionBarline: number;
  62. private arpeggioDistance: number;
  63. private idealStemLength: number;
  64. private stemNoteHeadBorderYOffset: number;
  65. private stemWidth: number;
  66. private stemMargin: number;
  67. private stemMinLength: number;
  68. private stemMaxLength: number;
  69. private beamSlopeMaxAngle: number;
  70. private stemMinAllowedDistanceBetweenNoteHeadAndBeamLine: number;
  71. private setWantedStemDirectionByXml: boolean;
  72. private graceNoteScalingFactor: number;
  73. private graceNoteXOffset: number;
  74. private wedgeOpeningLength: number;
  75. private wedgeMeasureEndOpeningLength: number;
  76. private wedgeMeasureBeginOpeningLength: number;
  77. private wedgePlacementAboveY: number;
  78. private wedgePlacementBelowY: number;
  79. private wedgeHorizontalMargin: number;
  80. private wedgeVerticalMargin: number;
  81. private distanceOffsetBetweenTwoHorizontallyCrossedWedges: number;
  82. private wedgeMinLength: number;
  83. private distanceBetweenAdjacentDynamics: number;
  84. private tempoChangeMeasureValidity: number;
  85. private tempoContinousFactor: number;
  86. private staccatoScalingFactor: number;
  87. private betweenDotsDistance: number;
  88. private ornamentAccidentalScalingFactor: number;
  89. private chordSymbolTextHeight: number;
  90. private chordSymbolXSpacing: number;
  91. private chordSymbolYOffset: number;
  92. private fingeringLabelFontHeight: number;
  93. private measureNumberLabelHeight: number;
  94. private measureNumberLabelOffset: number;
  95. /** Whether tuplets should display ratio (3:2 instead of 3 for triplet). Default false. */
  96. private tupletsRatioed: boolean;
  97. /** Whether all tuplets should be bracketed (e.g. |--5--| instead of 5). Default false.
  98. * If false, only tuplets given as bracketed in XML (bracket="yes") will be bracketed.
  99. * (If not given in XML, bracketing is implementation-dependent according to standard)
  100. */
  101. private tupletsBracketed: boolean;
  102. /** Whether all triplets should be bracketed. Overrides tupletsBracketed for triplets.
  103. * If false, only triplets given as bracketed in XML (bracket="yes") will be bracketed.
  104. * (Bracketing all triplets can be cluttering)
  105. */
  106. private tripletsBracketed: boolean;
  107. private tupletNumberLabelHeight: number;
  108. private tupletNumberYOffset: number;
  109. private labelMarginBorderFactor: number;
  110. private tupletVerticalLineLength: number;
  111. private repetitionEndingLabelHeight: number;
  112. private repetitionEndingLabelXOffset: number;
  113. private repetitionEndingLabelYOffset: number;
  114. private repetitionEndingLineYLowerOffset: number;
  115. private repetitionEndingLineYUpperOffset: number;
  116. private voltaOffset: number;
  117. /** Default alignment of lyrics.
  118. * Left alignments will extend text to the right of the bounding box,
  119. * which facilitates spacing by extending measure width.
  120. */
  121. private lyricsAlignmentStandard: TextAlignmentEnum;
  122. private lyricsHeight: number;
  123. private lyricsYOffsetToStaffHeight: number;
  124. private verticalBetweenLyricsDistance: number;
  125. private horizontalBetweenLyricsDistance: number;
  126. private betweenSyllableMaximumDistance: number;
  127. private betweenSyllableMinimumDistance: number;
  128. private lyricOverlapAllowedIntoNextMeasure: number;
  129. private minimumDistanceBetweenDashes: number;
  130. private bezierCurveStepSize: number;
  131. private tPower3: number[];
  132. private oneMinusTPower3: number[];
  133. private factorOne: number[];
  134. private factorTwo: number[];
  135. private tieGhostObjectWidth: number;
  136. private tieYPositionOffsetFactor: number;
  137. private minimumNeededXspaceForTieGhostObject: number;
  138. private tieHeightMinimum: number;
  139. private tieHeightMaximum: number;
  140. private tieHeightInterpolationK: number;
  141. private tieHeightInterpolationD: number;
  142. private slurNoteHeadYOffset: number;
  143. private slurStemXOffset: number;
  144. private slurSlopeMaxAngle: number;
  145. private slurTangentMinAngle: number;
  146. private slurTangentMaxAngle: number;
  147. private slursStartingAtSameStaffEntryYOffset: number;
  148. private instantaneousTempoTextHeight: number;
  149. private continuousDynamicTextHeight: number;
  150. private moodTextHeight: number;
  151. private unknownTextHeight: number;
  152. private continuousTempoTextHeight: number;
  153. private staffLineWidth: number;
  154. private ledgerLineWidth: number;
  155. private wedgeLineWidth: number;
  156. private tupletLineWidth: number;
  157. private lyricUnderscoreLineWidth: number;
  158. private systemThinLineWidth: number;
  159. private systemBoldLineWidth: number;
  160. private systemRepetitionEndingLineWidth: number;
  161. private systemDotWidth: number;
  162. private distanceBetweenVerticalSystemLines: number;
  163. private distanceBetweenDotAndLine: number;
  164. private octaveShiftLineWidth: number;
  165. private octaveShiftVerticalLineLength: number;
  166. private graceLineWidth: number;
  167. private minimumStaffLineDistance: number;
  168. private minimumCrossedBeamDifferenceMargin: number;
  169. private displacedNoteMargin: number;
  170. private minNoteDistance: number;
  171. private subMeasureXSpacingThreshold: number;
  172. private measureDynamicsMaxScalingFactor: number;
  173. private wholeRestXShiftVexflow: number;
  174. private metronomeMarkXShift: number;
  175. private metronomeMarkYShift: number;
  176. private maxInstructionsConstValue: number;
  177. private noteDistances: number[] = [1.0, 1.0, 1.3, 1.6, 2.0, 2.5, 3.0, 4.0];
  178. private noteDistancesScalingFactors: number[] = [1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0];
  179. private durationDistanceDict: {[_: number]: number; } = {};
  180. private durationScalingDistanceDict: {[_: number]: number; } = {};
  181. private alignRests: number; // 0 = false, 1 = true, 2 = auto
  182. private fillEmptyMeasuresWithWholeRest: FillEmptyMeasuresWithWholeRests | number;
  183. private arpeggiosGoAcrossVoices: boolean;
  184. private renderArpeggios: boolean;
  185. private renderSlurs: boolean;
  186. private coloringMode: ColoringMode;
  187. private coloringEnabled: boolean;
  188. private colorStemsLikeNoteheads: boolean;
  189. private colorFlags: boolean;
  190. private colorBeams: boolean;
  191. private coloringSetCustom: Dictionary<NoteEnum|number, string>;
  192. private defaultColorNotehead: string;
  193. private defaultColorRest: string;
  194. private defaultColorStem: string;
  195. private defaultColorLabel: string;
  196. private defaultColorTitle: string;
  197. private defaultFontFamily: string;
  198. private maxMeasureToDrawIndex: number;
  199. private minMeasureToDrawIndex: number;
  200. /** Whether to render a label for the composer of the piece at the top of the sheet. */
  201. private renderComposer: boolean;
  202. private renderTitle: boolean;
  203. private renderSubtitle: boolean;
  204. private renderLyricist: boolean;
  205. private renderPartNames: boolean;
  206. private renderPartAbbreviations: boolean;
  207. private renderFingerings: boolean;
  208. private renderMeasureNumbers: boolean;
  209. private renderLyrics: boolean;
  210. private dynamicExpressionMaxDistance: number;
  211. private dynamicExpressionSpacer: number;
  212. /** Position of fingering label in relation to corresponding note (left, right supported, above, below experimental) */
  213. private fingeringPosition: PlacementEnum;
  214. private fingeringInsideStafflines: boolean;
  215. private newSystemAtXMLNewSystemAttribute: boolean;
  216. private newPageAtXMLNewPageAttribute: boolean;
  217. private pageFormat: PageFormat;
  218. private pageBackgroundColor: string; // vexflow-color-string (#FFFFFF). Default undefined/transparent.
  219. private renderSingleHorizontalStaffline: boolean;
  220. private restoreCursorAfterRerender: boolean;
  221. private static fixStafflineBoundingBox: boolean; // TODO temporary workaround
  222. constructor() {
  223. // global variables
  224. this.samplingUnit = EngravingRules.unit * 3;
  225. // Page Label Variables
  226. this.sheetTitleHeight = 4.0;
  227. this.sheetSubtitleHeight = 2.0;
  228. this.sheetMinimumDistanceBetweenTitleAndSubtitle = 1.0;
  229. this.sheetComposerHeight = 2.0;
  230. this.sheetAuthorHeight = 2.0;
  231. // Staff sizing Variables
  232. this.compactMode = false;
  233. this.pagePlacementEnum = PagePlacementEnum.Down;
  234. this.pageHeight = 100001.0;
  235. this.pageTopMargin = 5.0;
  236. this.pageTopMarginNarrow = 0.0; // for compact mode
  237. this.pageBottomMargin = 5.0;
  238. this.pageLeftMargin = 5.0;
  239. this.pageRightMargin = 5.0;
  240. this.titleTopDistance = 9.0;
  241. this.titleBottomDistance = 1.0;
  242. this.staffDistance = 7.0;
  243. this.betweenStaffDistance = 5.0;
  244. // System Sizing and Label Variables
  245. this.staffHeight = 4.0;
  246. this.tabStaffHeight = 6.67;
  247. this.betweenStaffLinesDistance = EngravingRules.unit;
  248. this.systemLeftMargin = 0.0;
  249. this.systemRightMargin = 0.0;
  250. this.firstSystemMargin = 15.0;
  251. this.systemLabelsRightMargin = 2.0;
  252. this.systemComposerDistance = 2.0;
  253. this.instrumentLabelTextHeight = 2;
  254. this.minimumDistanceBetweenSystems = 4.0;
  255. this.lastSystemMaxScalingFactor = 1.4;
  256. // autoBeam options
  257. this.autoBeamNotes = false;
  258. this.autoBeamOptions = {
  259. beam_middle_rests_only: false,
  260. beam_rests: false,
  261. maintain_stem_directions: false
  262. };
  263. // Beam Sizing Variables
  264. this.beamWidth = EngravingRules.unit / 2.0;
  265. this.beamSpaceWidth = EngravingRules.unit / 3.0;
  266. this.beamForwardLength = 1.25 * EngravingRules.unit;
  267. // Beam Sizing Variables
  268. this.clefLeftMargin = 0.5;
  269. this.clefRightMargin = 0.75;
  270. this.betweenKeySymbolsDistance = 0.2;
  271. this.keyRightMargin = 0.75;
  272. this.rhythmRightMargin = 1.25;
  273. this.inStaffClefScalingFactor = 0.8;
  274. this.distanceBetweenNaturalAndSymbolWhenCancelling = 0.4;
  275. // Beam Sizing Variables
  276. this.noteHelperLinesOffset = 0.25;
  277. this.measureLeftMargin = 0.7;
  278. this.measureRightMargin = 0.0;
  279. this.distanceBetweenLastInstructionAndRepetitionBarline = 1.0;
  280. this.arpeggioDistance = 0.6;
  281. // Stems Variables
  282. this.staccatoShorteningFactor = 2;
  283. this.idealStemLength = 3.0;
  284. this.stemNoteHeadBorderYOffset = 0.2;
  285. this.stemWidth = 0.13;
  286. this.stemMargin = 0.2;
  287. this.stemMinLength = 2.5;
  288. this.stemMaxLength = 4.5;
  289. this.beamSlopeMaxAngle = 10.0;
  290. this.stemMinAllowedDistanceBetweenNoteHeadAndBeamLine = 1.0;
  291. this.setWantedStemDirectionByXml = true;
  292. // GraceNote Variables
  293. this.graceNoteScalingFactor = 0.6;
  294. this.graceNoteXOffset = 0.2;
  295. // Wedge Variables
  296. this.wedgeOpeningLength = 1.2;
  297. this.wedgeMeasureEndOpeningLength = 0.75;
  298. this.wedgeMeasureBeginOpeningLength = 0.75;
  299. this.wedgePlacementAboveY = -1.5;
  300. this.wedgePlacementBelowY = 1.5;
  301. this.wedgeHorizontalMargin = 0.6;
  302. this.wedgeVerticalMargin = 0.5;
  303. this.distanceOffsetBetweenTwoHorizontallyCrossedWedges = 0.3;
  304. this.wedgeMinLength = 2.0;
  305. this.distanceBetweenAdjacentDynamics = 0.75;
  306. // Tempo Variables
  307. this.tempoChangeMeasureValidity = 4;
  308. this.tempoContinousFactor = 0.7;
  309. // various
  310. this.staccatoScalingFactor = 0.8;
  311. this.betweenDotsDistance = 0.8;
  312. this.ornamentAccidentalScalingFactor = 0.65;
  313. this.chordSymbolTextHeight = 2.0;
  314. this.chordSymbolXSpacing = 1.0;
  315. this.chordSymbolYOffset = 2.0;
  316. this.fingeringLabelFontHeight = 1.7;
  317. // Tuplets, MeasureNumber and TupletNumber Labels
  318. this.measureNumberLabelHeight = 1.5 * EngravingRules.unit;
  319. this.measureNumberLabelOffset = 2;
  320. this.tupletsRatioed = false;
  321. this.tupletsBracketed = false;
  322. this.tripletsBracketed = false; // special setting for triplets, overrides tuplet setting (for triplets only)
  323. this.tupletNumberLabelHeight = 1.5 * EngravingRules.unit;
  324. this.tupletNumberYOffset = 0.5;
  325. this.labelMarginBorderFactor = 0.1;
  326. this.tupletVerticalLineLength = 0.5;
  327. // Slur and Tie variables
  328. this.bezierCurveStepSize = 1000;
  329. this.calculateCurveParametersArrays();
  330. this.tieGhostObjectWidth = 0.75;
  331. this.tieYPositionOffsetFactor = 0.3;
  332. this.minimumNeededXspaceForTieGhostObject = 1.0;
  333. this.tieHeightMinimum = 0.28;
  334. this.tieHeightMaximum = 1.2;
  335. this.tieHeightInterpolationK = 0.0288;
  336. this.tieHeightInterpolationD = 0.136;
  337. this.slurNoteHeadYOffset = 0.5;
  338. this.slurStemXOffset = 0.3;
  339. this.slurSlopeMaxAngle = 15.0;
  340. this.slurTangentMinAngle = 30.0;
  341. this.slurTangentMaxAngle = 80.0;
  342. this.slursStartingAtSameStaffEntryYOffset = 0.8;
  343. // Repetitions
  344. this.repetitionEndingLabelHeight = 2.0;
  345. this.repetitionEndingLabelXOffset = 0.5;
  346. this.repetitionEndingLabelYOffset = 0.3;
  347. this.repetitionEndingLineYLowerOffset = 0.5;
  348. this.repetitionEndingLineYUpperOffset = 0.3;
  349. this.voltaOffset = 2.5;
  350. // Lyrics
  351. this.lyricsAlignmentStandard = TextAlignmentEnum.LeftBottom; // CenterBottom and LeftBottom tested, spacing-optimized
  352. this.lyricsHeight = 2.0; // actually size of lyrics
  353. this.lyricsYOffsetToStaffHeight = 3.0; // distance between lyrics and staff. could partly be even lower/dynamic
  354. this.verticalBetweenLyricsDistance = 0.5;
  355. this.horizontalBetweenLyricsDistance = 0.2;
  356. this.betweenSyllableMaximumDistance = 10.0;
  357. this.betweenSyllableMinimumDistance = 0.5; // + 1.0 for CenterAlignment added in lyrics spacing
  358. this.lyricOverlapAllowedIntoNextMeasure = 3.4; // optimal for dashed last lyric, see Land der Berge
  359. this.minimumDistanceBetweenDashes = 10;
  360. // expressions variables
  361. this.instantaneousTempoTextHeight = 2.3;
  362. this.continuousDynamicTextHeight = 2.3;
  363. this.moodTextHeight = 2.3;
  364. this.unknownTextHeight = 2.0;
  365. this.continuousTempoTextHeight = 2.3;
  366. this.dynamicExpressionMaxDistance = 2;
  367. this.dynamicExpressionSpacer = 0.5;
  368. // Line Widths
  369. this.staffLineWidth = 0.12;
  370. this.ledgerLineWidth = 0.12;
  371. this.wedgeLineWidth = 0.12;
  372. this.tupletLineWidth = 0.12;
  373. this.lyricUnderscoreLineWidth = 0.12;
  374. this.systemThinLineWidth = 0.12;
  375. this.systemBoldLineWidth = EngravingRules.unit / 2.0;
  376. this.systemRepetitionEndingLineWidth = 0.12;
  377. this.systemDotWidth = EngravingRules.unit / 5.0;
  378. this.distanceBetweenVerticalSystemLines = 0.35;
  379. this.distanceBetweenDotAndLine = 0.7;
  380. this.octaveShiftLineWidth = 0.12;
  381. this.octaveShiftVerticalLineLength = EngravingRules.unit;
  382. this.graceLineWidth = this.staffLineWidth * this.GraceNoteScalingFactor;
  383. // Line Widths
  384. this.minimumStaffLineDistance = 1.0;
  385. this.minimumCrossedBeamDifferenceMargin = 0.0001;
  386. // xSpacing Variables
  387. this.displacedNoteMargin = 0.1;
  388. this.minNoteDistance = 2.0;
  389. this.subMeasureXSpacingThreshold = 35;
  390. this.measureDynamicsMaxScalingFactor = 2.5;
  391. this.wholeRestXShiftVexflow = -2.5; // VexFlow draws rest notes too far to the right
  392. this.metronomeMarkXShift = -6; // our unit, is taken * unitInPixels
  393. this.metronomeMarkYShift = -0.5;
  394. // Render options (whether to render specific or invisible elements)
  395. this.alignRests = AlignRestOption.Never; // 0 = false, 1 = true, 2 = auto
  396. this.fillEmptyMeasuresWithWholeRest = FillEmptyMeasuresWithWholeRests.No;
  397. this.arpeggiosGoAcrossVoices = false; // safe option, as otherwise arpeggios will always go across all voices in Vexflow, which is often unwanted
  398. this.renderArpeggios = true;
  399. this.renderSlurs = true;
  400. this.coloringMode = ColoringMode.XML;
  401. this.coloringEnabled = true;
  402. this.colorStemsLikeNoteheads = false;
  403. this.colorBeams = true;
  404. this.colorFlags = true;
  405. this.defaultColorNotehead = "#000000"; // black. undefined is only black if a note's color hasn't been changed before.
  406. this.defaultColorRest = this.defaultColorNotehead;
  407. this.defaultColorStem = this.defaultColorNotehead;
  408. this.defaultColorLabel = this.defaultColorNotehead;
  409. this.defaultColorTitle = this.defaultColorNotehead;
  410. this.defaultFontFamily = "Times New Roman"; // what OSMD was initially optimized for
  411. this.maxMeasureToDrawIndex = Number.MAX_VALUE;
  412. this.minMeasureToDrawIndex = 0;
  413. this.renderComposer = true;
  414. this.renderTitle = true;
  415. this.renderSubtitle = true;
  416. this.renderLyricist = true;
  417. this.renderPartNames = true;
  418. this.renderPartAbbreviations = true;
  419. this.renderFingerings = true;
  420. this.renderMeasureNumbers = true;
  421. this.renderLyrics = true;
  422. this.fingeringPosition = PlacementEnum.Left; // easier to get bounding box, and safer for vertical layout
  423. this.fingeringInsideStafflines = false;
  424. this.newSystemAtXMLNewSystemAttribute = false;
  425. this.newPageAtXMLNewPageAttribute = false;
  426. this.restoreCursorAfterRerender = true;
  427. EngravingRules.FixStafflineBoundingBox = false; // TODO temporary workaround
  428. this.pageFormat = PageFormat.UndefinedPageFormat; // default: undefined / 'infinite' height page, using the canvas'/container's width and height
  429. this.pageBackgroundColor = undefined; // default: transparent. half-transparent white: #FFFFFF88"
  430. this.renderSingleHorizontalStaffline = false;
  431. this.populateDictionaries();
  432. try {
  433. this.maxInstructionsConstValue = this.ClefLeftMargin + this.ClefRightMargin + this.KeyRightMargin + this.RhythmRightMargin + 11;
  434. //if (FontInfo.Info !== undefined) {
  435. // this.maxInstructionsConstValue += FontInfo.Info.getBoundingBox(MusicSymbol.G_CLEF).width
  436. // + FontInfo.Info.getBoundingBox(MusicSymbol.FOUR).width
  437. // + 7 * FontInfo.Info.getBoundingBox(MusicSymbol.SHARP).width;
  438. //}
  439. } catch (ex) {
  440. log.info("EngravingRules()", ex);
  441. }
  442. }
  443. // these two need to be static so that we can avoid passing EngravingRules to BoundingBox in lots of code
  444. public static get FixStafflineBoundingBox(): boolean {
  445. return EngravingRules.fixStafflineBoundingBox;
  446. }
  447. public static set FixStafflineBoundingBox(value: boolean) {
  448. EngravingRules.fixStafflineBoundingBox = value;
  449. }
  450. public get SamplingUnit(): number {
  451. return this.samplingUnit;
  452. }
  453. public get SheetTitleHeight(): number {
  454. return this.sheetTitleHeight;
  455. }
  456. public set SheetTitleHeight(value: number) {
  457. this.sheetTitleHeight = value;
  458. }
  459. public get SheetSubtitleHeight(): number {
  460. return this.sheetSubtitleHeight;
  461. }
  462. public set SheetSubtitleHeight(value: number) {
  463. this.sheetSubtitleHeight = value;
  464. }
  465. public get SheetMinimumDistanceBetweenTitleAndSubtitle(): number {
  466. return this.sheetMinimumDistanceBetweenTitleAndSubtitle;
  467. }
  468. public set SheetMinimumDistanceBetweenTitleAndSubtitle(value: number) {
  469. this.sheetMinimumDistanceBetweenTitleAndSubtitle = value;
  470. }
  471. public get SheetComposerHeight(): number {
  472. return this.sheetComposerHeight;
  473. }
  474. public set SheetComposerHeight(value: number) {
  475. this.sheetComposerHeight = value;
  476. }
  477. public get SheetAuthorHeight(): number {
  478. return this.sheetAuthorHeight;
  479. }
  480. public set SheetAuthorHeight(value: number) {
  481. this.sheetAuthorHeight = value;
  482. }
  483. public get PagePlacement(): PagePlacementEnum {
  484. return this.pagePlacementEnum;
  485. }
  486. public set PagePlacement(value: PagePlacementEnum) {
  487. this.pagePlacementEnum = value;
  488. }
  489. public get CompactMode(): boolean {
  490. return this.compactMode;
  491. }
  492. public set CompactMode(value: boolean) {
  493. this.compactMode = value;
  494. }
  495. public get PageHeight(): number {
  496. return this.pageHeight;
  497. }
  498. public set PageHeight(value: number) {
  499. this.pageHeight = value;
  500. }
  501. public get PageTopMargin(): number {
  502. return this.pageTopMargin;
  503. }
  504. public set PageTopMargin(value: number) {
  505. this.pageTopMargin = value;
  506. }
  507. public get PageTopMarginNarrow(): number {
  508. return this.pageTopMarginNarrow;
  509. }
  510. public set PageTopMarginNarrow(value: number) {
  511. this.pageTopMarginNarrow = value;
  512. }
  513. public get PageBottomMargin(): number {
  514. return this.pageBottomMargin;
  515. }
  516. public set PageBottomMargin(value: number) {
  517. this.pageBottomMargin = value;
  518. }
  519. public get PageLeftMargin(): number {
  520. return this.pageLeftMargin;
  521. }
  522. public set PageLeftMargin(value: number) {
  523. this.pageLeftMargin = value;
  524. }
  525. public get PageRightMargin(): number {
  526. return this.pageRightMargin;
  527. }
  528. public set PageRightMargin(value: number) {
  529. this.pageRightMargin = value;
  530. }
  531. public get TitleTopDistance(): number {
  532. return this.titleTopDistance;
  533. }
  534. public set TitleTopDistance(value: number) {
  535. this.titleTopDistance = value;
  536. }
  537. public get TitleBottomDistance(): number {
  538. return this.titleBottomDistance;
  539. }
  540. public set TitleBottomDistance(value: number) {
  541. this.titleBottomDistance = value;
  542. }
  543. public get SystemComposerDistance(): number {
  544. return this.systemComposerDistance;
  545. }
  546. public set SystemComposerDistance(value: number) {
  547. this.systemComposerDistance = value;
  548. }
  549. public get InstrumentLabelTextHeight(): number {
  550. return this.instrumentLabelTextHeight;
  551. }
  552. public set InstrumentLabelTextHeight(value: number) {
  553. this.instrumentLabelTextHeight = value;
  554. }
  555. public get SystemLeftMargin(): number {
  556. return this.systemLeftMargin;
  557. }
  558. public set SystemLeftMargin(value: number) {
  559. this.systemLeftMargin = value;
  560. }
  561. public get SystemRightMargin(): number {
  562. return this.systemRightMargin;
  563. }
  564. public set SystemRightMargin(value: number) {
  565. this.systemRightMargin = value;
  566. }
  567. public get FirstSystemMargin(): number {
  568. return this.firstSystemMargin;
  569. }
  570. public set FirstSystemMargin(value: number) {
  571. this.firstSystemMargin = value;
  572. }
  573. public get SystemLabelsRightMargin(): number {
  574. return this.systemLabelsRightMargin;
  575. }
  576. public set SystemLabelsRightMargin(value: number) {
  577. this.systemLabelsRightMargin = value;
  578. }
  579. public get MinimumDistanceBetweenSystems(): number {
  580. return this.minimumDistanceBetweenSystems;
  581. }
  582. public set MinimumDistanceBetweenSystems(value: number) {
  583. this.minimumDistanceBetweenSystems = value;
  584. }
  585. public get LastSystemMaxScalingFactor(): number {
  586. return this.lastSystemMaxScalingFactor;
  587. }
  588. public set LastSystemMaxScalingFactor(value: number) {
  589. this.lastSystemMaxScalingFactor = value;
  590. }
  591. public get StaffDistance(): number {
  592. return this.staffDistance;
  593. }
  594. public set StaffDistance(value: number) {
  595. this.staffDistance = value;
  596. }
  597. public get BetweenStaffDistance(): number {
  598. return this.betweenStaffDistance;
  599. }
  600. public set BetweenStaffDistance(value: number) {
  601. this.betweenStaffDistance = value;
  602. }
  603. public get StaffHeight(): number {
  604. return this.staffHeight;
  605. }
  606. public set StaffHeight(value: number) {
  607. this.staffHeight = value;
  608. }
  609. public get TabStaffHeight(): number {
  610. return this.tabStaffHeight;
  611. }
  612. public set TabStaffHeight(value: number) {
  613. this.tabStaffHeight = value;
  614. }
  615. public get BetweenStaffLinesDistance(): number {
  616. return this.betweenStaffLinesDistance;
  617. }
  618. public set BetweenStaffLinesDistance(value: number) {
  619. this.betweenStaffLinesDistance = value;
  620. }
  621. public get AutoBeamNotes(): boolean {
  622. return this.autoBeamNotes;
  623. }
  624. public set AutoBeamNotes(value: boolean) {
  625. this.autoBeamNotes = value;
  626. }
  627. public get AutoBeamOptions(): AutoBeamOptions {
  628. return this.autoBeamOptions;
  629. }
  630. public set AutoBeamOptions(value: AutoBeamOptions) {
  631. this.autoBeamOptions = value;
  632. }
  633. public get BeamWidth(): number {
  634. return this.beamWidth;
  635. }
  636. public set BeamWidth(value: number) {
  637. this.beamWidth = value;
  638. }
  639. public get BeamSpaceWidth(): number {
  640. return this.beamSpaceWidth;
  641. }
  642. public set BeamSpaceWidth(value: number) {
  643. this.beamSpaceWidth = value;
  644. }
  645. public get BeamForwardLength(): number {
  646. return this.beamForwardLength;
  647. }
  648. public set BeamForwardLength(value: number) {
  649. this.beamForwardLength = value;
  650. }
  651. public get BetweenKeySymbolsDistance(): number {
  652. return this.betweenKeySymbolsDistance;
  653. }
  654. public set BetweenKeySymbolsDistance(value: number) {
  655. this.betweenKeySymbolsDistance = value;
  656. }
  657. public get ClefLeftMargin(): number {
  658. return this.clefLeftMargin;
  659. }
  660. public set ClefLeftMargin(value: number) {
  661. this.clefLeftMargin = value;
  662. }
  663. public get ClefRightMargin(): number {
  664. return this.clefRightMargin;
  665. }
  666. public set ClefRightMargin(value: number) {
  667. this.clefRightMargin = value;
  668. }
  669. public get KeyRightMargin(): number {
  670. return this.keyRightMargin;
  671. }
  672. public set KeyRightMargin(value: number) {
  673. this.keyRightMargin = value;
  674. }
  675. public get RhythmRightMargin(): number {
  676. return this.rhythmRightMargin;
  677. }
  678. public set RhythmRightMargin(value: number) {
  679. this.rhythmRightMargin = value;
  680. }
  681. public get InStaffClefScalingFactor(): number {
  682. return this.inStaffClefScalingFactor;
  683. }
  684. public set InStaffClefScalingFactor(value: number) {
  685. this.inStaffClefScalingFactor = value;
  686. }
  687. public get DistanceBetweenNaturalAndSymbolWhenCancelling(): number {
  688. return this.distanceBetweenNaturalAndSymbolWhenCancelling;
  689. }
  690. public set DistanceBetweenNaturalAndSymbolWhenCancelling(value: number) {
  691. this.distanceBetweenNaturalAndSymbolWhenCancelling = value;
  692. }
  693. public get NoteHelperLinesOffset(): number {
  694. return this.noteHelperLinesOffset;
  695. }
  696. public set NoteHelperLinesOffset(value: number) {
  697. this.noteHelperLinesOffset = value;
  698. }
  699. public get MeasureLeftMargin(): number {
  700. return this.measureLeftMargin;
  701. }
  702. public set MeasureLeftMargin(value: number) {
  703. this.measureLeftMargin = value;
  704. }
  705. public get MeasureRightMargin(): number {
  706. return this.measureRightMargin;
  707. }
  708. public set MeasureRightMargin(value: number) {
  709. this.measureRightMargin = value;
  710. }
  711. public get DistanceBetweenLastInstructionAndRepetitionBarline(): number {
  712. return this.distanceBetweenLastInstructionAndRepetitionBarline;
  713. }
  714. public set DistanceBetweenLastInstructionAndRepetitionBarline(value: number) {
  715. this.distanceBetweenLastInstructionAndRepetitionBarline = value;
  716. }
  717. public get ArpeggioDistance(): number {
  718. return this.arpeggioDistance;
  719. }
  720. public set ArpeggioDistance(value: number) {
  721. this.arpeggioDistance = value;
  722. }
  723. public get StaccatoShorteningFactor(): number {
  724. return this.staccatoShorteningFactor;
  725. }
  726. public set StaccatoShorteningFactor(value: number) {
  727. this.staccatoShorteningFactor = value;
  728. }
  729. public get IdealStemLength(): number {
  730. return this.idealStemLength;
  731. }
  732. public set IdealStemLength(value: number) {
  733. this.idealStemLength = value;
  734. }
  735. public get StemNoteHeadBorderYOffset(): number {
  736. return this.stemNoteHeadBorderYOffset;
  737. }
  738. public set StemNoteHeadBorderYOffset(value: number) {
  739. this.stemNoteHeadBorderYOffset = value;
  740. }
  741. public get StemWidth(): number {
  742. return this.stemWidth;
  743. }
  744. public set StemWidth(value: number) {
  745. this.stemWidth = value;
  746. }
  747. public get StemMargin(): number {
  748. return this.stemMargin;
  749. }
  750. public set StemMargin(value: number) {
  751. this.stemMargin = value;
  752. }
  753. public get StemMinLength(): number {
  754. return this.stemMinLength;
  755. }
  756. public set StemMinLength(value: number) {
  757. this.stemMinLength = value;
  758. }
  759. public get StemMaxLength(): number {
  760. return this.stemMaxLength;
  761. }
  762. public set StemMaxLength(value: number) {
  763. this.stemMaxLength = value;
  764. }
  765. public get BeamSlopeMaxAngle(): number {
  766. return this.beamSlopeMaxAngle;
  767. }
  768. public set BeamSlopeMaxAngle(value: number) {
  769. this.beamSlopeMaxAngle = value;
  770. }
  771. public get StemMinAllowedDistanceBetweenNoteHeadAndBeamLine(): number {
  772. return this.stemMinAllowedDistanceBetweenNoteHeadAndBeamLine;
  773. }
  774. public set StemMinAllowedDistanceBetweenNoteHeadAndBeamLine(value: number) {
  775. this.stemMinAllowedDistanceBetweenNoteHeadAndBeamLine = value;
  776. }
  777. public get SetWantedStemDirectionByXml(): boolean {
  778. return this.setWantedStemDirectionByXml;
  779. }
  780. public set SetWantedStemDirectionByXml(value: boolean) {
  781. this.setWantedStemDirectionByXml = value;
  782. }
  783. public get GraceNoteScalingFactor(): number {
  784. return this.graceNoteScalingFactor;
  785. }
  786. public set GraceNoteScalingFactor(value: number) {
  787. this.graceNoteScalingFactor = value;
  788. }
  789. public get GraceNoteXOffset(): number {
  790. return this.graceNoteXOffset;
  791. }
  792. public set GraceNoteXOffset(value: number) {
  793. this.graceNoteXOffset = value;
  794. }
  795. public get WedgeOpeningLength(): number {
  796. return this.wedgeOpeningLength;
  797. }
  798. public set WedgeOpeningLength(value: number) {
  799. this.wedgeOpeningLength = value;
  800. }
  801. public get WedgeMeasureEndOpeningLength(): number {
  802. return this.wedgeMeasureEndOpeningLength;
  803. }
  804. public set WedgeMeasureEndOpeningLength(value: number) {
  805. this.wedgeMeasureEndOpeningLength = value;
  806. }
  807. public get WedgeMeasureBeginOpeningLength(): number {
  808. return this.wedgeMeasureBeginOpeningLength;
  809. }
  810. public set WedgeMeasureBeginOpeningLength(value: number) {
  811. this.wedgeMeasureBeginOpeningLength = value;
  812. }
  813. public get WedgePlacementAboveY(): number {
  814. return this.wedgePlacementAboveY;
  815. }
  816. public set WedgePlacementAboveY(value: number) {
  817. this.wedgePlacementAboveY = value;
  818. }
  819. public get WedgePlacementBelowY(): number {
  820. return this.wedgePlacementBelowY;
  821. }
  822. public set WedgePlacementBelowY(value: number) {
  823. this.wedgePlacementBelowY = value;
  824. }
  825. public get WedgeHorizontalMargin(): number {
  826. return this.wedgeHorizontalMargin;
  827. }
  828. public set WedgeHorizontalMargin(value: number) {
  829. this.wedgeHorizontalMargin = value;
  830. }
  831. public get WedgeVerticalMargin(): number {
  832. return this.wedgeVerticalMargin;
  833. }
  834. public set WedgeVerticalMargin(value: number) {
  835. this.wedgeVerticalMargin = value;
  836. }
  837. public get DistanceOffsetBetweenTwoHorizontallyCrossedWedges(): number {
  838. return this.distanceOffsetBetweenTwoHorizontallyCrossedWedges;
  839. }
  840. public set DistanceOffsetBetweenTwoHorizontallyCrossedWedges(value: number) {
  841. this.distanceOffsetBetweenTwoHorizontallyCrossedWedges = value;
  842. }
  843. public get WedgeMinLength(): number {
  844. return this.wedgeMinLength;
  845. }
  846. public set WedgeMinLength(value: number) {
  847. this.wedgeMinLength = value;
  848. }
  849. public get DistanceBetweenAdjacentDynamics(): number {
  850. return this.distanceBetweenAdjacentDynamics;
  851. }
  852. public set DistanceBetweenAdjacentDynamics(value: number) {
  853. this.distanceBetweenAdjacentDynamics = value;
  854. }
  855. public get TempoChangeMeasureValidity(): number {
  856. return this.tempoChangeMeasureValidity;
  857. }
  858. public set TempoChangeMeasureValidity(value: number) {
  859. this.tempoChangeMeasureValidity = value;
  860. }
  861. public get TempoContinousFactor(): number {
  862. return this.tempoContinousFactor;
  863. }
  864. public set TempoContinousFactor(value: number) {
  865. this.tempoContinousFactor = value;
  866. }
  867. public get StaccatoScalingFactor(): number {
  868. return this.staccatoScalingFactor;
  869. }
  870. public set StaccatoScalingFactor(value: number) {
  871. this.staccatoScalingFactor = value;
  872. }
  873. public get BetweenDotsDistance(): number {
  874. return this.betweenDotsDistance;
  875. }
  876. public set BetweenDotsDistance(value: number) {
  877. this.betweenDotsDistance = value;
  878. }
  879. public get OrnamentAccidentalScalingFactor(): number {
  880. return this.ornamentAccidentalScalingFactor;
  881. }
  882. public set OrnamentAccidentalScalingFactor(value: number) {
  883. this.ornamentAccidentalScalingFactor = value;
  884. }
  885. public get ChordSymbolTextHeight(): number {
  886. return this.chordSymbolTextHeight;
  887. }
  888. public set ChordSymbolTextHeight(value: number) {
  889. this.chordSymbolTextHeight = value;
  890. }
  891. public get ChordSymbolXSpacing(): number {
  892. return this.chordSymbolXSpacing;
  893. }
  894. public set ChordSymbolXSpacing(value: number) {
  895. this.chordSymbolXSpacing = value;
  896. }
  897. public get ChordSymbolYOffset(): number {
  898. return this.chordSymbolYOffset;
  899. }
  900. public set ChordSymbolYOffset(value: number) {
  901. this.chordSymbolYOffset = value;
  902. }
  903. public get FingeringLabelFontHeight(): number {
  904. return this.fingeringLabelFontHeight;
  905. }
  906. public set FingeringLabelFontHeight(value: number) {
  907. this.fingeringLabelFontHeight = value;
  908. }
  909. public get MeasureNumberLabelHeight(): number {
  910. return this.measureNumberLabelHeight;
  911. }
  912. public set MeasureNumberLabelHeight(value: number) {
  913. this.measureNumberLabelHeight = value;
  914. }
  915. public get MeasureNumberLabelOffset(): number {
  916. return this.measureNumberLabelOffset;
  917. }
  918. public set MeasureNumberLabelOffset(value: number) {
  919. this.measureNumberLabelOffset = value;
  920. }
  921. public get TupletsRatioed(): boolean {
  922. return this.tupletsRatioed;
  923. }
  924. public set TupletsRatioed(value: boolean) {
  925. this.tupletsRatioed = value;
  926. }
  927. public get TupletsBracketed(): boolean {
  928. return this.tupletsBracketed;
  929. }
  930. public set TupletsBracketed(value: boolean) {
  931. this.tupletsBracketed = value;
  932. }
  933. public get TripletsBracketed(): boolean {
  934. return this.tripletsBracketed;
  935. }
  936. public set TripletsBracketed(value: boolean) {
  937. this.tripletsBracketed = value;
  938. }
  939. public get TupletNumberLabelHeight(): number {
  940. return this.tupletNumberLabelHeight;
  941. }
  942. public set TupletNumberLabelHeight(value: number) {
  943. this.tupletNumberLabelHeight = value;
  944. }
  945. public get TupletNumberYOffset(): number {
  946. return this.tupletNumberYOffset;
  947. }
  948. public set TupletNumberYOffset(value: number) {
  949. this.tupletNumberYOffset = value;
  950. }
  951. public get LabelMarginBorderFactor(): number {
  952. return this.labelMarginBorderFactor;
  953. }
  954. public set LabelMarginBorderFactor(value: number) {
  955. this.labelMarginBorderFactor = value;
  956. }
  957. public get TupletVerticalLineLength(): number {
  958. return this.tupletVerticalLineLength;
  959. }
  960. public set TupletVerticalLineLength(value: number) {
  961. this.tupletVerticalLineLength = value;
  962. }
  963. public get RepetitionEndingLabelHeight(): number {
  964. return this.repetitionEndingLabelHeight;
  965. }
  966. public set RepetitionEndingLabelHeight(value: number) {
  967. this.repetitionEndingLabelHeight = value;
  968. }
  969. public get RepetitionEndingLabelXOffset(): number {
  970. return this.repetitionEndingLabelXOffset;
  971. }
  972. public set RepetitionEndingLabelXOffset(value: number) {
  973. this.repetitionEndingLabelXOffset = value;
  974. }
  975. public get RepetitionEndingLabelYOffset(): number {
  976. return this.repetitionEndingLabelYOffset;
  977. }
  978. public set RepetitionEndingLabelYOffset(value: number) {
  979. this.repetitionEndingLabelYOffset = value;
  980. }
  981. public get RepetitionEndingLineYLowerOffset(): number {
  982. return this.repetitionEndingLineYLowerOffset;
  983. }
  984. public set RepetitionEndingLineYLowerOffset(value: number) {
  985. this.repetitionEndingLineYLowerOffset = value;
  986. }
  987. public get RepetitionEndingLineYUpperOffset(): number {
  988. return this.repetitionEndingLineYUpperOffset;
  989. }
  990. public set RepetitionEndingLineYUpperOffset(value: number) {
  991. this.repetitionEndingLineYUpperOffset = value;
  992. }
  993. public get VoltaOffset(): number {
  994. return this.voltaOffset;
  995. }
  996. public set VoltaOffset(value: number) {
  997. this.voltaOffset = value;
  998. }
  999. public get LyricsAlignmentStandard(): TextAlignmentEnum {
  1000. return this.lyricsAlignmentStandard;
  1001. }
  1002. public set LyricsAlignmentStandard(value: TextAlignmentEnum) {
  1003. this.lyricsAlignmentStandard = value;
  1004. }
  1005. public get LyricsHeight(): number {
  1006. return this.lyricsHeight;
  1007. }
  1008. public set LyricsHeight(value: number) {
  1009. this.lyricsHeight = value;
  1010. }
  1011. public get LyricsYOffsetToStaffHeight(): number {
  1012. return this.lyricsYOffsetToStaffHeight;
  1013. }
  1014. public set LyricsYOffsetToStaffHeight(value: number) {
  1015. this.lyricsYOffsetToStaffHeight = value;
  1016. }
  1017. public get VerticalBetweenLyricsDistance(): number {
  1018. return this.verticalBetweenLyricsDistance;
  1019. }
  1020. public set VerticalBetweenLyricsDistance(value: number) {
  1021. this.verticalBetweenLyricsDistance = value;
  1022. }
  1023. public get HorizontalBetweenLyricsDistance(): number {
  1024. return this.horizontalBetweenLyricsDistance;
  1025. }
  1026. public set HorizontalBetweenLyricsDistance(value: number) {
  1027. this.horizontalBetweenLyricsDistance = value;
  1028. }
  1029. public get BetweenSyllableMaximumDistance(): number {
  1030. return this.betweenSyllableMaximumDistance;
  1031. }
  1032. public set BetweenSyllableMaximumDistance(value: number) {
  1033. this.betweenSyllableMaximumDistance = value;
  1034. }
  1035. public get BetweenSyllableMinimumDistance(): number {
  1036. return this.betweenSyllableMinimumDistance;
  1037. }
  1038. public set BetweenSyllableMinimumDistance(value: number) {
  1039. this.betweenSyllableMinimumDistance = value;
  1040. }
  1041. public get LyricOverlapAllowedIntoNextMeasure(): number {
  1042. return this.lyricOverlapAllowedIntoNextMeasure;
  1043. }
  1044. public set LyricOverlapAllowedIntoNextMeasure(value: number) {
  1045. this.lyricOverlapAllowedIntoNextMeasure = value;
  1046. }
  1047. public get MinimumDistanceBetweenDashes(): number {
  1048. return this.minimumDistanceBetweenDashes;
  1049. }
  1050. public set MinimumDistanceBetweenDashes(value: number) {
  1051. this.minimumDistanceBetweenDashes = value;
  1052. }
  1053. public get BezierCurveStepSize(): number {
  1054. return this.bezierCurveStepSize;
  1055. }
  1056. public set BezierCurveStepSize(value: number) {
  1057. this.bezierCurveStepSize = value;
  1058. }
  1059. public get TPow3(): number[] {
  1060. return this.tPower3;
  1061. }
  1062. public set TPow3(value: number[]) {
  1063. this.tPower3 = value;
  1064. }
  1065. public get OneMinusTPow3(): number[] {
  1066. return this.oneMinusTPower3;
  1067. }
  1068. public set OneMinusTPow3(value: number[]) {
  1069. this.oneMinusTPower3 = value;
  1070. }
  1071. public get BezierFactorOne(): number[] {
  1072. return this.factorOne;
  1073. }
  1074. public set BezierFactorOne(value: number[]) {
  1075. this.factorOne = value;
  1076. }
  1077. public get BezierFactorTwo(): number[] {
  1078. return this.factorTwo;
  1079. }
  1080. public set BezierFactorTwo(value: number[]) {
  1081. this.factorTwo = value;
  1082. }
  1083. public get TieGhostObjectWidth(): number {
  1084. return this.tieGhostObjectWidth;
  1085. }
  1086. public set TieGhostObjectWidth(value: number) {
  1087. this.tieGhostObjectWidth = value;
  1088. }
  1089. public get TieYPositionOffsetFactor(): number {
  1090. return this.tieYPositionOffsetFactor;
  1091. }
  1092. public set TieYPositionOffsetFactor(value: number) {
  1093. this.tieYPositionOffsetFactor = value;
  1094. }
  1095. public get MinimumNeededXspaceForTieGhostObject(): number {
  1096. return this.minimumNeededXspaceForTieGhostObject;
  1097. }
  1098. public set MinimumNeededXspaceForTieGhostObject(value: number) {
  1099. this.minimumNeededXspaceForTieGhostObject = value;
  1100. }
  1101. public get TieHeightMinimum(): number {
  1102. return this.tieHeightMinimum;
  1103. }
  1104. public set TieHeightMinimum(value: number) {
  1105. this.tieHeightMinimum = value;
  1106. }
  1107. public get TieHeightMaximum(): number {
  1108. return this.tieHeightMaximum;
  1109. }
  1110. public set TieHeightMaximum(value: number) {
  1111. this.tieHeightMaximum = value;
  1112. }
  1113. public get TieHeightInterpolationK(): number {
  1114. return this.tieHeightInterpolationK;
  1115. }
  1116. public set TieHeightInterpolationK(value: number) {
  1117. this.tieHeightInterpolationK = value;
  1118. }
  1119. public get TieHeightInterpolationD(): number {
  1120. return this.tieHeightInterpolationD;
  1121. }
  1122. public set TieHeightInterpolationD(value: number) {
  1123. this.tieHeightInterpolationD = value;
  1124. }
  1125. public get SlurNoteHeadYOffset(): number {
  1126. return this.slurNoteHeadYOffset;
  1127. }
  1128. public set SlurNoteHeadYOffset(value: number) {
  1129. this.slurNoteHeadYOffset = value;
  1130. }
  1131. public get SlurStemXOffset(): number {
  1132. return this.slurStemXOffset;
  1133. }
  1134. public set SlurStemXOffset(value: number) {
  1135. this.slurStemXOffset = value;
  1136. }
  1137. public get SlurSlopeMaxAngle(): number {
  1138. return this.slurSlopeMaxAngle;
  1139. }
  1140. public set SlurSlopeMaxAngle(value: number) {
  1141. this.slurSlopeMaxAngle = value;
  1142. }
  1143. public get SlurTangentMinAngle(): number {
  1144. return this.slurTangentMinAngle;
  1145. }
  1146. public set SlurTangentMinAngle(value: number) {
  1147. this.slurTangentMinAngle = value;
  1148. }
  1149. public get SlurTangentMaxAngle(): number {
  1150. return this.slurTangentMaxAngle;
  1151. }
  1152. public set SlurTangentMaxAngle(value: number) {
  1153. this.slurTangentMaxAngle = value;
  1154. }
  1155. public get SlursStartingAtSameStaffEntryYOffset(): number {
  1156. return this.slursStartingAtSameStaffEntryYOffset;
  1157. }
  1158. public set SlursStartingAtSameStaffEntryYOffset(value: number) {
  1159. this.slursStartingAtSameStaffEntryYOffset = value;
  1160. }
  1161. public get InstantaneousTempoTextHeight(): number {
  1162. return this.instantaneousTempoTextHeight;
  1163. }
  1164. public set InstantaneousTempoTextHeight(value: number) {
  1165. this.instantaneousTempoTextHeight = value;
  1166. }
  1167. public get ContinuousDynamicTextHeight(): number {
  1168. return this.continuousDynamicTextHeight;
  1169. }
  1170. public set ContinuousDynamicTextHeight(value: number) {
  1171. this.continuousDynamicTextHeight = value;
  1172. }
  1173. public get MoodTextHeight(): number {
  1174. return this.moodTextHeight;
  1175. }
  1176. public set MoodTextHeight(value: number) {
  1177. this.moodTextHeight = value;
  1178. }
  1179. public get ContinuousTempoTextHeight(): number {
  1180. return this.continuousTempoTextHeight;
  1181. }
  1182. public set ContinuousTempoTextHeight(value: number) {
  1183. this.continuousTempoTextHeight = value;
  1184. }
  1185. /** Distance of expressions inside a group */
  1186. public get DynamicExpressionMaxDistance(): number {
  1187. return this.dynamicExpressionMaxDistance;
  1188. }
  1189. public set DynamicExpressionMaxDistance(value: number) {
  1190. this.dynamicExpressionMaxDistance = value;
  1191. }
  1192. /** Space between expressions in a group */
  1193. public get DynamicExpressionSpacer(): number {
  1194. return this.dynamicExpressionSpacer;
  1195. }
  1196. public set DynamicExpressionSpacer(value: number) {
  1197. this.dynamicExpressionSpacer = value;
  1198. }
  1199. public get UnknownTextHeight(): number {
  1200. return this.unknownTextHeight;
  1201. }
  1202. public set UnknownTextHeight(value: number) {
  1203. this.unknownTextHeight = value;
  1204. }
  1205. public get StaffLineWidth(): number {
  1206. return this.staffLineWidth;
  1207. }
  1208. public set StaffLineWidth(value: number) {
  1209. this.staffLineWidth = value;
  1210. }
  1211. public get LedgerLineWidth(): number {
  1212. return this.ledgerLineWidth;
  1213. }
  1214. public set LedgerLineWidth(value: number) {
  1215. this.ledgerLineWidth = value;
  1216. }
  1217. public get WedgeLineWidth(): number {
  1218. return this.wedgeLineWidth;
  1219. }
  1220. public set WedgeLineWidth(value: number) {
  1221. this.wedgeLineWidth = value;
  1222. }
  1223. public get TupletLineWidth(): number {
  1224. return this.tupletLineWidth;
  1225. }
  1226. public set TupletLineWidth(value: number) {
  1227. this.tupletLineWidth = value;
  1228. }
  1229. public get LyricUnderscoreLineWidth(): number {
  1230. return this.lyricUnderscoreLineWidth;
  1231. }
  1232. public set LyricUnderscoreLineWidth(value: number) {
  1233. this.lyricUnderscoreLineWidth = value;
  1234. }
  1235. public get SystemThinLineWidth(): number {
  1236. return this.systemThinLineWidth;
  1237. }
  1238. public set SystemThinLineWidth(value: number) {
  1239. this.systemThinLineWidth = value;
  1240. }
  1241. public get SystemBoldLineWidth(): number {
  1242. return this.systemBoldLineWidth;
  1243. }
  1244. public set SystemBoldLineWidth(value: number) {
  1245. this.systemBoldLineWidth = value;
  1246. }
  1247. public get SystemRepetitionEndingLineWidth(): number {
  1248. return this.systemRepetitionEndingLineWidth;
  1249. }
  1250. public set SystemRepetitionEndingLineWidth(value: number) {
  1251. this.systemRepetitionEndingLineWidth = value;
  1252. }
  1253. public get SystemDotWidth(): number {
  1254. return this.systemDotWidth;
  1255. }
  1256. public set SystemDotWidth(value: number) {
  1257. this.systemDotWidth = value;
  1258. }
  1259. public get DistanceBetweenVerticalSystemLines(): number {
  1260. return this.distanceBetweenVerticalSystemLines;
  1261. }
  1262. public set DistanceBetweenVerticalSystemLines(value: number) {
  1263. this.distanceBetweenVerticalSystemLines = value;
  1264. }
  1265. public get DistanceBetweenDotAndLine(): number {
  1266. return this.distanceBetweenDotAndLine;
  1267. }
  1268. public set DistanceBetweenDotAndLine(value: number) {
  1269. this.distanceBetweenDotAndLine = value;
  1270. }
  1271. public get OctaveShiftLineWidth(): number {
  1272. return this.octaveShiftLineWidth;
  1273. }
  1274. public set OctaveShiftLineWidth(value: number) {
  1275. this.octaveShiftLineWidth = value;
  1276. }
  1277. public get OctaveShiftVerticalLineLength(): number {
  1278. return this.octaveShiftVerticalLineLength;
  1279. }
  1280. public set OctaveShiftVerticalLineLength(value: number) {
  1281. this.octaveShiftVerticalLineLength = value;
  1282. }
  1283. public get GraceLineWidth(): number {
  1284. return this.graceLineWidth;
  1285. }
  1286. public set GraceLineWidth(value: number) {
  1287. this.graceLineWidth = value;
  1288. }
  1289. public get MinimumStaffLineDistance(): number {
  1290. return this.minimumStaffLineDistance;
  1291. }
  1292. public set MinimumStaffLineDistance(value: number) {
  1293. this.minimumStaffLineDistance = value;
  1294. }
  1295. public get MinimumCrossedBeamDifferenceMargin(): number {
  1296. return this.minimumCrossedBeamDifferenceMargin;
  1297. }
  1298. public set MinimumCrossedBeamDifferenceMargin(value: number) {
  1299. this.minimumCrossedBeamDifferenceMargin = value;
  1300. }
  1301. public get DisplacedNoteMargin(): number {
  1302. return this.displacedNoteMargin;
  1303. }
  1304. public set DisplacedNoteMargin(value: number) {
  1305. this.displacedNoteMargin = value;
  1306. }
  1307. public get MinNoteDistance(): number {
  1308. return this.minNoteDistance;
  1309. }
  1310. public set MinNoteDistance(value: number) {
  1311. this.minNoteDistance = value;
  1312. }
  1313. public get SubMeasureXSpacingThreshold(): number {
  1314. return this.subMeasureXSpacingThreshold;
  1315. }
  1316. public set SubMeasureXSpacingThreshold(value: number) {
  1317. this.subMeasureXSpacingThreshold = value;
  1318. }
  1319. public get MeasureDynamicsMaxScalingFactor(): number {
  1320. return this.measureDynamicsMaxScalingFactor;
  1321. }
  1322. public set MeasureDynamicsMaxScalingFactor(value: number) {
  1323. this.measureDynamicsMaxScalingFactor = value;
  1324. }
  1325. public get WholeRestXShiftVexflow(): number {
  1326. return this.wholeRestXShiftVexflow;
  1327. }
  1328. public set WholeRestXShiftVexflow(value: number) {
  1329. this.wholeRestXShiftVexflow = value;
  1330. }
  1331. public get MetronomeMarkXShift(): number {
  1332. return this.metronomeMarkXShift;
  1333. }
  1334. public set MetronomeMarkXShift(value: number) {
  1335. this.metronomeMarkXShift = value;
  1336. }
  1337. public get MetronomeMarkYShift(): number {
  1338. return this.metronomeMarkYShift;
  1339. }
  1340. public set MetronomeMarkYShift(value: number) {
  1341. this.metronomeMarkYShift = value;
  1342. }
  1343. public get MaxInstructionsConstValue(): number {
  1344. return this.maxInstructionsConstValue;
  1345. }
  1346. public set MaxInstructionsConstValue(value: number) {
  1347. this.maxInstructionsConstValue = value;
  1348. }
  1349. public get NoteDistances(): number[] {
  1350. return this.noteDistances;
  1351. }
  1352. public set NoteDistances(value: number[]) {
  1353. this.noteDistances = value;
  1354. }
  1355. public get NoteDistancesScalingFactors(): number[] {
  1356. return this.noteDistancesScalingFactors;
  1357. }
  1358. public set NoteDistancesScalingFactors(value: number[]) {
  1359. this.noteDistancesScalingFactors = value;
  1360. }
  1361. public get DurationDistanceDict(): {[_: number]: number; } {
  1362. return this.durationDistanceDict;
  1363. }
  1364. public get DurationScalingDistanceDict(): {[_: number]: number; } {
  1365. return this.durationScalingDistanceDict;
  1366. }
  1367. public get AlignRests(): number {
  1368. return this.alignRests;
  1369. }
  1370. public set AlignRests(value: number) {
  1371. this.alignRests = value;
  1372. }
  1373. public get FillEmptyMeasuresWithWholeRest(): FillEmptyMeasuresWithWholeRests | number {
  1374. return this.fillEmptyMeasuresWithWholeRest;
  1375. }
  1376. public set FillEmptyMeasuresWithWholeRest(value: FillEmptyMeasuresWithWholeRests | number) {
  1377. this.fillEmptyMeasuresWithWholeRest = value;
  1378. }
  1379. public get ArpeggiosGoAcrossVoices(): boolean {
  1380. return this.arpeggiosGoAcrossVoices;
  1381. }
  1382. public set ArpeggiosGoAcrossVoices(value: boolean) {
  1383. this.arpeggiosGoAcrossVoices = value;
  1384. }
  1385. public get RenderArpeggios(): boolean {
  1386. return this.renderArpeggios;
  1387. }
  1388. public set RenderArpeggios(value: boolean) {
  1389. this.renderArpeggios = value;
  1390. }
  1391. public get RenderSlurs(): boolean {
  1392. return this.renderSlurs;
  1393. }
  1394. public set RenderSlurs(value: boolean) {
  1395. this.renderSlurs = value;
  1396. }
  1397. public get ColoringMode(): ColoringMode {
  1398. return this.coloringMode;
  1399. }
  1400. public set ColoringMode(value: ColoringMode) {
  1401. this.coloringMode = value;
  1402. }
  1403. public get ColoringEnabled(): boolean {
  1404. return this.coloringEnabled;
  1405. }
  1406. public set ColoringEnabled(value: boolean) {
  1407. this.coloringEnabled = value;
  1408. }
  1409. public get ColorStemsLikeNoteheads(): boolean {
  1410. return this.colorStemsLikeNoteheads;
  1411. }
  1412. public set ColorStemsLikeNoteheads(value: boolean) {
  1413. this.colorStemsLikeNoteheads = value;
  1414. }
  1415. public get ColorFlags(): boolean {
  1416. return this.colorFlags;
  1417. }
  1418. public set ColorFlags(value: boolean) {
  1419. this.colorFlags = value;
  1420. }
  1421. public get ColorBeams(): boolean {
  1422. return this.colorBeams;
  1423. }
  1424. public set ColorBeams(value: boolean) {
  1425. this.colorBeams = value;
  1426. }
  1427. public get ColoringSetCurrent(): Dictionary<NoteEnum|number, string> {
  1428. return this.coloringSetCustom;
  1429. }
  1430. public set ColoringSetCurrent(value: Dictionary<NoteEnum|number, string>) {
  1431. this.coloringSetCustom = value;
  1432. }
  1433. public get DefaultColorNotehead(): string {
  1434. return this.defaultColorNotehead;
  1435. }
  1436. public set DefaultColorNotehead(value: string) {
  1437. this.defaultColorNotehead = value;
  1438. }
  1439. public get DefaultColorRest(): string {
  1440. return this.defaultColorRest;
  1441. }
  1442. public set DefaultColorRest(value: string) {
  1443. this.defaultColorRest = value;
  1444. }
  1445. public get DefaultColorStem(): string {
  1446. return this.defaultColorStem;
  1447. }
  1448. public set DefaultColorStem(value: string) {
  1449. this.defaultColorStem = value;
  1450. }
  1451. public get DefaultColorLabel(): string {
  1452. return this.defaultColorLabel;
  1453. }
  1454. public set DefaultColorLabel(value: string) {
  1455. this.defaultColorLabel = value;
  1456. }
  1457. public get DefaultColorTitle(): string {
  1458. return this.defaultColorTitle;
  1459. }
  1460. public set DefaultColorTitle(value: string) {
  1461. this.defaultColorTitle = value;
  1462. }
  1463. public get DefaultFontFamily(): string {
  1464. return this.defaultFontFamily;
  1465. }
  1466. public set DefaultFontFamily(value: string) {
  1467. this.defaultFontFamily = value;
  1468. }
  1469. public get MaxMeasureToDrawIndex(): number {
  1470. return this.maxMeasureToDrawIndex;
  1471. }
  1472. public set MaxMeasureToDrawIndex(value: number) {
  1473. this.maxMeasureToDrawIndex = value;
  1474. }
  1475. public get MinMeasureToDrawIndex(): number {
  1476. return this.minMeasureToDrawIndex;
  1477. }
  1478. public set MinMeasureToDrawIndex(value: number) {
  1479. this.minMeasureToDrawIndex = value;
  1480. }
  1481. public get RenderComposer(): boolean {
  1482. return this.renderComposer;
  1483. }
  1484. public set RenderComposer(value: boolean) {
  1485. this.renderComposer = value;
  1486. }
  1487. public get RenderTitle(): boolean {
  1488. return this.renderTitle;
  1489. }
  1490. public set RenderTitle(value: boolean) {
  1491. this.renderTitle = value;
  1492. }
  1493. public get RenderSubtitle(): boolean {
  1494. return this.renderSubtitle;
  1495. }
  1496. public set RenderSubtitle(value: boolean) {
  1497. this.renderSubtitle = value;
  1498. }
  1499. public get RenderLyricist(): boolean {
  1500. return this.renderLyricist;
  1501. }
  1502. public set RenderLyricist(value: boolean) {
  1503. this.renderLyricist = value;
  1504. }
  1505. public get RenderPartNames(): boolean {
  1506. return this.renderPartNames;
  1507. }
  1508. public set RenderPartNames(value: boolean) {
  1509. this.renderPartNames = value;
  1510. }
  1511. public get RenderPartAbbreviations(): boolean {
  1512. return this.renderPartAbbreviations;
  1513. }
  1514. public set RenderPartAbbreviations(value: boolean) {
  1515. this.renderPartAbbreviations = value;
  1516. }
  1517. public get RenderFingerings(): boolean {
  1518. return this.renderFingerings;
  1519. }
  1520. public set RenderFingerings(value: boolean) {
  1521. this.renderFingerings = value;
  1522. }
  1523. public get RenderMeasureNumbers(): boolean {
  1524. return this.renderMeasureNumbers;
  1525. }
  1526. public set RenderMeasureNumbers(value: boolean) {
  1527. this.renderMeasureNumbers = value;
  1528. }
  1529. public get RenderLyrics(): boolean {
  1530. return this.renderLyrics;
  1531. }
  1532. public set RenderLyrics(value: boolean) {
  1533. this.renderLyrics = value;
  1534. }
  1535. public get FingeringPosition(): PlacementEnum {
  1536. return this.fingeringPosition;
  1537. }
  1538. public set FingeringPosition(value: PlacementEnum) {
  1539. this.fingeringPosition = value;
  1540. }
  1541. public get FingeringInsideStafflines(): boolean {
  1542. return this.fingeringInsideStafflines;
  1543. }
  1544. public set FingeringInsideStafflines(value: boolean) {
  1545. this.fingeringInsideStafflines = value;
  1546. }
  1547. public get NewSystemAtXMLNewSystemAttribute(): boolean {
  1548. return this.newSystemAtXMLNewSystemAttribute;
  1549. }
  1550. public set NewSystemAtXMLNewSystemAttribute(value: boolean) {
  1551. this.newSystemAtXMLNewSystemAttribute = value;
  1552. }
  1553. public get NewPageAtXMLNewPageAttribute(): boolean {
  1554. return this.newPageAtXMLNewPageAttribute;
  1555. }
  1556. public set NewPageAtXMLNewPageAttribute(value: boolean) {
  1557. this.newPageAtXMLNewPageAttribute = value;
  1558. }
  1559. public get PageFormat(): PageFormat {
  1560. return this.pageFormat;
  1561. }
  1562. public set PageFormat(value: PageFormat) {
  1563. this.pageFormat = value;
  1564. }
  1565. public get PageBackgroundColor(): string {
  1566. return this.pageBackgroundColor;
  1567. }
  1568. public set PageBackgroundColor(value: string) {
  1569. this.pageBackgroundColor = value;
  1570. }
  1571. public get RenderSingleHorizontalStaffline(): boolean {
  1572. return this.renderSingleHorizontalStaffline;
  1573. }
  1574. public set RenderSingleHorizontalStaffline(value: boolean) {
  1575. this.renderSingleHorizontalStaffline = value;
  1576. }
  1577. public get RestoreCursorAfterRerender(): boolean {
  1578. return this.restoreCursorAfterRerender;
  1579. }
  1580. public set RestoreCursorAfterRerender(value: boolean) {
  1581. this.restoreCursorAfterRerender = value;
  1582. }
  1583. /**
  1584. * This method maps NoteDurations to Distances and DistancesScalingFactors.
  1585. */
  1586. private populateDictionaries(): void {
  1587. for (let i: number = 0; i < this.noteDistances.length; i++) {
  1588. switch (i) {
  1589. case 0:
  1590. this.durationDistanceDict[0.015625] = this.noteDistances[i];
  1591. this.durationScalingDistanceDict[0.015625] = this.noteDistancesScalingFactors[i];
  1592. break;
  1593. case 1:
  1594. this.durationDistanceDict[0.03125] = this.noteDistances[i];
  1595. this.durationScalingDistanceDict[0.03125] = this.noteDistancesScalingFactors[i];
  1596. break;
  1597. case 2:
  1598. this.durationDistanceDict[0.0625] = this.noteDistances[i];
  1599. this.durationScalingDistanceDict[0.0625] = this.noteDistancesScalingFactors[i];
  1600. break;
  1601. case 3:
  1602. this.durationDistanceDict[0.125] = this.noteDistances[i];
  1603. this.durationScalingDistanceDict[0.125] = this.noteDistancesScalingFactors[i];
  1604. break;
  1605. case 4:
  1606. this.durationDistanceDict[0.25] = this.noteDistances[i];
  1607. this.durationScalingDistanceDict[0.25] = this.noteDistancesScalingFactors[i];
  1608. break;
  1609. case 5:
  1610. this.durationDistanceDict[0.5] = this.noteDistances[i];
  1611. this.durationScalingDistanceDict[0.5] = this.noteDistancesScalingFactors[i];
  1612. break;
  1613. case 6:
  1614. this.durationDistanceDict[1.0] = this.noteDistances[i];
  1615. this.durationScalingDistanceDict[1.0] = this.noteDistancesScalingFactors[i];
  1616. break;
  1617. case 7:
  1618. this.durationDistanceDict[2.0] = this.noteDistances[i];
  1619. this.durationScalingDistanceDict[2.0] = this.noteDistancesScalingFactors[i];
  1620. break;
  1621. default:
  1622. // FIXME
  1623. }
  1624. }
  1625. }
  1626. /**
  1627. * Calculate Curve-independend factors, to be used later in the Slur- and TieCurvePoints calculation
  1628. */
  1629. private calculateCurveParametersArrays(): void {
  1630. this.tPower3 = new Array(this.bezierCurveStepSize);
  1631. this.oneMinusTPower3 = new Array(this.bezierCurveStepSize);
  1632. this.factorOne = new Array(this.bezierCurveStepSize);
  1633. this.factorTwo = new Array(this.bezierCurveStepSize);
  1634. for (let i: number = 0; i < this.bezierCurveStepSize; i++) {
  1635. const t: number = i / this.bezierCurveStepSize;
  1636. this.tPower3[i] = Math.pow(t, 3);
  1637. this.oneMinusTPower3[i] = Math.pow((1 - t), 3);
  1638. this.factorOne[i] = 3 * Math.pow((1 - t), 2) * t;
  1639. this.factorTwo[i] = 3 * (1 - t) * Math.pow(t, 2);
  1640. }
  1641. }
  1642. }
  1643. // TODO maybe this should be moved to OSMDOptions. Also see OpenSheetMusicDisplay.PageFormatStandards
  1644. export class PageFormat {
  1645. constructor(width: number, height: number, idString: string = "noIdStringGiven") {
  1646. this.width = width;
  1647. this.height = height;
  1648. this.idString = idString;
  1649. }
  1650. public width: number;
  1651. public height: number;
  1652. public idString: string;
  1653. public get aspectRatio(): number {
  1654. if (!this.IsUndefined) {
  1655. return this.width / this.height;
  1656. } else {
  1657. return 0; // infinite page height
  1658. }
  1659. }
  1660. /** Undefined page format: use default page format. */
  1661. public get IsUndefined(): boolean {
  1662. return this.width === undefined || this.height === undefined || this.height === 0 || this.width === 0;
  1663. }
  1664. public static get UndefinedPageFormat(): PageFormat {
  1665. return new PageFormat(0, 0);
  1666. }
  1667. public Equals(otherPageFormat: PageFormat): boolean {
  1668. if (!otherPageFormat) {
  1669. return false;
  1670. }
  1671. return otherPageFormat.width === this.width && otherPageFormat.height === this.height;
  1672. }
  1673. }