+ <credit-words default-x="1124" default-y="1393" font-size="12" font-weight="bold" halign="right" justify="center" valign="top" xml:space="preserve">Words and Music by
+ var compactMode = paramCompactMode && paramCompactMode !== '0';
+ var measureRangeStart = paramMeasureRangeStart ? Number.parseInt(paramMeasureRangeStart) : 0;
+ var measureRangeEnd = paramMeasureRangeEnd ? Number.parseInt(paramMeasureRangeEnd) : Number.MAX_SAFE_INTEGER;
+ if (measureRangeStart && measureRangeEnd && measureRangeEnd < measureRangeStart) {
+ console.log("[OSMD] warning: measure range end parameter should not be smaller than measure range start. We've set start measure = end measure now.")
+ measureRangeStart = measureRangeEnd;
+ }
+ let pageFormat = paramPageFormat ? paramPageFormat : "Endless";
+ var pageBackgroundColor = paramPageBackgroundColor ? "#" + paramPageBackgroundColor : undefined; // vexflow format, see OSMDOptions. can't use # in parameters.
+ // TODO after selectSampleOnChange, the resize handler triggers immediately,
+ // so we render twice at the start of the demo.
+ // maybe delay the first osmd render, e.g. when window ready?
+ if (paramOpenUrl) {
+ if (openSheetMusicDisplay.getLogLevel() < 2) { // debug or trace
+ console.log("[OSMD] selectSampleOnChange with " + paramOpenUrl);
+ }
+ // DEBUG: cause an error for a certain sample, for testing
+ // if (paramOpenUrl.startsWith("Beethoven")) {
+ // paramOpenUrl.causeError();
+ // }
+ selectSampleOnChange(paramOpenUrl);
+ } else {
+ if (openSheetMusicDisplay.getLogLevel() < 2) { // debug or trace
+ console.log("[OSMD] selectSampleOnChange without param");
+ }
+ selectSampleOnChange();
+ }
+ }
+
+ function findGetParameter(parameterName) {
+ // special treatment for the openUrl parameter, because different systems attach different arguments to an URL.
+ // because of CORS (cross-origin safety restrictions), you can only load an xml file from the same origin (server).
+
+ // test parameter: ?openUrl=https://opensheetmusiceducation.org/index.php?gf-download=2020%2F01%2FJohannSebastianBach_PraeludiumInCDur_BWV846_1.xml&endUrl&form-id=1&field-id=4&hash=c4ba271ef08204a26cbd4cd2d751c53b78f238c25ddbb1f343e1172f2ce2aa53
+ // (enable the console.log at the end of this method for testing)
+ // working test parameter in local demo: ?openUrl=OSMD_function_test_all.xml&endUrl
+
+ if (parameterName === 'openUrl') {
+ let startParameterName = 'openUrl=';
+ let endParameterName = '&endUrl';
+ let openUrlIndex = location.search.indexOf(startParameterName);
+ if (openUrlIndex < 0) {
+ return undefined;
+ }
+ let endIndex = location.search.indexOf(endParameterName) + endParameterName.length;
+ if (endIndex < 0) {
+ console.log("[OSMD] If using openUrl as a parameter, you have to end it with '&endUrl'. openUrl parameter omitted.");
+ return undefined;
+ }
+ let urlString = location.search.substring(openUrlIndex + startParameterName.length, endIndex - endParameterName.length);
+ public static FloatInaccuracyTolerance: number = 0.0001; // inaccuracy allowed when comparing Fraction.RealValues, because of floating point inaccuracy
+
+ public isOnBeat(timeSignature: Fraction): boolean { // use sourceMeasure.ActiveTimeSignature as timeSignature
+ const beatDistance: number = this.distanceFromBeat(timeSignature);
+ // // TODO MB: C# uses out keyword in .liesInsideBorders. Needs to be handled differently here.
+ // // Original C# for reference:
+ // // isCompletelyInside = this.psi.liesInsideBorders(psi, out leftBorderInside, out rightBorderInside, out topBorderInside, out bottomBorderInside);
+ // // Commented to not offend linter. End of where I commented marked below
+ * Returns the index of the closest previous (earlier) vertical container which has at least some visible staff entry, with respect to the given index.
+ * @param index
+ * @returns {number}
+ * @constructor
+ */
+ public GetPreviousVisibleContainerIndex(index: number): number {