barmark 0.14.1 → 0.16.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 +65 -1
- package/README.md +24 -0
- package/dist/chart/barLine.js +57 -14
- package/dist/chart/credits.d.ts +9 -0
- package/dist/chart/credits.js +62 -0
- package/dist/chart/directives.d.ts +2 -0
- package/dist/chart/directives.js +2 -0
- package/dist/chart/document.d.ts +4 -3
- package/dist/chart/document.js +72 -48
- package/dist/chart/expand.d.ts +3 -1
- package/dist/chart/expand.js +11 -2
- package/dist/chart/index.d.ts +6 -0
- package/dist/chart/index.js +6 -0
- package/dist/chart/instruments.d.ts +27 -0
- package/dist/chart/instruments.js +48 -0
- package/dist/chart/lines.d.ts +14 -0
- package/dist/chart/lines.js +98 -0
- package/dist/chart/parse.d.ts +6 -3
- package/dist/chart/parse.js +99 -12
- package/dist/chart/partLine.d.ts +3 -0
- package/dist/chart/partLine.js +73 -0
- package/dist/chart/parts.d.ts +8 -3
- package/dist/chart/parts.js +50 -14
- package/dist/chart/pedal.d.ts +5 -0
- package/dist/chart/pedal.js +44 -0
- package/dist/chart/print.js +23 -8
- package/dist/chart/repeats.js +1 -1
- package/dist/chart/shares.d.ts +6 -0
- package/dist/chart/shares.js +10 -0
- package/dist/chart/systems.d.ts +2 -0
- package/dist/chart/systems.js +18 -3
- package/dist/chart/types.d.ts +50 -5
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a group divides its slot (grammar 2.2), as fractions summing to 1:
|
|
3
|
+
* equally, or 3:1 (1:3) when one member of a pair is dotted.
|
|
4
|
+
*/
|
|
5
|
+
export function memberShares(members) {
|
|
6
|
+
const dotted = members.findIndex((m) => m.dotted);
|
|
7
|
+
if (members.length === 2 && dotted >= 0)
|
|
8
|
+
return dotted === 0 ? [0.75, 0.25] : [0.25, 0.75];
|
|
9
|
+
return members.map(() => 1 / members.length);
|
|
10
|
+
}
|
package/dist/chart/systems.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ type BarsLine = Extract<Line, {
|
|
|
4
4
|
}>;
|
|
5
5
|
/** The marks of a bar line that shape the timeline, which every line of a system shares (grammar 7.4). */
|
|
6
6
|
export declare function structureOf(l: BarsLine): string;
|
|
7
|
+
/** The key a part's line is grouped and played by: its label, and its line's name if any (grammar 7.6). */
|
|
8
|
+
export declare const streamKey: (part: string, lineName?: string) => string;
|
|
7
9
|
/**
|
|
8
10
|
* Group a multi-part chart's labelled bar lines into systems and check that
|
|
9
11
|
* each system's lines share their bars and structure. A line that differs is
|
package/dist/chart/systems.js
CHANGED
|
@@ -33,6 +33,20 @@ function differs(l, ref) {
|
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
35
|
const isLabelled = (l) => (l.kind === "bars" || l.kind === "invalid") && l.part !== undefined;
|
|
36
|
+
/** The key a part's line is grouped and played by: its label, and its line's name if any (grammar 7.6). */
|
|
37
|
+
export const streamKey = (part, lineName) => (lineName === undefined ? part : `${part}.${lineName}`).toLowerCase();
|
|
38
|
+
/**
|
|
39
|
+
* What a line takes in its system, and what it can't share it with: its
|
|
40
|
+
* own stream, and its part written bare or as lines, which can't share a
|
|
41
|
+
* system (grammar 7.6).
|
|
42
|
+
*/
|
|
43
|
+
function claimsOf(l) {
|
|
44
|
+
const part = (l.part ?? "").toLowerCase();
|
|
45
|
+
if (l.lineName === undefined)
|
|
46
|
+
return { takes: [part, `${part}#bare`], clashes: [part, `${part}#lines`] };
|
|
47
|
+
const own = streamKey(part, l.lineName);
|
|
48
|
+
return { takes: [own, `${part}#lines`], clashes: [own, `${part}#bare`] };
|
|
49
|
+
}
|
|
36
50
|
/** Number each run of labelled lines with no label twice (grammar 7.4). */
|
|
37
51
|
function numberSystems(lines) {
|
|
38
52
|
let system = -1;
|
|
@@ -42,12 +56,13 @@ function numberSystems(lines) {
|
|
|
42
56
|
seen = null;
|
|
43
57
|
return l;
|
|
44
58
|
}
|
|
45
|
-
const
|
|
46
|
-
if (!seen || seen
|
|
59
|
+
const { takes, clashes } = claimsOf(l);
|
|
60
|
+
if (!seen || clashes.some((c) => seen?.has(c))) {
|
|
47
61
|
system++;
|
|
48
62
|
seen = new Set();
|
|
49
63
|
}
|
|
50
|
-
|
|
64
|
+
for (const c of takes)
|
|
65
|
+
seen.add(c);
|
|
51
66
|
return { ...l, system };
|
|
52
67
|
});
|
|
53
68
|
}
|
package/dist/chart/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ChordRecord } from "../chords/types.js";
|
|
2
|
+
import type { ClefName, InstrumentName } from "./instruments.js";
|
|
2
3
|
export type Severity = "error" | "warning";
|
|
3
4
|
export type ChartDiagnostic = {
|
|
4
5
|
line: number;
|
|
@@ -28,11 +29,14 @@ export type TempoChange = {
|
|
|
28
29
|
/** `tempo:` gives either `tempo` (a steady tempo) or `tempoChange`, never both. */
|
|
29
30
|
/**
|
|
30
31
|
* The part a chart is written for (grammar 7.3): `part: Electric Guitar 1`,
|
|
31
|
-
* or with a short label, `part: Gtr = Electric Guitar 1
|
|
32
|
+
* or with a short label, `part: Gtr = Electric Guitar 1`; `instrument:`
|
|
33
|
+
* and `clef:` may follow, and are present only when written.
|
|
32
34
|
*/
|
|
33
35
|
export type Part = {
|
|
34
36
|
name: string;
|
|
35
37
|
label?: string;
|
|
38
|
+
instrument?: InstrumentName;
|
|
39
|
+
clef?: ClefName;
|
|
36
40
|
};
|
|
37
41
|
export type Directives = {
|
|
38
42
|
key?: Key;
|
|
@@ -54,16 +58,19 @@ export type Articulation = "accent" | "hit";
|
|
|
54
58
|
* sixteenth, taken from the slot played just before it.
|
|
55
59
|
*/
|
|
56
60
|
export type Push = "eighth" | "sixteenth";
|
|
61
|
+
/** `+` presses the sustain pedal, or changes it when it is down; `*` lifts it (grammar 2.9). */
|
|
62
|
+
export type Pedal = "press" | "release";
|
|
57
63
|
/**
|
|
58
64
|
* A chord slot holds a chord symbol or a note set; `chord.kind` tells
|
|
59
65
|
* which. `voicing` is the exact notes written after a chord's name
|
|
60
66
|
* (`Cmaj7{E3 G3 B3}`, grammar 4.2). The optional fields are present only
|
|
61
67
|
* when written.
|
|
62
68
|
*/
|
|
63
|
-
export type SimpleSlot = {
|
|
69
|
+
export type SimpleSlot = ({
|
|
64
70
|
kind: "chord";
|
|
65
71
|
chord: ChordRecord;
|
|
66
72
|
voicing?: ChordRecord;
|
|
73
|
+
pedal?: Pedal;
|
|
67
74
|
articulation?: Articulation;
|
|
68
75
|
push?: Push;
|
|
69
76
|
} | {
|
|
@@ -76,6 +83,9 @@ export type SimpleSlot = {
|
|
|
76
83
|
push?: Push;
|
|
77
84
|
} | {
|
|
78
85
|
kind: "unknown";
|
|
86
|
+
}) & {
|
|
87
|
+
/** A dotted member of a two-member group (grammar 2.2): three quarters of its slot. */
|
|
88
|
+
dotted?: true;
|
|
79
89
|
};
|
|
80
90
|
export type Slot = SimpleSlot | {
|
|
81
91
|
kind: "group";
|
|
@@ -134,6 +144,10 @@ export type Cell = {
|
|
|
134
144
|
label: string;
|
|
135
145
|
};
|
|
136
146
|
export type Repeat = number | "open" | null;
|
|
147
|
+
/** Who a credit line names (grammar 7.5). */
|
|
148
|
+
export type CreditRole = "composer" | "lyricist" | "arranger" | "copyright";
|
|
149
|
+
/** A chart's credits, each role's entries in written order (grammar 7.5). */
|
|
150
|
+
export type Credits = Record<CreditRole, string[]>;
|
|
137
151
|
export type Line = {
|
|
138
152
|
kind: "title";
|
|
139
153
|
line: number;
|
|
@@ -162,6 +176,8 @@ export type Line = {
|
|
|
162
176
|
ending: number[] | null;
|
|
163
177
|
/** The declared label of the part whose line this is (grammar 7.4); absent on a tutti line and in a single-part chart. */
|
|
164
178
|
part?: string;
|
|
179
|
+
/** The part's line this is (`RH` in `Pno.RH`, grammar 7.6), as first spelled; absent on a part's bare line. */
|
|
180
|
+
lineName?: string;
|
|
165
181
|
/** Which system a labelled line is in, from 0 in chart order. */
|
|
166
182
|
system?: number;
|
|
167
183
|
/** Set when the line's bars or structure differ from its system's (an error): its part is tacet there. */
|
|
@@ -171,6 +187,13 @@ export type Line = {
|
|
|
171
187
|
line: number;
|
|
172
188
|
text: string;
|
|
173
189
|
}
|
|
190
|
+
/** `composer: …` and the other credit lines (grammar 7.5). */
|
|
191
|
+
| {
|
|
192
|
+
kind: "credit";
|
|
193
|
+
line: number;
|
|
194
|
+
role: CreditRole;
|
|
195
|
+
text: string;
|
|
196
|
+
}
|
|
174
197
|
/**
|
|
175
198
|
* A bar line dropped for an error, kept as written so its section still
|
|
176
199
|
* counts as written out; `written` is how many bars its pipes write.
|
|
@@ -181,6 +204,7 @@ export type Line = {
|
|
|
181
204
|
text: string;
|
|
182
205
|
written: number;
|
|
183
206
|
part?: string;
|
|
207
|
+
lineName?: string;
|
|
184
208
|
system?: number;
|
|
185
209
|
};
|
|
186
210
|
export type PlayedBar = {
|
|
@@ -222,12 +246,27 @@ export type PlayedBar = {
|
|
|
222
246
|
* `slots` and `words` are the first part's.
|
|
223
247
|
*/
|
|
224
248
|
parts?: PartBar[];
|
|
249
|
+
/** A single part's lines (grammar 7.6), as on `PartBar`: in a single-part chart or an extracted part that writes lines. */
|
|
250
|
+
lines?: LineBar[];
|
|
251
|
+
};
|
|
252
|
+
/** One part's line's share of a played bar (grammar 7.6): its name, the line it is written on, its slots and words. */
|
|
253
|
+
export type LineBar = {
|
|
254
|
+
name: string;
|
|
255
|
+
line: number;
|
|
256
|
+
slots: Slot[];
|
|
257
|
+
words?: Words[];
|
|
225
258
|
};
|
|
226
|
-
/**
|
|
259
|
+
/**
|
|
260
|
+
* One part's share of a played bar (grammar 7.4): the line it is written
|
|
261
|
+
* on, its slots and words. A part that writes lines (7.6) has `lines`, one
|
|
262
|
+
* per line playing there in score order, and its first playing line's
|
|
263
|
+
* `line`, `slots` and `words`.
|
|
264
|
+
*/
|
|
227
265
|
export type PartBar = {
|
|
228
266
|
line: number;
|
|
229
267
|
slots: Slot[];
|
|
230
268
|
words?: Words[];
|
|
269
|
+
lines?: LineBar[];
|
|
231
270
|
} | null;
|
|
232
271
|
/** An open repeat shows one pass; the number of passes is unknown. */
|
|
233
272
|
export type ChartEvent = {
|
|
@@ -255,6 +294,10 @@ export type SectionOccurrence = {
|
|
|
255
294
|
*/
|
|
256
295
|
form: number;
|
|
257
296
|
};
|
|
297
|
+
/** A declared part as the parse reports it: `lines` names its lines in score order (grammar 7.6), present only when it writes some. */
|
|
298
|
+
export type DeclaredPart = Part & {
|
|
299
|
+
lines?: string[];
|
|
300
|
+
};
|
|
258
301
|
export type ChartParse = {
|
|
259
302
|
title: string | null;
|
|
260
303
|
/**
|
|
@@ -262,9 +305,11 @@ export type ChartParse = {
|
|
|
262
305
|
* none or several.
|
|
263
306
|
* @deprecated use `parts`.
|
|
264
307
|
*/
|
|
265
|
-
part:
|
|
308
|
+
part: DeclaredPart | null;
|
|
266
309
|
/** Every part the chart declares, in score order (grammar 7.4); empty when none. */
|
|
267
|
-
parts:
|
|
310
|
+
parts: DeclaredPart[];
|
|
311
|
+
/** The credit lines (grammar 7.5); each list empty when none is written. */
|
|
312
|
+
credits: Credits;
|
|
268
313
|
lines: Line[];
|
|
269
314
|
events: ChartEvent[];
|
|
270
315
|
/** `events` flattened, with an open repeat's pass included once. */
|