barmark 0.19.0 → 0.19.1
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 +13 -1
- package/dist/chords/harte.js +27 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,17 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.19.1] - 2026-11-07
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- **`harteToBarmark` names an interval list as its shorthand does.**
|
|
17
|
+
`C:(1,b3,b5,b7)` gave `Cdim(7)`, the alphabetical first of the names
|
|
18
|
+
spelling those notes, while `C:hdim7` gave `Cm7(b5)`, the grammar's
|
|
19
|
+
spelling of `ø`. When several names spell the notes equally well, the
|
|
20
|
+
one a Harte shorthand means now wins, so both give `Cm7(b5)`. Only the
|
|
21
|
+
half-diminished seventh was named differently.
|
|
22
|
+
|
|
12
23
|
## [0.19.0] - 2026-11-07
|
|
13
24
|
|
|
14
25
|
### Added
|
|
@@ -579,7 +590,8 @@ The first working release: the reference parser and printer for the
|
|
|
579
590
|
|
|
580
591
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
581
592
|
|
|
582
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.19.
|
|
593
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.19.1...HEAD
|
|
594
|
+
[0.19.1]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.19.0...barmark-v0.19.1
|
|
583
595
|
[0.19.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.18.0...barmark-v0.19.0
|
|
584
596
|
[0.18.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.17.1...barmark-v0.18.0
|
|
585
597
|
[0.17.1]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.17.0...barmark-v0.17.1
|
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
|
}
|