@goplayerjuggler/abc-tools 1.0.24 → 1.0.25
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/incipit.js +5 -4
- package/src/manipulator.js +30 -3
package/package.json
CHANGED
package/src/incipit.js
CHANGED
|
@@ -296,12 +296,13 @@ function getIncipit(data) {
|
|
|
296
296
|
(currentMeter[0] === 4 &&
|
|
297
297
|
currentMeter[1] === 2 &&
|
|
298
298
|
unitLength.den === 8) ||
|
|
299
|
-
(currentMeter[0] === 12 && currentMeter[1] === 8)
|
|
300
|
-
|
|
299
|
+
(currentMeter[0] === 12 && currentMeter[1] === 8) ||
|
|
300
|
+
(currentMeter[0] >= 12 && currentMeter[0] < 16)
|
|
301
|
+
)
|
|
301
302
|
numBars = new Fraction(3, 2);
|
|
302
|
-
|
|
303
|
+
else if (currentMeter[0] === 3 && [4, 8].indexOf(currentMeter[1]) >= 0)
|
|
303
304
|
numBars = 3;
|
|
304
|
-
|
|
305
|
+
else if (currentMeter[0] >= 16) numBars = 1;
|
|
305
306
|
}
|
|
306
307
|
abc = sanitise(abc);
|
|
307
308
|
return getFirstBars(abc, numBars, withAnacrucis, false, { all: true });
|
package/src/manipulator.js
CHANGED
|
@@ -725,6 +725,30 @@ function convertStandardHornpipe(
|
|
|
725
725
|
}
|
|
726
726
|
return result;
|
|
727
727
|
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Doubles the bar length of an ABC string when the
|
|
731
|
+
* ABC is eligible (as determined by canDoubleBarLength()).
|
|
732
|
+
* @param {string} abc
|
|
733
|
+
* @param {string} rhythm
|
|
734
|
+
* @returns {string}
|
|
735
|
+
*/
|
|
736
|
+
function maybeConvertStandardTune(abc, rhythm) {
|
|
737
|
+
if (!canDoubleBarLength(abc, { rhythm })) return abc;
|
|
738
|
+
switch (rhythm) {
|
|
739
|
+
case "reel":
|
|
740
|
+
return convertStandardReel(abc);
|
|
741
|
+
case "jig":
|
|
742
|
+
return convertStandardJig(abc);
|
|
743
|
+
case "polka":
|
|
744
|
+
return convertStandardPolka(abc);
|
|
745
|
+
case "hornpipe":
|
|
746
|
+
return convertStandardHornpipe(abc);
|
|
747
|
+
default:
|
|
748
|
+
return abc;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
728
752
|
function doubleBarLength(abc, comment = null) {
|
|
729
753
|
const meter = getMeter(abc);
|
|
730
754
|
if (!Array.isArray(meter) || !meter) {
|
|
@@ -1061,10 +1085,12 @@ function getFirstBars(
|
|
|
1061
1085
|
)}`;
|
|
1062
1086
|
}
|
|
1063
1087
|
|
|
1064
|
-
function canDoubleBarLength(abc) {
|
|
1065
|
-
const
|
|
1088
|
+
function canDoubleBarLength(abc, info = {}) {
|
|
1089
|
+
const {
|
|
1090
|
+
meter = getMeter(abc),
|
|
1066
1091
|
l = getUnitLength(abc),
|
|
1067
|
-
rhythm = getHeaderValue(abc, "R")
|
|
1092
|
+
rhythm = getHeaderValue(abc, "R")
|
|
1093
|
+
} = info;
|
|
1068
1094
|
if (
|
|
1069
1095
|
!rhythm ||
|
|
1070
1096
|
["reel", "hornpipe", "jig", "polka"].indexOf(rhythm.toLowerCase()) < 0
|
|
@@ -1125,6 +1151,7 @@ module.exports = {
|
|
|
1125
1151
|
filterHeaders,
|
|
1126
1152
|
getFirstBars,
|
|
1127
1153
|
hasAnacrucis,
|
|
1154
|
+
maybeConvertStandardTune,
|
|
1128
1155
|
normaliseKey,
|
|
1129
1156
|
toggleMeter_4_4_to_4_2,
|
|
1130
1157
|
toggleMeter_6_8_to_12_8,
|