EngravingRules.ts 57 KB

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