@goplayerjuggler/abc-tools 1.0.22 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/manipulator.js +5 -3
- package/src/sort/contour-sort.js +14 -4
package/package.json
CHANGED
package/src/manipulator.js
CHANGED
|
@@ -175,6 +175,8 @@ function hasAnacrucis(abc) {
|
|
|
175
175
|
* @throws {Error} If the current meter doesn't match either smallMeter or largeMeter
|
|
176
176
|
*/
|
|
177
177
|
function toggleMeterDoubling(abc, smallMeter, largeMeter, currentMeter) {
|
|
178
|
+
//if no L: header at all: add one
|
|
179
|
+
if (!/\nL:\s*1\/8/.test(abc)) abc = abc.replace("\nK:", "\nL:1/8\nK:");
|
|
178
180
|
if (!currentMeter) currentMeter = getMeter(abc);
|
|
179
181
|
|
|
180
182
|
const isSmall =
|
|
@@ -649,7 +651,7 @@ function convertStandardReel(
|
|
|
649
651
|
}
|
|
650
652
|
|
|
651
653
|
let result = //toggleMeter_4_4_to_4_2(reel, meter);
|
|
652
|
-
toggleMeterDoubling(reel,
|
|
654
|
+
toggleMeterDoubling(reel, meter, [4, 2], meter);
|
|
653
655
|
if (comment) {
|
|
654
656
|
result = result.replace(/(\nK:)/, `\nN:${comment}$1`);
|
|
655
657
|
}
|
|
@@ -1074,8 +1076,8 @@ function canDoubleBarLength(abc) {
|
|
|
1074
1076
|
!abc.match(/\[L:/) &&
|
|
1075
1077
|
(((rhythm === "reel" || rhythm === "hornpipe") &&
|
|
1076
1078
|
l.equals(new Fraction(1, 8)) &&
|
|
1077
|
-
meter[0] === 4 &&
|
|
1078
|
-
|
|
1079
|
+
((meter[0] === 4 && meter[1] === 4) ||
|
|
1080
|
+
(meter[0] === 2 && meter[1] === 2))) ||
|
|
1079
1081
|
(rhythm === "jig" && meter[0] === 6 && meter[1] === 8))) ||
|
|
1080
1082
|
(rhythm === "polka" && meter[0] === 2 && meter[1] === 4)
|
|
1081
1083
|
);
|
package/src/sort/contour-sort.js
CHANGED
|
@@ -204,8 +204,10 @@ function sort(arr, options = {}) {
|
|
|
204
204
|
],
|
|
205
205
|
applySwingTransform = ["hornpipe", "barndance", "fling", "mazurka"],
|
|
206
206
|
getAbc: getAbcForContour = getAbcForContour_default,
|
|
207
|
-
getContourOptions = {
|
|
208
|
-
|
|
207
|
+
getContourOptions = () => {
|
|
208
|
+
return {
|
|
209
|
+
withSvg: true
|
|
210
|
+
};
|
|
209
211
|
}
|
|
210
212
|
} = options;
|
|
211
213
|
|
|
@@ -223,13 +225,21 @@ function sort(arr, options = {}) {
|
|
|
223
225
|
for (const tune of arr) {
|
|
224
226
|
if (!tune.contour) {
|
|
225
227
|
try {
|
|
228
|
+
const contourOptions = getContourOptions();
|
|
229
|
+
// if (
|
|
230
|
+
// tune.title?.indexOf("oldrick") >= 0 ||
|
|
231
|
+
// ) {
|
|
232
|
+
// console.log("debug");
|
|
233
|
+
// }
|
|
226
234
|
const withSwingTransform =
|
|
227
235
|
applySwingTransform.indexOf(tune.rhythm) >= 0;
|
|
228
236
|
const shortAbc = getAbcForContour(tune);
|
|
229
237
|
|
|
230
238
|
if (shortAbc) {
|
|
231
|
-
|
|
232
|
-
|
|
239
|
+
contourOptions.withSwingTransform = withSwingTransform;
|
|
240
|
+
if (Object.hasOwn(tune, "contourShift"))
|
|
241
|
+
contourOptions.contourShift = tune.contourShift;
|
|
242
|
+
tune.contour = getContour(shortAbc, contourOptions);
|
|
233
243
|
}
|
|
234
244
|
} catch (error) {
|
|
235
245
|
console.log(error);
|