barmark 0.8.0 → 0.9.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 +21 -1
- package/README.md +1 -1
- package/dist/chart/directives.js +35 -4
- package/dist/chart/expand.js +6 -2
- package/dist/chart/print.js +1 -1
- package/dist/chart/types.d.ts +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,25 @@ Releases follow the process in [RELEASING.md](RELEASING.md).
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.9.0] - 2026-11-02
|
|
13
|
+
|
|
14
|
+
An optional swing amount for `feel:` (`swing 58%`), issue #66. Charts
|
|
15
|
+
that read before read and print the same. Implements the
|
|
16
|
+
[grammar v0.1 draft](https://github.com/kevinpeckham/barmark/blob/main/docs/grammar-v0.1-draft.md).
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- **A swing amount** (grammar 7.1, issue #66): `feel: swing 58%`,
|
|
21
|
+
`feel: shuffle 62.5%`, `feel: swing 16 55%`. The amount is where the
|
|
22
|
+
swung note lands, as a percentage of its pair, from 50% to 75%
|
|
23
|
+
inclusive, with the `%` required. It reaches `Directives.swingPercent`
|
|
24
|
+
and each played bar's `swingPercent`; both are absent for the bare word,
|
|
25
|
+
which stays the triplet feel (66.7%). `swing 66.7%` reads and prints as
|
|
26
|
+
`swing`, so every chart that read before reads and prints the same.
|
|
27
|
+
- Errors, each on its line: an amount outside 50% to 75%, more than one
|
|
28
|
+
decimal place, a missing `%` (`swing 58` suggests `swing 58%`), an amount
|
|
29
|
+
on `straight` (suggests `swing` with it), and an amount with no kind.
|
|
30
|
+
|
|
12
31
|
## [0.8.0] - 2026-11-02
|
|
13
32
|
|
|
14
33
|
`(add9)` and friends inside parentheses, clearer messages for an empty
|
|
@@ -202,7 +221,8 @@ The first working release: the reference parser and printer for the
|
|
|
202
221
|
|
|
203
222
|
- **A placeholder package that holds the `barmark` name** while the spec and parser are written.
|
|
204
223
|
|
|
205
|
-
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.
|
|
224
|
+
[Unreleased]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.9.0...HEAD
|
|
225
|
+
[0.9.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.8.0...barmark-v0.9.0
|
|
206
226
|
[0.8.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.7.0...barmark-v0.8.0
|
|
207
227
|
[0.7.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.6.0...barmark-v0.7.0
|
|
208
228
|
[0.6.0]: https://github.com/kevinpeckham/barmark/compare/barmark-v0.5.0...barmark-v0.6.0
|
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
|
|
48
48
|
const chart = parseChart(text);
|
|
49
49
|
chart.title; // "Example Song"
|
|
50
|
-
chart.bars; // every bar in play order: slots, section, key, meter, tempo, feel
|
|
50
|
+
chart.bars; // every bar in play order: slots, section, key, meter, tempo, feel (and swingPercent)
|
|
51
51
|
chart.sections; // each section as played, with its first and last bar
|
|
52
52
|
chart.diagnostics; // errors and warnings, each with a line number
|
|
53
53
|
|
package/dist/chart/directives.js
CHANGED
|
@@ -55,9 +55,40 @@ function parseTempoChange(text) {
|
|
|
55
55
|
const to = m[2] === undefined ? null : parseTempo(m[2]);
|
|
56
56
|
return m[2] !== undefined && to === null ? null : { kind, to };
|
|
57
57
|
}
|
|
58
|
+
/** The amount that means the same as the bare word: the triplet feel, ⅔ written to one decimal. */
|
|
59
|
+
const TRIPLET_PERCENT = 66.7;
|
|
60
|
+
const FEEL_ERROR = "feel must be straight, swing, shuffle or swing 16, optionally with an amount (swing 58%)";
|
|
61
|
+
/** A feel and an amount: `swing 16 55%` is "swing 16", "55", "%". */
|
|
62
|
+
const WITH_AMOUNT = /^(.*?)\s*(\d+(?:\.\d+)?)(%?)$/;
|
|
63
|
+
/** Why `head digits sign` isn't a feel with an amount, or null when it is (7.1). */
|
|
64
|
+
function amountError(head, digits, sign) {
|
|
65
|
+
const feel = FEELS.find((f) => f === head);
|
|
66
|
+
if (head && !feel)
|
|
67
|
+
return FEEL_ERROR;
|
|
68
|
+
if (!feel)
|
|
69
|
+
return `a swing amount follows a feel: swing ${digits}%`;
|
|
70
|
+
if (feel === "straight")
|
|
71
|
+
return `straight takes no amount; write swing ${digits}%`;
|
|
72
|
+
if (!sign)
|
|
73
|
+
return `a swing amount needs a % sign: ${feel} ${digits}%`;
|
|
74
|
+
if (/\.\d{2}/.test(digits))
|
|
75
|
+
return "a swing amount takes at most one decimal place";
|
|
76
|
+
const amount = Number(digits);
|
|
77
|
+
return amount < 50 || amount > 75 ? "a swing amount must be from 50% to 75%" : null;
|
|
78
|
+
}
|
|
79
|
+
/** `swing`, `swing 58%`, `swing 16 55%`: a kind, then an optional amount (7.1). */
|
|
58
80
|
function parseFeel(text) {
|
|
59
81
|
const lower = text.toLowerCase();
|
|
60
|
-
|
|
82
|
+
const bare = FEELS.find((f) => f === lower);
|
|
83
|
+
if (bare)
|
|
84
|
+
return { feel: bare };
|
|
85
|
+
const [, head = "", digits = "", sign = ""] = WITH_AMOUNT.exec(lower) ?? [];
|
|
86
|
+
const error = digits ? amountError(head, digits, sign) : FEEL_ERROR;
|
|
87
|
+
const feel = FEELS.find((f) => f === head);
|
|
88
|
+
if (error || !feel)
|
|
89
|
+
return { error: error ?? FEEL_ERROR };
|
|
90
|
+
const amount = Number(digits);
|
|
91
|
+
return amount === TRIPLET_PERCENT ? { feel } : { feel, swingPercent: amount };
|
|
61
92
|
}
|
|
62
93
|
/**
|
|
63
94
|
* A directive line: one or more `name: value` parts separated by commas.
|
|
@@ -113,10 +144,10 @@ export function parseDirectiveLine(text, line) {
|
|
|
113
144
|
}
|
|
114
145
|
else {
|
|
115
146
|
const feel = parseFeel(value);
|
|
116
|
-
if (feel)
|
|
117
|
-
|
|
147
|
+
if ("error" in feel)
|
|
148
|
+
error(feel.error, value);
|
|
118
149
|
else
|
|
119
|
-
|
|
150
|
+
Object.assign(set, feel);
|
|
120
151
|
}
|
|
121
152
|
}
|
|
122
153
|
return { set, diagnostics };
|
package/dist/chart/expand.js
CHANGED
|
@@ -126,6 +126,7 @@ export function expand(lines) {
|
|
|
126
126
|
tempo: null,
|
|
127
127
|
change: null,
|
|
128
128
|
feel: "straight",
|
|
129
|
+
swingPercent: undefined,
|
|
129
130
|
};
|
|
130
131
|
const warned = new Set();
|
|
131
132
|
const warn = (line, message, token) => {
|
|
@@ -159,8 +160,10 @@ export function expand(lines) {
|
|
|
159
160
|
}
|
|
160
161
|
if (set.tempoChange)
|
|
161
162
|
changeTempo(set.tempoChange, line);
|
|
162
|
-
if (set.feel)
|
|
163
|
+
if (set.feel) {
|
|
163
164
|
state.feel = set.feel;
|
|
165
|
+
state.swingPercent = set.swingPercent;
|
|
166
|
+
}
|
|
164
167
|
};
|
|
165
168
|
let count = 0;
|
|
166
169
|
let work = 0;
|
|
@@ -198,7 +201,7 @@ export function expand(lines) {
|
|
|
198
201
|
token: `${k}`,
|
|
199
202
|
});
|
|
200
203
|
}
|
|
201
|
-
const { key, tempo, change: tempoChange, feel } = state;
|
|
204
|
+
const { key, tempo, change: tempoChange, feel, swingPercent } = state;
|
|
202
205
|
out.push({
|
|
203
206
|
kind: "bar",
|
|
204
207
|
bar: {
|
|
@@ -210,6 +213,7 @@ export function expand(lines) {
|
|
|
210
213
|
tempo,
|
|
211
214
|
tempoChange,
|
|
212
215
|
feel,
|
|
216
|
+
...(swingPercent === undefined ? {} : { swingPercent }),
|
|
213
217
|
slots: p.slots,
|
|
214
218
|
},
|
|
215
219
|
});
|
package/dist/chart/print.js
CHANGED
|
@@ -79,7 +79,7 @@ function printDirectives(d) {
|
|
|
79
79
|
if (d.tempoChange)
|
|
80
80
|
parts.push(`tempo: ${printTempoChange(d.tempoChange)}`);
|
|
81
81
|
if (d.feel)
|
|
82
|
-
parts.push(`feel: ${d.feel}`);
|
|
82
|
+
parts.push(`feel: ${d.feel}${d.swingPercent === undefined ? "" : ` ${d.swingPercent}%`}`);
|
|
83
83
|
return parts.join(", ");
|
|
84
84
|
}
|
|
85
85
|
/**
|
package/dist/chart/types.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ export type Directives = {
|
|
|
32
32
|
tempo?: number;
|
|
33
33
|
tempoChange?: TempoChange;
|
|
34
34
|
feel?: Feel;
|
|
35
|
+
/**
|
|
36
|
+
* How far a swing or shuffle swings: where the swung note lands, as a
|
|
37
|
+
* percentage of its pair (50 to 75). Absent for the bare word, which
|
|
38
|
+
* means 66.7 (the triplet feel), and for straight.
|
|
39
|
+
*/
|
|
40
|
+
swingPercent?: number;
|
|
35
41
|
};
|
|
36
42
|
/** A chord slot holds a chord symbol or a note set; `chord.kind` tells which. */
|
|
37
43
|
export type SimpleSlot = {
|
|
@@ -110,6 +116,8 @@ export type PlayedBar = {
|
|
|
110
116
|
to: number | null;
|
|
111
117
|
} | null;
|
|
112
118
|
feel: Feel;
|
|
119
|
+
/** The swing amount in force (Directives.swingPercent); absent when the feel has none. */
|
|
120
|
+
swingPercent?: number;
|
|
113
121
|
/** `%` resolved to the copied slots; holds stay holds. */
|
|
114
122
|
slots: Slot[];
|
|
115
123
|
};
|