barmark 0.19.0 → 0.20.0
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/CHANGELOG.md +34 -1
- package/dist/chart/direction.js +25 -0
- package/dist/chart/expand.js +8 -1
- package/dist/chords/harte.js +27 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,37 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.20.0] - 2026-11-08
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **`->` cuts the replay's last bar as written** (Kevin's decision,
|
|
17
|
+
2026-11-08, grammar 6). It used to cut the last bar played, so a
|
|
18
|
+
`Fine` or `To Coda` that stopped the replay early, after the jump, cut
|
|
19
|
+
a bar before the stop instead: `## Intro` holding `| E7 | Fine |`,
|
|
20
|
+
replayed as `## Intro ->` after a `D.S. al Fine`, played nothing. Now
|
|
21
|
+
the cut bar is the last one written in the replayed section (from the
|
|
22
|
+
last pass with `x N`); when play stops before it, it is never reached,
|
|
23
|
+
the replay plays up to the stop and its occurrence's `elided` is false.
|
|
24
|
+
- **A `Coda` with no bar after it is an error** (Kevin's decision,
|
|
25
|
+
2026-11-08, grammar 5.2): "Coda has no bar after it, so To Coda has
|
|
26
|
+
nowhere to go on", on the `Coda`'s line. The `Coda` an `al Coda` goes
|
|
27
|
+
on needs a bar after it: a bar written later in the chart, or a later
|
|
28
|
+
heading that replays one (`## Chorus` alone, the last chorus as the
|
|
29
|
+
coda). Like every direction error, it drops the jump. Before, such a chart parsed cleanly and played
|
|
30
|
+
nothing after `To Coda`.
|
|
31
|
+
|
|
32
|
+
## [0.19.1] - 2026-11-07
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- **`harteToBarmark` names an interval list as its shorthand does.**
|
|
37
|
+
`C:(1,b3,b5,b7)` gave `Cdim(7)`, the alphabetical first of the names
|
|
38
|
+
spelling those notes, while `C:hdim7` gave `Cm7(b5)`, the grammar's
|
|
39
|
+
spelling of `ø`. When several names spell the notes equally well, the
|
|
40
|
+
one a Harte shorthand means now wins, so both give `Cm7(b5)`. Only the
|
|
41
|
+
half-diminished seventh was named differently.
|
|
42
|
+
|
|
12
43
|
## [0.19.0] - 2026-11-07
|
|
13
44
|
|
|
14
45
|
### Added
|
|
@@ -579,7 +610,9 @@ The first working release: the reference parser and printer for the
|
|
|
579
610
|
|
|
580
611
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
581
612
|
|
|
582
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.
|
|
613
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.20.0...HEAD
|
|
614
|
+
[0.20.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.19.1...barmark-v0.20.0
|
|
615
|
+
[0.19.1]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.19.0...barmark-v0.19.1
|
|
583
616
|
[0.19.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.18.0...barmark-v0.19.0
|
|
584
617
|
[0.18.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.17.1...barmark-v0.18.0
|
|
585
618
|
[0.17.1]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.17.0...barmark-v0.17.1
|
package/dist/chart/direction.js
CHANGED
|
@@ -61,6 +61,27 @@ function missingMarks(jump, plan, first) {
|
|
|
61
61
|
const name = printDirection(jump.direction);
|
|
62
62
|
return wants.filter(([missing]) => missing).map(([, what]) => `${name} has ${what}`);
|
|
63
63
|
}
|
|
64
|
+
const writes = (l) => l.kind === "bars" || l.kind === "invalid";
|
|
65
|
+
/** Whether the section heading at `i` is a replay: no bar line before the next heading. */
|
|
66
|
+
function isReplay(lines, i) {
|
|
67
|
+
const next = lines.findIndex((l, k) => k > i && l.kind === "section");
|
|
68
|
+
return !lines.slice(i + 1, next < 0 ? undefined : next).some(writes);
|
|
69
|
+
}
|
|
70
|
+
/** Whether a bar follows `m`: on its line, on a later one, or in a later replay (grammar 5.2). */
|
|
71
|
+
function barAfter(lines, m) {
|
|
72
|
+
return lines.some((l, i) => {
|
|
73
|
+
if (l.line < m.line)
|
|
74
|
+
return false;
|
|
75
|
+
if (l.kind === "section")
|
|
76
|
+
return l.line > m.line && isReplay(lines, i);
|
|
77
|
+
if (l.kind === "invalid")
|
|
78
|
+
return l.line > m.line && l.written > 0;
|
|
79
|
+
if (l.kind !== "bars")
|
|
80
|
+
return false;
|
|
81
|
+
const cells = l.line === m.line ? l.cells.slice(m.cell + 1) : l.cells;
|
|
82
|
+
return cells.some((c) => c.kind === "slots" || c.kind === "simile");
|
|
83
|
+
});
|
|
84
|
+
}
|
|
64
85
|
/** The marks no jump uses: each is an error. */
|
|
65
86
|
function unusedMarks(plan, first) {
|
|
66
87
|
const used = {
|
|
@@ -91,6 +112,10 @@ export function planJump(lines, error) {
|
|
|
91
112
|
const plan = jump?.direction.kind === "jump" ? jump.direction : null;
|
|
92
113
|
if (jump && plan)
|
|
93
114
|
problems.push(...missingMarks(jump, plan, first).map((m) => [jump, m]));
|
|
115
|
+
const coda = first.get("coda");
|
|
116
|
+
// Only the Coda an al Coda goes on; an unused one is an error of its own.
|
|
117
|
+
if (coda && plan?.al === "coda" && !barAfter(lines, coda))
|
|
118
|
+
problems.push([coda, "Coda has no bar after it, so To Coda has nowhere to go on"]);
|
|
94
119
|
for (const m of unusedMarks(plan, first))
|
|
95
120
|
problems.push([m, `${printDirection(m.direction)}: no jump uses it`]);
|
|
96
121
|
for (const [m, message] of problems)
|
package/dist/chart/expand.js
CHANGED
|
@@ -424,6 +424,12 @@ sing) {
|
|
|
424
424
|
times(h.repeat, h.line, out, (into) => playItems(itemsOf.get(s) ?? [], into));
|
|
425
425
|
return { replayOf: null, elided: false };
|
|
426
426
|
};
|
|
427
|
+
/** Whether `out` ends with the last bar written in `s` (grammar 6: what `->` cuts). */
|
|
428
|
+
const reachesEnd = (s, out) => {
|
|
429
|
+
const bars = s.lines.flatMap((l) => (l.kind === "bars" ? (resolved.get(l) ?? []) : []));
|
|
430
|
+
const last = bars.findLast((p) => p.kind === "bar");
|
|
431
|
+
return last?.kind === "bar" && flattenBars(out).at(-1)?.written === last.written;
|
|
432
|
+
};
|
|
427
433
|
/** A replay's bars into `out`, then its own lines; null when it replays nothing. */
|
|
428
434
|
const playReplay = (s, h, out) => {
|
|
429
435
|
// A nameless heading is already an error; it has nothing to replay.
|
|
@@ -437,7 +443,8 @@ sing) {
|
|
|
437
443
|
where.replay = h.line;
|
|
438
444
|
times(h.repeat, h.line, out, (into) => playItems(itemsOf.get(source) ?? [], into));
|
|
439
445
|
where.replay = null;
|
|
440
|
-
|
|
446
|
+
// It cuts the last bar as written; play stopped before it (a Fine, a To Coda) never reaches it.
|
|
447
|
+
const elided = h.elided && reachesEnd(source, out) && removeLastBar(out);
|
|
441
448
|
// A replay heading stands for its bars: its own lines (directives) come after them.
|
|
442
449
|
playItems(itemsOf.get(s) ?? [], out);
|
|
443
450
|
return { replayOf: source.heading.line, elided };
|
package/dist/chords/harte.js
CHANGED
|
@@ -70,6 +70,30 @@ const INTENDED = {
|
|
|
70
70
|
};
|
|
71
71
|
/** Own keys only: a label like `C:constructor` must not find Object.prototype. */
|
|
72
72
|
const intendedShape = (name) => Object.hasOwn(INTENDED, name) ? INTENDED[name] : undefined;
|
|
73
|
+
let shorthandNames = null;
|
|
74
|
+
/**
|
|
75
|
+
* Each shorthand's suffix by the notes it means: an interval list spelling a
|
|
76
|
+
* shorthand's notes takes its name (`C:(1,b3,b5,b7)` is `Cm7(b5)`, as `C:hdim7`
|
|
77
|
+
* is, not the `Cdim(7)` that spells the same notes).
|
|
78
|
+
*/
|
|
79
|
+
function shorthandFor(intervals) {
|
|
80
|
+
if (!shorthandNames) {
|
|
81
|
+
shorthandNames = new Map();
|
|
82
|
+
for (const s of Object.values(INTENDED)) {
|
|
83
|
+
const key = intervalSetKey(chordIntervals({ ...s, root: "C", bass: null }, "").intervals);
|
|
84
|
+
if (!shorthandNames.has(key))
|
|
85
|
+
shorthandNames.set(key, printSuffix(s));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return shorthandNames.get(intervalSetKey(intervals));
|
|
89
|
+
}
|
|
90
|
+
/** The candidate naming most degrees as written; on a tie, a shorthand's name, else the first. */
|
|
91
|
+
function bestSuffix(candidates, exact, intervals) {
|
|
92
|
+
const most = Math.max(...candidates.map(exact));
|
|
93
|
+
const tied = candidates.filter((c) => exact(c) === most);
|
|
94
|
+
const shorthand = shorthandFor(intervals);
|
|
95
|
+
return (tied.find((c) => c.suffix === shorthand) ?? tied[0])?.suffix;
|
|
96
|
+
}
|
|
73
97
|
const HARTE = /^([A-G][#b]*)(?::([^(/]*)(?:\(([^)]*)\))?)?(?:\/([#b]*\d+))?$/;
|
|
74
98
|
/** A Harte label's root, intervals (shorthand at its intended meaning, list applied) and bass. */
|
|
75
99
|
export function parseHarte(label) {
|
|
@@ -121,10 +145,11 @@ export function harteToBarmark(label) {
|
|
|
121
145
|
const direct = directShape ? printSuffix(directShape) : undefined;
|
|
122
146
|
const candidates = rootSounds ? enumerateSuffixes().get(intervalSetKey(h.intervals)) : undefined;
|
|
123
147
|
// Same notes, several names (A11 and A9sus4 under the eleventh rule): take the
|
|
124
|
-
// one naming most degrees as the label wrote them, then
|
|
148
|
+
// one naming most degrees as the label wrote them, then a shorthand's name,
|
|
149
|
+
// then the shortest.
|
|
125
150
|
const written = new Set(h.intervals.map(formatInterval));
|
|
126
151
|
const exact = (c) => c.intervals.filter((i) => written.has(formatInterval(i))).length;
|
|
127
|
-
const suffix = direct ?? candidates
|
|
152
|
+
const suffix = direct ?? (candidates && bestSuffix(candidates, exact, h.intervals));
|
|
128
153
|
if (suffix !== undefined && SINGLE_ACCIDENTAL.test(h.bass)) {
|
|
129
154
|
return `${h.root}${suffix}${h.bass === h.root ? "" : `/${h.bass}`}`;
|
|
130
155
|
}
|