You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
10798
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10799
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10780
10800
var keyAccidentals = __webpack_require__(/*! ../const/key-accidentals */ "./src/const/key-accidentals.js");
10781
10801
var _require = __webpack_require__(/*! ../const/relative-major */ "./src/const/relative-major.js"),
10782
10802
relativeMajor = _require.relativeMajor,
@@ -11073,6 +11093,7 @@ var strTranspose;
11073
11093
var regNote = /([_^=]*[A-Ga-g][,']*)(\d*\/*\d*)([\>\<\-\)\.\s\\]*)/;
11074
11094
var regOptionalNote = /([_^=]*[A-Ga-g][,']*)?(\d*\/*\d*)?([\>\<\-\)]*)?/;
11075
11095
var regSpace = /(\s*)$/;
11096
+
var regOptionalSpace = /(\s*)/;
11076
11097
11077
11098
// This the relationship of the note to the tonic and an octave. So what is returned is a distance in steps from the tonic and the amount of adjustment from
11078
11099
// a normal scale. That is - in the key of D an F# is two steps from the tonic and no adjustment. A G# is three steps from the tonic and one half-step higher.
@@ -11101,39 +11122,59 @@ var strTranspose;
11101
11122
};
11102
11123
}
11103
11124
function replaceNote(abc, start, end, newPitch, index) {
11104
-
// There may be more than just the note between the start and end - there could be spaces, there could be a chord symbol, there could be a decoration.
11105
-
// This could also be a part of a chord. If so, then the particular note needs to be teased out.
11106
11125
var note = abc.substring(start, end);
11107
-
var match = note.match(new RegExp(regNote.source + regSpace.source), '');
11126
+
// Try single note first
11127
+
var match = note.match(new RegExp(regNote.source + regSpace.source));
11108
11128
if (match) {
11109
-
// This will match a single note
11110
11129
var noteLen = match[1].length;
11111
11130
var trailingLen = match[2].length + match[3].length + match[4].length;
11112
11131
var leadingLen = end - start - noteLen - trailingLen;
11113
11132
start += leadingLen;
11114
11133
end -= trailingLen;
11115
11134
} else {
11116
-
// I don't know how to capture more than one note, so I'm separating them. There is a limit of the number of notes in a chord depending on the repeats I have here, but it is unlikely to happen in real music.
11135
+
// Match chord
11117
11136
var regPreBracket = /([^\[]*)/;
11118
11137
var regOpenBracket = /\[/;
11119
11138
var regCloseBracket = /\-?](\d*\/*\d*)?([\>\<\-\)]*)/;
0 commit comments