@goplayerjuggler/abc-tools 1.0.17 → 1.0.18
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 +33 -11
- package/src/sort/get-contour.js +1 -1
package/package.json
CHANGED
package/src/manipulator.js
CHANGED
|
@@ -179,6 +179,7 @@ function toggleMeterDoubling(abc, smallMeter, largeMeter, currentMeter) {
|
|
|
179
179
|
|
|
180
180
|
const parsed = parseAbc(abc);
|
|
181
181
|
const { headerLines, barLines, musicText, bars, meter } = parsed;
|
|
182
|
+
|
|
182
183
|
// throw if there's a change of meter or unit length in the tune
|
|
183
184
|
if (barLines.find((bl) => bl.newMeter || bl.newUnitLength)) {
|
|
184
185
|
throw new Error("change of meter or unit length not handled");
|
|
@@ -269,13 +270,6 @@ function toggleMeterDoubling(abc, smallMeter, largeMeter, currentMeter) {
|
|
|
269
270
|
continue;
|
|
270
271
|
}
|
|
271
272
|
|
|
272
|
-
// If the current bar starts with a variant, keep its bar line
|
|
273
|
-
const currentBarVariant = barStartsWithVariant.get(i);
|
|
274
|
-
if (currentBarVariant) {
|
|
275
|
-
barLineDecisions.set(i, { action: "keep" });
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
273
|
// This is a complete bar - use its barNumber to decide
|
|
280
274
|
// Without anacrucis: Remove complete bars with even barNumber (0, 2, 4, ...), keep odd ones (1, 3, 5, ...)
|
|
281
275
|
// With anacrucis: the other way round!
|
|
@@ -287,6 +281,15 @@ function toggleMeterDoubling(abc, smallMeter, largeMeter, currentMeter) {
|
|
|
287
281
|
? barLine.barNumber % 2 !== 0
|
|
288
282
|
: barLine.barNumber % 2 === 0;
|
|
289
283
|
if (remove) {
|
|
284
|
+
// Check if current bar starts with variant
|
|
285
|
+
if (barStartsWithVariant.has(i)) {
|
|
286
|
+
const variantToken = barStartsWithVariant.get(i);
|
|
287
|
+
barLinesToConvert.set(variantToken.sourceIndex, {
|
|
288
|
+
oldLength: variantToken.sourceLength,
|
|
289
|
+
oldText: variantToken.token
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
// Also check if next bar starts with variant
|
|
290
293
|
const nextBarIdx = i + 1;
|
|
291
294
|
if (nextBarIdx < bars.length && barStartsWithVariant.has(nextBarIdx)) {
|
|
292
295
|
const variantToken = barStartsWithVariant.get(nextBarIdx);
|
|
@@ -302,6 +305,26 @@ function toggleMeterDoubling(abc, smallMeter, largeMeter, currentMeter) {
|
|
|
302
305
|
}
|
|
303
306
|
}
|
|
304
307
|
|
|
308
|
+
// --- Debugging - may be helpful ----
|
|
309
|
+
// console.log(
|
|
310
|
+
// "Bar line decisions:",
|
|
311
|
+
// Array.from(barLineDecisions.entries()).map(([i, d]) => ({
|
|
312
|
+
// index: i,
|
|
313
|
+
// barLine: barLines[i]?.text,
|
|
314
|
+
// sourceIndex: barLines[i]?.sourceIndex,
|
|
315
|
+
// action: d.action
|
|
316
|
+
// }))
|
|
317
|
+
// );
|
|
318
|
+
|
|
319
|
+
// console.log(
|
|
320
|
+
// "Bar lines:",
|
|
321
|
+
// barLines.map((bl) => ({ text: bl.text, sourceIndex: bl.sourceIndex }))
|
|
322
|
+
// );
|
|
323
|
+
// console.log(
|
|
324
|
+
// "Bars starting with variants:",
|
|
325
|
+
// Array.from(barStartsWithVariant.entries())
|
|
326
|
+
// );
|
|
327
|
+
|
|
305
328
|
// Reconstruct music
|
|
306
329
|
let newMusic = "";
|
|
307
330
|
let pos = 0;
|
|
@@ -383,10 +406,9 @@ function toggleMeter_4_4_to_4_2(abc, currentMeter) {
|
|
|
383
406
|
}
|
|
384
407
|
|
|
385
408
|
const defaultCommentForReelConversion =
|
|
386
|
-
"*abc-tools: convert
|
|
387
|
-
const defaultCommentForHornpipeConversion =
|
|
388
|
-
|
|
389
|
-
const defaultCommentForJigConversion = "*abc-tools: convert jig to M:12/8*";
|
|
409
|
+
"*abc-tools: convert to M:4/4 & L:1/16*";
|
|
410
|
+
const defaultCommentForHornpipeConversion = "*abc-tools: convert to M:4/2*";
|
|
411
|
+
const defaultCommentForJigConversion = "*abc-tools: convert to M:12/8*";
|
|
390
412
|
/**
|
|
391
413
|
* Adjusts bar lengths and L, M fields - a
|
|
392
414
|
* reel written in the normal way (M:4/4 L:1/8) is written
|