@ugfoundation/swaralipi-js 0.1.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/LICENSE +347 -0
- package/README.md +257 -0
- package/dist/batch-NF2Q2CFS.js +47 -0
- package/dist/batch-NF2Q2CFS.js.map +1 -0
- package/dist/chunk-C6O7DYU5.js +115 -0
- package/dist/chunk-C6O7DYU5.js.map +1 -0
- package/dist/chunk-GWXI2HJA.js +14 -0
- package/dist/chunk-GWXI2HJA.js.map +1 -0
- package/dist/chunk-N3NNWAOW.js +593 -0
- package/dist/chunk-N3NNWAOW.js.map +1 -0
- package/dist/cli.cjs +913 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +91 -0
- package/dist/cli.js.map +1 -0
- package/dist/convert/index.cjs +720 -0
- package/dist/convert/index.cjs.map +1 -0
- package/dist/convert/index.d.cts +270 -0
- package/dist/convert/index.d.ts +270 -0
- package/dist/convert/index.js +5 -0
- package/dist/convert/index.js.map +1 -0
- package/dist/index.cjs +143 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/player/index.cjs +775 -0
- package/dist/player/index.cjs.map +1 -0
- package/dist/player/index.d.cts +285 -0
- package/dist/player/index.d.ts +285 -0
- package/dist/player/index.js +743 -0
- package/dist/player/index.js.map +1 -0
- package/dist/schema-gxhG45OK.d.cts +467 -0
- package/dist/schema-gxhG45OK.d.ts +467 -0
- package/dist/spec/index.cjs +143 -0
- package/dist/spec/index.cjs.map +1 -0
- package/dist/spec/index.d.cts +70 -0
- package/dist/spec/index.d.ts +70 -0
- package/dist/spec/index.js +4 -0
- package/dist/spec/index.js.map +1 -0
- package/dist/taals-DguYW0wf.d.cts +60 -0
- package/dist/taals-DguYW0wf.d.ts +60 -0
- package/dist/viewer/index.cjs +998 -0
- package/dist/viewer/index.cjs.map +1 -0
- package/dist/viewer/index.d.cts +285 -0
- package/dist/viewer/index.d.ts +285 -0
- package/dist/viewer/index.js +814 -0
- package/dist/viewer/index.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* swaralipi-js JSON spec — Zod schema + inferred types.
|
|
5
|
+
|
|
6
|
+
/** Octave registers */
|
|
7
|
+
declare const octaveSchema: z.ZodEnum<["ati-mandra", "mandra", "madhyam", "taar", "ati-taar"]>;
|
|
8
|
+
type Octave = z.infer<typeof octaveSchema>;
|
|
9
|
+
/**
|
|
10
|
+
* The seven shuddha svara letters:
|
|
11
|
+
* `d` = ধৈবত (dha), `n` = নিষাদ (ni). Komal/tivra are flags, not letters.
|
|
12
|
+
*/
|
|
13
|
+
declare const svaraLetterSchema: z.ZodEnum<["s", "r", "g", "m", "p", "d", "n"]>;
|
|
14
|
+
type SvaraLetter = z.infer<typeof svaraLetterSchema>;
|
|
15
|
+
/** A pitch as `[octave, letter]` */
|
|
16
|
+
declare const svaraSchema: z.ZodTuple<[z.ZodEnum<["ati-mandra", "mandra", "madhyam", "taar", "ati-taar"]>, z.ZodEnum<["s", "r", "g", "m", "p", "d", "n"]>], null>;
|
|
17
|
+
type Svara = z.infer<typeof svaraSchema>;
|
|
18
|
+
/** Microtone variants below komal (legend: অল্পকোমল / অতিকোমল). */
|
|
19
|
+
declare const microtoneSchema: z.ZodEnum<["alpakomal", "atikomal"]>;
|
|
20
|
+
type Microtone = z.infer<typeof microtoneSchema>;
|
|
21
|
+
/**
|
|
22
|
+
* Barline weights. Swarabitan distinguishes the light দাঁড়ি (।) that
|
|
23
|
+
* separates vibhags *within* a taal cycle from the দণ্ড (danda, I) strokes:
|
|
24
|
+
* - `dari` — । vibhag separator inside the cycle
|
|
25
|
+
* - `single` — I end of one taal cycle (ফেরা)
|
|
26
|
+
* - `double` — II section (kali) boundary / return-to-asthayi marker
|
|
27
|
+
* - `quad` — IIII end of the song
|
|
28
|
+
*/
|
|
29
|
+
declare const barSchema: z.ZodEnum<["dari", "single", "double", "quad"]>;
|
|
30
|
+
type Bar = z.infer<typeof barSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* A repeat-bracket edge. Brackets span a range of notes; the opening note
|
|
33
|
+
* carries `{ ..., edge: 'open' }` and the closing note `{ ..., edge: 'close' }`.
|
|
34
|
+
* kind: `repeat` = {} গুন্ডবন্ধনী, `skip` = () বক্রবন্ধনী (omit on repeat),
|
|
35
|
+
* `alt` = [] সরল বন্ধনী (changed notes on repeat).
|
|
36
|
+
*/
|
|
37
|
+
declare const bracketSchema: z.ZodObject<{
|
|
38
|
+
kind: z.ZodEnum<["repeat", "skip", "alt"]>;
|
|
39
|
+
edge: z.ZodEnum<["open", "close"]>;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
kind: "repeat" | "skip" | "alt";
|
|
42
|
+
edge: "open" | "close";
|
|
43
|
+
}, {
|
|
44
|
+
kind: "repeat" | "skip" | "alt";
|
|
45
|
+
edge: "open" | "close";
|
|
46
|
+
}>;
|
|
47
|
+
type Bracket = z.infer<typeof bracketSchema>;
|
|
48
|
+
/**
|
|
49
|
+
* A single token in a row. A token is one of: a pitched note (`svara`),
|
|
50
|
+
* a rest (`rest`), an আ-কার sustain (`sustain`), a barline (`bar`), or a
|
|
51
|
+
* purely raw/undecoded cell (`raw`) — possibly carrying annotations
|
|
52
|
+
* (`above`/`below`) or a lyric syllable on an otherwise empty column.
|
|
53
|
+
* The `.refine` enforces that a note carries at least one of these so
|
|
54
|
+
* truly empty tokens can't slip through.
|
|
55
|
+
*
|
|
56
|
+
* `above`/`below` make `Note` recursive, so the type is hand-written and
|
|
57
|
+
* the schema is typed `z.ZodType<Note>` via `z.lazy` (all fields are
|
|
58
|
+
* optional, hence input ≡ output and the annotation is sound).
|
|
59
|
+
*/
|
|
60
|
+
interface Note {
|
|
61
|
+
/** Pitch. Omitted for rests, sustains, and barlines. */
|
|
62
|
+
svara?: Svara;
|
|
63
|
+
/** কোমল (flat). */
|
|
64
|
+
komal?: boolean;
|
|
65
|
+
/** তীব্র / কড়ি (sharp — applies to ma). */
|
|
66
|
+
tivra?: boolean;
|
|
67
|
+
/** Sub-komal microtone (legend: অল্পকোমল / অতিকোমল). */
|
|
68
|
+
microtone?: Microtone;
|
|
69
|
+
/** Duration in মাত্রা (beats): 1 (default), 0.5, 0.25, 2, … */
|
|
70
|
+
durationMatra?: number;
|
|
71
|
+
/**
|
|
72
|
+
* আ-কার: no new syllable attack. Alone (no `svara`) it holds the previous
|
|
73
|
+
* note's pitch and vowel; combined with `svara` it is a melisma — the
|
|
74
|
+
* pitch moves while the previous syllable's vowel continues (Swarabitan
|
|
75
|
+
* writes these with a leading hyphen, e.g. `-sfa`).
|
|
76
|
+
*/
|
|
77
|
+
sustain?: boolean;
|
|
78
|
+
/** বিরাম: a rest of `durationMatra` beats. */
|
|
79
|
+
rest?: boolean;
|
|
80
|
+
/** কণ স্বর: a grace note attached before this note. */
|
|
81
|
+
kan?: Svara;
|
|
82
|
+
/** মীড় (glide/slur) endpoint. */
|
|
83
|
+
meend?: 'start' | 'end';
|
|
84
|
+
/** Barline. A bar token usually has no `svara`. */
|
|
85
|
+
bar?: Bar;
|
|
86
|
+
/** Repeat-bracket edges opening/closing on this token. */
|
|
87
|
+
brackets?: Bracket[];
|
|
88
|
+
/** Lyric syllable aligned under this note */
|
|
89
|
+
lyric?: string;
|
|
90
|
+
/** Lossless passthrough of the source cell (e.g. raw Swarabitan code). */
|
|
91
|
+
raw?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Annotation notes rendered above this column: alt-on-repeat passages
|
|
94
|
+
* (legend: পরিবর্তিত স্বর in [ ] শিরোদেশে), stop marks, beat numbers.
|
|
95
|
+
*/
|
|
96
|
+
above?: Note[];
|
|
97
|
+
/** Annotation notes rendered below this column. */
|
|
98
|
+
below?: Note[];
|
|
99
|
+
}
|
|
100
|
+
declare const noteSchema: z.ZodType<Note>;
|
|
101
|
+
/** A written line of the song: a sequence of note tokens. */
|
|
102
|
+
declare const rowSchema: z.ZodObject<{
|
|
103
|
+
/** Optional line label (e.g. a tuk/section marker). */
|
|
104
|
+
label: z.ZodOptional<z.ZodString>;
|
|
105
|
+
notes: z.ZodArray<z.ZodType<Note, z.ZodTypeDef, Note>, "many">;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
notes: Note[];
|
|
108
|
+
label?: string | undefined;
|
|
109
|
+
}, {
|
|
110
|
+
notes: Note[];
|
|
111
|
+
label?: string | undefined;
|
|
112
|
+
}>;
|
|
113
|
+
type Row = z.infer<typeof rowSchema>;
|
|
114
|
+
/** A structural section: আস্থায়ী / অন্তরা / সঞ্চারী / আভোগ, or free text. */
|
|
115
|
+
declare const partSchema: z.ZodObject<{
|
|
116
|
+
name: z.ZodOptional<z.ZodString>;
|
|
117
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
118
|
+
/** Optional line label (e.g. a tuk/section marker). */
|
|
119
|
+
label: z.ZodOptional<z.ZodString>;
|
|
120
|
+
notes: z.ZodArray<z.ZodType<Note, z.ZodTypeDef, Note>, "many">;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
notes: Note[];
|
|
123
|
+
label?: string | undefined;
|
|
124
|
+
}, {
|
|
125
|
+
notes: Note[];
|
|
126
|
+
label?: string | undefined;
|
|
127
|
+
}>, "many">;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
rows: {
|
|
130
|
+
notes: Note[];
|
|
131
|
+
label?: string | undefined;
|
|
132
|
+
}[];
|
|
133
|
+
name?: string | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
rows: {
|
|
136
|
+
notes: Note[];
|
|
137
|
+
label?: string | undefined;
|
|
138
|
+
}[];
|
|
139
|
+
name?: string | undefined;
|
|
140
|
+
}>;
|
|
141
|
+
type Part = z.infer<typeof partSchema>;
|
|
142
|
+
/**
|
|
143
|
+
* Taal definition. `numBeats` is the cycle length in মাত্রা; `bhaags` (if
|
|
144
|
+
* present) must sum to `numBeats`; `sam`/`khaali` are 0-based beat indices.
|
|
145
|
+
*/
|
|
146
|
+
declare const taalSchema: z.ZodEffects<z.ZodObject<{
|
|
147
|
+
/** Player sample key, e.g. `dadra`, `teentaal`. */
|
|
148
|
+
id: z.ZodString;
|
|
149
|
+
numBeats: z.ZodNumber;
|
|
150
|
+
/** Vibhag groupings; if given, they sum to numBeats. */
|
|
151
|
+
bhaags: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
152
|
+
/** Sam (cycle start) beat index, 0-based. */
|
|
153
|
+
sam: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
/** Khaali (wave) beat indices, 0-based. */
|
|
155
|
+
khaali: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
156
|
+
}, "strip", z.ZodTypeAny, {
|
|
157
|
+
id: string;
|
|
158
|
+
numBeats: number;
|
|
159
|
+
bhaags?: number[] | undefined;
|
|
160
|
+
sam?: number | undefined;
|
|
161
|
+
khaali?: number[] | undefined;
|
|
162
|
+
}, {
|
|
163
|
+
id: string;
|
|
164
|
+
numBeats: number;
|
|
165
|
+
bhaags?: number[] | undefined;
|
|
166
|
+
sam?: number | undefined;
|
|
167
|
+
khaali?: number[] | undefined;
|
|
168
|
+
}>, {
|
|
169
|
+
id: string;
|
|
170
|
+
numBeats: number;
|
|
171
|
+
bhaags?: number[] | undefined;
|
|
172
|
+
sam?: number | undefined;
|
|
173
|
+
khaali?: number[] | undefined;
|
|
174
|
+
}, {
|
|
175
|
+
id: string;
|
|
176
|
+
numBeats: number;
|
|
177
|
+
bhaags?: number[] | undefined;
|
|
178
|
+
sam?: number | undefined;
|
|
179
|
+
khaali?: number[] | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
type Taal = z.infer<typeof taalSchema>;
|
|
182
|
+
/** Document-level metadata. */
|
|
183
|
+
declare const metaSchema: z.ZodObject<{
|
|
184
|
+
title: z.ZodString;
|
|
185
|
+
/** Cross-reference to a gitabitan.io song content id (filename, immutable). */
|
|
186
|
+
songId: z.ZodOptional<z.ZodString>;
|
|
187
|
+
/** Source NLTR node/song id. */
|
|
188
|
+
nltrId: z.ZodOptional<z.ZodNumber>;
|
|
189
|
+
taal: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
190
|
+
/** Player sample key, e.g. `dadra`, `teentaal`. */
|
|
191
|
+
id: z.ZodString;
|
|
192
|
+
numBeats: z.ZodNumber;
|
|
193
|
+
/** Vibhag groupings; if given, they sum to numBeats. */
|
|
194
|
+
bhaags: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
195
|
+
/** Sam (cycle start) beat index, 0-based. */
|
|
196
|
+
sam: z.ZodOptional<z.ZodNumber>;
|
|
197
|
+
/** Khaali (wave) beat indices, 0-based. */
|
|
198
|
+
khaali: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
199
|
+
}, "strip", z.ZodTypeAny, {
|
|
200
|
+
id: string;
|
|
201
|
+
numBeats: number;
|
|
202
|
+
bhaags?: number[] | undefined;
|
|
203
|
+
sam?: number | undefined;
|
|
204
|
+
khaali?: number[] | undefined;
|
|
205
|
+
}, {
|
|
206
|
+
id: string;
|
|
207
|
+
numBeats: number;
|
|
208
|
+
bhaags?: number[] | undefined;
|
|
209
|
+
sam?: number | undefined;
|
|
210
|
+
khaali?: number[] | undefined;
|
|
211
|
+
}>, {
|
|
212
|
+
id: string;
|
|
213
|
+
numBeats: number;
|
|
214
|
+
bhaags?: number[] | undefined;
|
|
215
|
+
sam?: number | undefined;
|
|
216
|
+
khaali?: number[] | undefined;
|
|
217
|
+
}, {
|
|
218
|
+
id: string;
|
|
219
|
+
numBeats: number;
|
|
220
|
+
bhaags?: number[] | undefined;
|
|
221
|
+
sam?: number | undefined;
|
|
222
|
+
khaali?: number[] | undefined;
|
|
223
|
+
}>>;
|
|
224
|
+
/**
|
|
225
|
+
* The taal name exactly as printed in the source (e.g. `তালমুক্ত`,
|
|
226
|
+
* `ষষ্ঠী(২/৪)`). Always set by the NLTR converter; `taal` is set only
|
|
227
|
+
* when the name resolves to a known definition.
|
|
228
|
+
*/
|
|
229
|
+
taalName: z.ZodOptional<z.ZodString>;
|
|
230
|
+
/** Base pitch for playback, e.g. `C`, `C#`, or the player's `cs` form. */
|
|
231
|
+
tonic: z.ZodOptional<z.ZodString>;
|
|
232
|
+
/** Default playback tempo in matra/min. Player-only — the viewer ignores it.
|
|
233
|
+
* The player adopts it on `load()` (precedence: constructor `bpm` → `setBpm`
|
|
234
|
+
* tweak → this → 90). `null` is the converter's blank placeholder = unset. */
|
|
235
|
+
bpm: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
236
|
+
raag: z.ZodOptional<z.ZodString>;
|
|
237
|
+
/** আবর্তন: number of taal cycles, when the source states it. */
|
|
238
|
+
avartan: z.ZodOptional<z.ZodNumber>;
|
|
239
|
+
/** স্বরলিপিকার (notation author). */
|
|
240
|
+
notationBy: z.ZodOptional<z.ZodString>;
|
|
241
|
+
/** Provenance note or URL. */
|
|
242
|
+
source: z.ZodOptional<z.ZodString>;
|
|
243
|
+
}, "strip", z.ZodTypeAny, {
|
|
244
|
+
title: string;
|
|
245
|
+
songId?: string | undefined;
|
|
246
|
+
nltrId?: number | undefined;
|
|
247
|
+
taal?: {
|
|
248
|
+
id: string;
|
|
249
|
+
numBeats: number;
|
|
250
|
+
bhaags?: number[] | undefined;
|
|
251
|
+
sam?: number | undefined;
|
|
252
|
+
khaali?: number[] | undefined;
|
|
253
|
+
} | undefined;
|
|
254
|
+
taalName?: string | undefined;
|
|
255
|
+
tonic?: string | undefined;
|
|
256
|
+
bpm?: number | null | undefined;
|
|
257
|
+
raag?: string | undefined;
|
|
258
|
+
avartan?: number | undefined;
|
|
259
|
+
notationBy?: string | undefined;
|
|
260
|
+
source?: string | undefined;
|
|
261
|
+
}, {
|
|
262
|
+
title: string;
|
|
263
|
+
songId?: string | undefined;
|
|
264
|
+
nltrId?: number | undefined;
|
|
265
|
+
taal?: {
|
|
266
|
+
id: string;
|
|
267
|
+
numBeats: number;
|
|
268
|
+
bhaags?: number[] | undefined;
|
|
269
|
+
sam?: number | undefined;
|
|
270
|
+
khaali?: number[] | undefined;
|
|
271
|
+
} | undefined;
|
|
272
|
+
taalName?: string | undefined;
|
|
273
|
+
tonic?: string | undefined;
|
|
274
|
+
bpm?: number | null | undefined;
|
|
275
|
+
raag?: string | undefined;
|
|
276
|
+
avartan?: number | undefined;
|
|
277
|
+
notationBy?: string | undefined;
|
|
278
|
+
source?: string | undefined;
|
|
279
|
+
}>;
|
|
280
|
+
type Meta = z.infer<typeof metaSchema>;
|
|
281
|
+
/** A complete swaralipi document. */
|
|
282
|
+
declare const swaralipiSchema: z.ZodObject<{
|
|
283
|
+
/** Spec version this document targets (see SPEC_VERSION in ./index). */
|
|
284
|
+
version: z.ZodString;
|
|
285
|
+
meta: z.ZodObject<{
|
|
286
|
+
title: z.ZodString;
|
|
287
|
+
/** Cross-reference to a gitabitan.io song content id (filename, immutable). */
|
|
288
|
+
songId: z.ZodOptional<z.ZodString>;
|
|
289
|
+
/** Source NLTR node/song id. */
|
|
290
|
+
nltrId: z.ZodOptional<z.ZodNumber>;
|
|
291
|
+
taal: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
292
|
+
/** Player sample key, e.g. `dadra`, `teentaal`. */
|
|
293
|
+
id: z.ZodString;
|
|
294
|
+
numBeats: z.ZodNumber;
|
|
295
|
+
/** Vibhag groupings; if given, they sum to numBeats. */
|
|
296
|
+
bhaags: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
297
|
+
/** Sam (cycle start) beat index, 0-based. */
|
|
298
|
+
sam: z.ZodOptional<z.ZodNumber>;
|
|
299
|
+
/** Khaali (wave) beat indices, 0-based. */
|
|
300
|
+
khaali: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
301
|
+
}, "strip", z.ZodTypeAny, {
|
|
302
|
+
id: string;
|
|
303
|
+
numBeats: number;
|
|
304
|
+
bhaags?: number[] | undefined;
|
|
305
|
+
sam?: number | undefined;
|
|
306
|
+
khaali?: number[] | undefined;
|
|
307
|
+
}, {
|
|
308
|
+
id: string;
|
|
309
|
+
numBeats: number;
|
|
310
|
+
bhaags?: number[] | undefined;
|
|
311
|
+
sam?: number | undefined;
|
|
312
|
+
khaali?: number[] | undefined;
|
|
313
|
+
}>, {
|
|
314
|
+
id: string;
|
|
315
|
+
numBeats: number;
|
|
316
|
+
bhaags?: number[] | undefined;
|
|
317
|
+
sam?: number | undefined;
|
|
318
|
+
khaali?: number[] | undefined;
|
|
319
|
+
}, {
|
|
320
|
+
id: string;
|
|
321
|
+
numBeats: number;
|
|
322
|
+
bhaags?: number[] | undefined;
|
|
323
|
+
sam?: number | undefined;
|
|
324
|
+
khaali?: number[] | undefined;
|
|
325
|
+
}>>;
|
|
326
|
+
/**
|
|
327
|
+
* The taal name exactly as printed in the source (e.g. `তালমুক্ত`,
|
|
328
|
+
* `ষষ্ঠী(২/৪)`). Always set by the NLTR converter; `taal` is set only
|
|
329
|
+
* when the name resolves to a known definition.
|
|
330
|
+
*/
|
|
331
|
+
taalName: z.ZodOptional<z.ZodString>;
|
|
332
|
+
/** Base pitch for playback, e.g. `C`, `C#`, or the player's `cs` form. */
|
|
333
|
+
tonic: z.ZodOptional<z.ZodString>;
|
|
334
|
+
/** Default playback tempo in matra/min. Player-only — the viewer ignores it.
|
|
335
|
+
* The player adopts it on `load()` (precedence: constructor `bpm` → `setBpm`
|
|
336
|
+
* tweak → this → 90). `null` is the converter's blank placeholder = unset. */
|
|
337
|
+
bpm: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
338
|
+
raag: z.ZodOptional<z.ZodString>;
|
|
339
|
+
/** আবর্তন: number of taal cycles, when the source states it. */
|
|
340
|
+
avartan: z.ZodOptional<z.ZodNumber>;
|
|
341
|
+
/** স্বরলিপিকার (notation author). */
|
|
342
|
+
notationBy: z.ZodOptional<z.ZodString>;
|
|
343
|
+
/** Provenance note or URL. */
|
|
344
|
+
source: z.ZodOptional<z.ZodString>;
|
|
345
|
+
}, "strip", z.ZodTypeAny, {
|
|
346
|
+
title: string;
|
|
347
|
+
songId?: string | undefined;
|
|
348
|
+
nltrId?: number | undefined;
|
|
349
|
+
taal?: {
|
|
350
|
+
id: string;
|
|
351
|
+
numBeats: number;
|
|
352
|
+
bhaags?: number[] | undefined;
|
|
353
|
+
sam?: number | undefined;
|
|
354
|
+
khaali?: number[] | undefined;
|
|
355
|
+
} | undefined;
|
|
356
|
+
taalName?: string | undefined;
|
|
357
|
+
tonic?: string | undefined;
|
|
358
|
+
bpm?: number | null | undefined;
|
|
359
|
+
raag?: string | undefined;
|
|
360
|
+
avartan?: number | undefined;
|
|
361
|
+
notationBy?: string | undefined;
|
|
362
|
+
source?: string | undefined;
|
|
363
|
+
}, {
|
|
364
|
+
title: string;
|
|
365
|
+
songId?: string | undefined;
|
|
366
|
+
nltrId?: number | undefined;
|
|
367
|
+
taal?: {
|
|
368
|
+
id: string;
|
|
369
|
+
numBeats: number;
|
|
370
|
+
bhaags?: number[] | undefined;
|
|
371
|
+
sam?: number | undefined;
|
|
372
|
+
khaali?: number[] | undefined;
|
|
373
|
+
} | undefined;
|
|
374
|
+
taalName?: string | undefined;
|
|
375
|
+
tonic?: string | undefined;
|
|
376
|
+
bpm?: number | null | undefined;
|
|
377
|
+
raag?: string | undefined;
|
|
378
|
+
avartan?: number | undefined;
|
|
379
|
+
notationBy?: string | undefined;
|
|
380
|
+
source?: string | undefined;
|
|
381
|
+
}>;
|
|
382
|
+
parts: z.ZodArray<z.ZodObject<{
|
|
383
|
+
name: z.ZodOptional<z.ZodString>;
|
|
384
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
385
|
+
/** Optional line label (e.g. a tuk/section marker). */
|
|
386
|
+
label: z.ZodOptional<z.ZodString>;
|
|
387
|
+
notes: z.ZodArray<z.ZodType<Note, z.ZodTypeDef, Note>, "many">;
|
|
388
|
+
}, "strip", z.ZodTypeAny, {
|
|
389
|
+
notes: Note[];
|
|
390
|
+
label?: string | undefined;
|
|
391
|
+
}, {
|
|
392
|
+
notes: Note[];
|
|
393
|
+
label?: string | undefined;
|
|
394
|
+
}>, "many">;
|
|
395
|
+
}, "strip", z.ZodTypeAny, {
|
|
396
|
+
rows: {
|
|
397
|
+
notes: Note[];
|
|
398
|
+
label?: string | undefined;
|
|
399
|
+
}[];
|
|
400
|
+
name?: string | undefined;
|
|
401
|
+
}, {
|
|
402
|
+
rows: {
|
|
403
|
+
notes: Note[];
|
|
404
|
+
label?: string | undefined;
|
|
405
|
+
}[];
|
|
406
|
+
name?: string | undefined;
|
|
407
|
+
}>, "many">;
|
|
408
|
+
}, "strip", z.ZodTypeAny, {
|
|
409
|
+
version: string;
|
|
410
|
+
meta: {
|
|
411
|
+
title: string;
|
|
412
|
+
songId?: string | undefined;
|
|
413
|
+
nltrId?: number | undefined;
|
|
414
|
+
taal?: {
|
|
415
|
+
id: string;
|
|
416
|
+
numBeats: number;
|
|
417
|
+
bhaags?: number[] | undefined;
|
|
418
|
+
sam?: number | undefined;
|
|
419
|
+
khaali?: number[] | undefined;
|
|
420
|
+
} | undefined;
|
|
421
|
+
taalName?: string | undefined;
|
|
422
|
+
tonic?: string | undefined;
|
|
423
|
+
bpm?: number | null | undefined;
|
|
424
|
+
raag?: string | undefined;
|
|
425
|
+
avartan?: number | undefined;
|
|
426
|
+
notationBy?: string | undefined;
|
|
427
|
+
source?: string | undefined;
|
|
428
|
+
};
|
|
429
|
+
parts: {
|
|
430
|
+
rows: {
|
|
431
|
+
notes: Note[];
|
|
432
|
+
label?: string | undefined;
|
|
433
|
+
}[];
|
|
434
|
+
name?: string | undefined;
|
|
435
|
+
}[];
|
|
436
|
+
}, {
|
|
437
|
+
version: string;
|
|
438
|
+
meta: {
|
|
439
|
+
title: string;
|
|
440
|
+
songId?: string | undefined;
|
|
441
|
+
nltrId?: number | undefined;
|
|
442
|
+
taal?: {
|
|
443
|
+
id: string;
|
|
444
|
+
numBeats: number;
|
|
445
|
+
bhaags?: number[] | undefined;
|
|
446
|
+
sam?: number | undefined;
|
|
447
|
+
khaali?: number[] | undefined;
|
|
448
|
+
} | undefined;
|
|
449
|
+
taalName?: string | undefined;
|
|
450
|
+
tonic?: string | undefined;
|
|
451
|
+
bpm?: number | null | undefined;
|
|
452
|
+
raag?: string | undefined;
|
|
453
|
+
avartan?: number | undefined;
|
|
454
|
+
notationBy?: string | undefined;
|
|
455
|
+
source?: string | undefined;
|
|
456
|
+
};
|
|
457
|
+
parts: {
|
|
458
|
+
rows: {
|
|
459
|
+
notes: Note[];
|
|
460
|
+
label?: string | undefined;
|
|
461
|
+
}[];
|
|
462
|
+
name?: string | undefined;
|
|
463
|
+
}[];
|
|
464
|
+
}>;
|
|
465
|
+
type Swaralipi = z.infer<typeof swaralipiSchema>;
|
|
466
|
+
|
|
467
|
+
export { type Bar as B, type Meta as M, type Note as N, type Octave as O, type Part as P, type Row as R, type Swaralipi as S, type Taal as T, type SvaraLetter as a, type Bracket as b, type Microtone as c, type Svara as d, barSchema as e, bracketSchema as f, microtoneSchema as g, svaraSchema as h, swaralipiSchema as i, metaSchema as m, noteSchema as n, octaveSchema as o, partSchema as p, rowSchema as r, svaraLetterSchema as s, taalSchema as t };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/spec/schema.ts
|
|
6
|
+
var octaveSchema = zod.z.enum([
|
|
7
|
+
"ati-mandra",
|
|
8
|
+
// very low
|
|
9
|
+
"mandra",
|
|
10
|
+
// low (dot below)
|
|
11
|
+
"madhyam",
|
|
12
|
+
// middle
|
|
13
|
+
"taar",
|
|
14
|
+
// high (ref/dot above)
|
|
15
|
+
"ati-taar"
|
|
16
|
+
// very high
|
|
17
|
+
]);
|
|
18
|
+
var svaraLetterSchema = zod.z.enum(["s", "r", "g", "m", "p", "d", "n"]);
|
|
19
|
+
var svaraSchema = zod.z.tuple([octaveSchema, svaraLetterSchema]);
|
|
20
|
+
var microtoneSchema = zod.z.enum(["alpakomal", "atikomal"]);
|
|
21
|
+
var barSchema = zod.z.enum(["dari", "single", "double", "quad"]);
|
|
22
|
+
var bracketSchema = zod.z.object({
|
|
23
|
+
kind: zod.z.enum(["repeat", "skip", "alt"]),
|
|
24
|
+
edge: zod.z.enum(["open", "close"])
|
|
25
|
+
});
|
|
26
|
+
var noteSchema = zod.z.lazy(
|
|
27
|
+
() => zod.z.object({
|
|
28
|
+
svara: svaraSchema.optional(),
|
|
29
|
+
komal: zod.z.boolean().optional(),
|
|
30
|
+
tivra: zod.z.boolean().optional(),
|
|
31
|
+
microtone: microtoneSchema.optional(),
|
|
32
|
+
durationMatra: zod.z.number().positive().optional(),
|
|
33
|
+
sustain: zod.z.boolean().optional(),
|
|
34
|
+
rest: zod.z.boolean().optional(),
|
|
35
|
+
kan: svaraSchema.optional(),
|
|
36
|
+
meend: zod.z.enum(["start", "end"]).optional(),
|
|
37
|
+
bar: barSchema.optional(),
|
|
38
|
+
brackets: zod.z.array(bracketSchema).optional(),
|
|
39
|
+
lyric: zod.z.string().optional(),
|
|
40
|
+
raw: zod.z.string().optional(),
|
|
41
|
+
above: zod.z.array(noteSchema).optional(),
|
|
42
|
+
below: zod.z.array(noteSchema).optional()
|
|
43
|
+
}).refine(
|
|
44
|
+
(n) => n.svara !== void 0 || n.rest === true || n.sustain === true || n.bar !== void 0 || n.raw !== void 0 || n.brackets !== void 0 && n.brackets.length > 0 || n.above !== void 0 && n.above.length > 0 || n.below !== void 0 && n.below.length > 0 || n.lyric !== void 0,
|
|
45
|
+
{
|
|
46
|
+
message: "note must carry one of: svara, rest, sustain, bar, raw, lyric, brackets, or a non-empty above/below"
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
var rowSchema = zod.z.object({
|
|
51
|
+
/** Optional line label (e.g. a tuk/section marker). */
|
|
52
|
+
label: zod.z.string().optional(),
|
|
53
|
+
notes: zod.z.array(noteSchema)
|
|
54
|
+
});
|
|
55
|
+
var partSchema = zod.z.object({
|
|
56
|
+
name: zod.z.string().optional(),
|
|
57
|
+
rows: zod.z.array(rowSchema)
|
|
58
|
+
});
|
|
59
|
+
var taalSchema = zod.z.object({
|
|
60
|
+
/** Player sample key, e.g. `dadra`, `teentaal`. */
|
|
61
|
+
id: zod.z.string(),
|
|
62
|
+
numBeats: zod.z.number().int().positive(),
|
|
63
|
+
/** Vibhag groupings; if given, they sum to numBeats. */
|
|
64
|
+
bhaags: zod.z.array(zod.z.number().int().positive()).optional(),
|
|
65
|
+
/** Sam (cycle start) beat index, 0-based. */
|
|
66
|
+
sam: zod.z.number().int().nonnegative().optional(),
|
|
67
|
+
/** Khaali (wave) beat indices, 0-based. */
|
|
68
|
+
khaali: zod.z.array(zod.z.number().int().nonnegative()).optional()
|
|
69
|
+
}).refine((t) => t.bhaags === void 0 || t.bhaags.reduce((a, b) => a + b, 0) === t.numBeats, {
|
|
70
|
+
message: "bhaags must sum to numBeats"
|
|
71
|
+
});
|
|
72
|
+
var metaSchema = zod.z.object({
|
|
73
|
+
title: zod.z.string(),
|
|
74
|
+
/** Cross-reference to a gitabitan.io song content id (filename, immutable). */
|
|
75
|
+
songId: zod.z.string().optional(),
|
|
76
|
+
/** Source NLTR node/song id. */
|
|
77
|
+
nltrId: zod.z.number().int().optional(),
|
|
78
|
+
taal: taalSchema.optional(),
|
|
79
|
+
/**
|
|
80
|
+
* The taal name exactly as printed in the source (e.g. `তালমুক্ত`,
|
|
81
|
+
* `ষষ্ঠী(২/৪)`). Always set by the NLTR converter; `taal` is set only
|
|
82
|
+
* when the name resolves to a known definition.
|
|
83
|
+
*/
|
|
84
|
+
taalName: zod.z.string().optional(),
|
|
85
|
+
/** Base pitch for playback, e.g. `C`, `C#`, or the player's `cs` form. */
|
|
86
|
+
tonic: zod.z.string().optional(),
|
|
87
|
+
/** Default playback tempo in matra/min. Player-only — the viewer ignores it.
|
|
88
|
+
* The player adopts it on `load()` (precedence: constructor `bpm` → `setBpm`
|
|
89
|
+
* tweak → this → 90). `null` is the converter's blank placeholder = unset. */
|
|
90
|
+
bpm: zod.z.number().positive().nullable().optional(),
|
|
91
|
+
raag: zod.z.string().optional(),
|
|
92
|
+
/** আবর্তন: number of taal cycles, when the source states it. */
|
|
93
|
+
avartan: zod.z.number().int().positive().optional(),
|
|
94
|
+
/** স্বরলিপিকার (notation author). */
|
|
95
|
+
notationBy: zod.z.string().optional(),
|
|
96
|
+
/** Provenance note or URL. */
|
|
97
|
+
source: zod.z.string().optional()
|
|
98
|
+
});
|
|
99
|
+
var swaralipiSchema = zod.z.object({
|
|
100
|
+
/** Spec version this document targets (see SPEC_VERSION in ./index). */
|
|
101
|
+
version: zod.z.string(),
|
|
102
|
+
meta: metaSchema,
|
|
103
|
+
parts: zod.z.array(partSchema)
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// src/spec/taals.ts
|
|
107
|
+
var TAALS = {
|
|
108
|
+
dadra: { id: "dadra", numBeats: 6, bhaags: [3, 3], sam: 0, khaali: [3] },
|
|
109
|
+
kehrwa: { id: "kehrwa", numBeats: 8, bhaags: [4, 4], sam: 0, khaali: [4] },
|
|
110
|
+
rupak: { id: "rupak", numBeats: 7, bhaags: [3, 2, 2], sam: 0, khaali: [0] },
|
|
111
|
+
jhaptaal: { id: "jhaptaal", numBeats: 10, bhaags: [2, 3, 2, 3], sam: 0, khaali: [5] },
|
|
112
|
+
ektaal: { id: "ektaal", numBeats: 12, bhaags: [2, 2, 2, 2, 2, 2], sam: 0, khaali: [2, 6] },
|
|
113
|
+
adachautaal: { id: "adachautaal", numBeats: 14, sam: 0 },
|
|
114
|
+
teentaal: { id: "teentaal", numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] }
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/spec/index.ts
|
|
118
|
+
var SPEC_VERSION = "0.1.0";
|
|
119
|
+
function parseSwaralipi(data) {
|
|
120
|
+
return swaralipiSchema.parse(data);
|
|
121
|
+
}
|
|
122
|
+
function safeParseSwaralipi(data) {
|
|
123
|
+
return swaralipiSchema.safeParse(data);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
exports.SPEC_VERSION = SPEC_VERSION;
|
|
127
|
+
exports.TAALS = TAALS;
|
|
128
|
+
exports.barSchema = barSchema;
|
|
129
|
+
exports.bracketSchema = bracketSchema;
|
|
130
|
+
exports.metaSchema = metaSchema;
|
|
131
|
+
exports.microtoneSchema = microtoneSchema;
|
|
132
|
+
exports.noteSchema = noteSchema;
|
|
133
|
+
exports.octaveSchema = octaveSchema;
|
|
134
|
+
exports.parseSwaralipi = parseSwaralipi;
|
|
135
|
+
exports.partSchema = partSchema;
|
|
136
|
+
exports.rowSchema = rowSchema;
|
|
137
|
+
exports.safeParseSwaralipi = safeParseSwaralipi;
|
|
138
|
+
exports.svaraLetterSchema = svaraLetterSchema;
|
|
139
|
+
exports.svaraSchema = svaraSchema;
|
|
140
|
+
exports.swaralipiSchema = swaralipiSchema;
|
|
141
|
+
exports.taalSchema = taalSchema;
|
|
142
|
+
//# sourceMappingURL=index.cjs.map
|
|
143
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/spec/schema.ts","../../src/spec/taals.ts","../../src/spec/index.ts"],"names":["z"],"mappings":";;;;;AAMO,IAAM,YAAA,GAAeA,MAAE,IAAA,CAAK;AAAA,EACjC,YAAA;AAAA;AAAA,EACA,QAAA;AAAA;AAAA,EACA,SAAA;AAAA;AAAA,EACA,MAAA;AAAA;AAAA,EACA;AAAA;AACF,CAAC;AAOM,IAAM,iBAAA,GAAoBA,KAAA,CAAE,IAAA,CAAK,CAAC,GAAA,EAAK,GAAA,EAAK,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G,CAAA,EAAG,CAAC,CAAA,EAAG,GAAA,EAAK,GAAG,MAAA,EAAQ,CAAC,CAAC,CAAA,EAAE;AAAA,EACpF,MAAA,EAAQ,EAAE,EAAA,EAAI,QAAA,EAAU,UAAU,EAAA,EAAI,MAAA,EAAQ,CAAC,CAAA,EAAG,CAAA,EAAG,GAAG,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,GAAA,EAAK,GAAG,MAAA,EAAQ,CAAC,CAAA,EAAG,CAAC,CAAA,EAAE;AAAA,EACzF,aAAa,EAAE,EAAA,EAAI,eAAe,QAAA,EAAU,EAAA,EAAI,KAAK,CAAA,EAAE;AAAA,EACvD,UAAU,EAAE,EAAA,EAAI,YAAY,QAAA,EAAU,EAAA,EAAI,QAAQ,CAAC,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,GAAA,EAAK,GAAG,MAAA,EAAQ,CAAC,CAAC,CAAA;AACpF;;;ACVO,IAAM,YAAA,GAAe;AAmCrB,SAAS,eAAe,IAAA,EAA0B;AACvD,EAAA,OAAO,eAAA,CAAgB,MAAM,IAAI,CAAA;AACnC;AAGO,SAAS,mBAAmB,IAAA,EAAe;AAChD,EAAA,OAAO,eAAA,CAAgB,UAAU,IAAI,CAAA;AACvC","file":"index.cjs","sourcesContent":["import { z } from 'zod';\n\n/**\n * swaralipi-js JSON spec — Zod schema + inferred types.\n\n/** Octave registers */\nexport const octaveSchema = z.enum([\n 'ati-mandra', // very low\n 'mandra', // low (dot below)\n 'madhyam', // middle\n 'taar', // high (ref/dot above)\n 'ati-taar', // very high\n]);\nexport type Octave = z.infer<typeof octaveSchema>;\n\n/**\n * The seven shuddha svara letters:\n * `d` = ধৈবত (dha), `n` = নিষাদ (ni). Komal/tivra are flags, not letters.\n */\nexport const svaraLetterSchema = z.enum(['s', 'r', 'g', 'm', 'p', 'd', 'n']);\nexport type SvaraLetter = z.infer<typeof svaraLetterSchema>;\n\n/** A pitch as `[octave, letter]` */\nexport const svaraSchema = z.tuple([octaveSchema, svaraLetterSchema]);\nexport type Svara = z.infer<typeof svaraSchema>;\n\n/** Microtone variants below komal (legend: অল্পকোমল / অতিকোমল). */\nexport const microtoneSchema = z.enum(['alpakomal', 'atikomal']);\nexport type Microtone = z.infer<typeof microtoneSchema>;\n\n/**\n * Barline weights. Swarabitan distinguishes the light দাঁড়ি (।) that\n * separates vibhags *within* a taal cycle from the দণ্ড (danda, I) strokes:\n * - `dari` — । vibhag separator inside the cycle\n * - `single` — I end of one taal cycle (ফেরা)\n * - `double` — II section (kali) boundary / return-to-asthayi marker\n * - `quad` — IIII end of the song\n */\nexport const barSchema = z.enum(['dari', 'single', 'double', 'quad']);\nexport type Bar = z.infer<typeof barSchema>;\n\n/**\n * A repeat-bracket edge. Brackets span a range of notes; the opening note\n * carries `{ ..., edge: 'open' }` and the closing note `{ ..., edge: 'close' }`.\n * kind: `repeat` = {} গুন্ডবন্ধনী, `skip` = () বক্রবন্ধনী (omit on repeat),\n * `alt` = [] সরল বন্ধনী (changed notes on repeat).\n */\nexport const bracketSchema = z.object({\n kind: z.enum(['repeat', 'skip', 'alt']),\n edge: z.enum(['open', 'close']),\n});\nexport type Bracket = z.infer<typeof bracketSchema>;\n\n/**\n * A single token in a row. A token is one of: a pitched note (`svara`),\n * a rest (`rest`), an আ-কার sustain (`sustain`), a barline (`bar`), or a\n * purely raw/undecoded cell (`raw`) — possibly carrying annotations\n * (`above`/`below`) or a lyric syllable on an otherwise empty column.\n * The `.refine` enforces that a note carries at least one of these so\n * truly empty tokens can't slip through.\n *\n * `above`/`below` make `Note` recursive, so the type is hand-written and\n * the schema is typed `z.ZodType<Note>` via `z.lazy` (all fields are\n * optional, hence input ≡ output and the annotation is sound).\n */\nexport interface Note {\n /** Pitch. Omitted for rests, sustains, and barlines. */\n svara?: Svara;\n /** কোমল (flat). */\n komal?: boolean;\n /** তীব্র / কড়ি (sharp — applies to ma). */\n tivra?: boolean;\n /** Sub-komal microtone (legend: অল্পকোমল / অতিকোমল). */\n microtone?: Microtone;\n /** Duration in মাত্রা (beats): 1 (default), 0.5, 0.25, 2, … */\n durationMatra?: number;\n /**\n * আ-কার: no new syllable attack. Alone (no `svara`) it holds the previous\n * note's pitch and vowel; combined with `svara` it is a melisma — the\n * pitch moves while the previous syllable's vowel continues (Swarabitan\n * writes these with a leading hyphen, e.g. `-sfa`).\n */\n sustain?: boolean;\n /** বিরাম: a rest of `durationMatra` beats. */\n rest?: boolean;\n /** কণ স্বর: a grace note attached before this note. */\n kan?: Svara;\n /** মীড় (glide/slur) endpoint. */\n meend?: 'start' | 'end';\n /** Barline. A bar token usually has no `svara`. */\n bar?: Bar;\n /** Repeat-bracket edges opening/closing on this token. */\n brackets?: Bracket[];\n /** Lyric syllable aligned under this note */\n lyric?: string;\n /** Lossless passthrough of the source cell (e.g. raw Swarabitan code). */\n raw?: string;\n /**\n * Annotation notes rendered above this column: alt-on-repeat passages\n * (legend: পরিবর্তিত স্বর in [ ] শিরোদেশে), stop marks, beat numbers.\n */\n above?: Note[];\n /** Annotation notes rendered below this column. */\n below?: Note[];\n}\n\nexport const noteSchema: z.ZodType<Note> = z.lazy(() =>\n z\n .object({\n svara: svaraSchema.optional(),\n komal: z.boolean().optional(),\n tivra: z.boolean().optional(),\n microtone: microtoneSchema.optional(),\n durationMatra: z.number().positive().optional(),\n sustain: z.boolean().optional(),\n rest: z.boolean().optional(),\n kan: svaraSchema.optional(),\n meend: z.enum(['start', 'end']).optional(),\n bar: barSchema.optional(),\n brackets: z.array(bracketSchema).optional(),\n lyric: z.string().optional(),\n raw: z.string().optional(),\n above: z.array(noteSchema).optional(),\n below: z.array(noteSchema).optional(),\n })\n .refine(\n (n) =>\n n.svara !== undefined ||\n n.rest === true ||\n n.sustain === true ||\n n.bar !== undefined ||\n n.raw !== undefined ||\n (n.brackets !== undefined && n.brackets.length > 0) ||\n (n.above !== undefined && n.above.length > 0) ||\n (n.below !== undefined && n.below.length > 0) ||\n n.lyric !== undefined,\n {\n message:\n 'note must carry one of: svara, rest, sustain, bar, raw, lyric, brackets, or a non-empty above/below',\n },\n ),\n);\n\n/** A written line of the song: a sequence of note tokens. */\nexport const rowSchema = z.object({\n /** Optional line label (e.g. a tuk/section marker). */\n label: z.string().optional(),\n notes: z.array(noteSchema),\n});\nexport type Row = z.infer<typeof rowSchema>;\n\n/** A structural section: আস্থায়ী / অন্তরা / সঞ্চারী / আভোগ, or free text. */\nexport const partSchema = z.object({\n name: z.string().optional(),\n rows: z.array(rowSchema),\n});\nexport type Part = z.infer<typeof partSchema>;\n\n/**\n * Taal definition. `numBeats` is the cycle length in মাত্রা; `bhaags` (if\n * present) must sum to `numBeats`; `sam`/`khaali` are 0-based beat indices.\n */\nexport const taalSchema = z\n .object({\n /** Player sample key, e.g. `dadra`, `teentaal`. */\n id: z.string(),\n numBeats: z.number().int().positive(),\n /** Vibhag groupings; if given, they sum to numBeats. */\n bhaags: z.array(z.number().int().positive()).optional(),\n /** Sam (cycle start) beat index, 0-based. */\n sam: z.number().int().nonnegative().optional(),\n /** Khaali (wave) beat indices, 0-based. */\n khaali: z.array(z.number().int().nonnegative()).optional(),\n })\n .refine((t) => t.bhaags === undefined || t.bhaags.reduce((a, b) => a + b, 0) === t.numBeats, {\n message: 'bhaags must sum to numBeats',\n });\nexport type Taal = z.infer<typeof taalSchema>;\n\n/** Document-level metadata. */\nexport const metaSchema = z.object({\n title: z.string(),\n /** Cross-reference to a gitabitan.io song content id (filename, immutable). */\n songId: z.string().optional(),\n /** Source NLTR node/song id. */\n nltrId: z.number().int().optional(),\n taal: taalSchema.optional(),\n /**\n * The taal name exactly as printed in the source (e.g. `তালমুক্ত`,\n * `ষষ্ঠী(২/৪)`). Always set by the NLTR converter; `taal` is set only\n * when the name resolves to a known definition.\n */\n taalName: z.string().optional(),\n /** Base pitch for playback, e.g. `C`, `C#`, or the player's `cs` form. */\n tonic: z.string().optional(),\n /** Default playback tempo in matra/min. Player-only — the viewer ignores it.\n * The player adopts it on `load()` (precedence: constructor `bpm` → `setBpm`\n * tweak → this → 90). `null` is the converter's blank placeholder = unset. */\n bpm: z.number().positive().nullable().optional(),\n raag: z.string().optional(),\n /** আবর্তন: number of taal cycles, when the source states it. */\n avartan: z.number().int().positive().optional(),\n /** স্বরলিপিকার (notation author). */\n notationBy: z.string().optional(),\n /** Provenance note or URL. */\n source: z.string().optional(),\n});\nexport type Meta = z.infer<typeof metaSchema>;\n\n/** A complete swaralipi document. */\nexport const swaralipiSchema = z.object({\n /** Spec version this document targets (see SPEC_VERSION in ./index). */\n version: z.string(),\n meta: metaSchema,\n parts: z.array(partSchema),\n});\nexport type Swaralipi = z.infer<typeof swaralipiSchema>;\n","import type { Taal } from './schema.js';\n\n/**\n * Reference definitions for the taals the player will sample (P2.3):\n * adachautaal, dadra, ektaal, jhaptaal, kehrwa, rupak, teentaal.\n *\n * `numBeats` and the `bhaags` given below are standard Hindustani taal theory.\n * `bhaags` is omitted where a single canonical division isn't well-agreed\n * (adachautaal) — we assert only what's uncontested. `sam` is beat 0 for all.\n */\nexport const TAALS = {\n dadra: { id: 'dadra', numBeats: 6, bhaags: [3, 3], sam: 0, khaali: [3] },\n kehrwa: { id: 'kehrwa', numBeats: 8, bhaags: [4, 4], sam: 0, khaali: [4] },\n rupak: { id: 'rupak', numBeats: 7, bhaags: [3, 2, 2], sam: 0, khaali: [0] },\n jhaptaal: { id: 'jhaptaal', numBeats: 10, bhaags: [2, 3, 2, 3], sam: 0, khaali: [5] },\n ektaal: { id: 'ektaal', numBeats: 12, bhaags: [2, 2, 2, 2, 2, 2], sam: 0, khaali: [2, 6] },\n adachautaal: { id: 'adachautaal', numBeats: 14, sam: 0 },\n teentaal: { id: 'teentaal', numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] },\n} as const satisfies Record<string, Taal>;\n\nexport type TaalId = keyof typeof TAALS;\n","/**\n * @ugfoundation/swaralipi-js/spec\n *\n * The swaralipi JSON spec: Zod schemas, inferred TS types, and parse helpers.\n */\nimport { swaralipiSchema, type Swaralipi } from './schema.js';\n\n/** Current spec version. Documents declare the version they target. */\nexport const SPEC_VERSION = '0.1.0';\n\nexport {\n octaveSchema,\n svaraLetterSchema,\n svaraSchema,\n microtoneSchema,\n barSchema,\n bracketSchema,\n noteSchema,\n rowSchema,\n partSchema,\n taalSchema,\n metaSchema,\n swaralipiSchema,\n} from './schema.js';\n\nexport type {\n Octave,\n SvaraLetter,\n Svara,\n Microtone,\n Bar,\n Bracket,\n Note,\n Row,\n Part,\n Taal,\n Meta,\n Swaralipi,\n} from './schema.js';\n\nexport { TAALS, type TaalId } from './taals.js';\n\n/** Parse + validate unknown data into a `Swaralipi`. Throws `ZodError` on failure. */\nexport function parseSwaralipi(data: unknown): Swaralipi {\n return swaralipiSchema.parse(data);\n}\n\n/** Non-throwing variant: returns Zod's `{ success, data | error }` result. */\nexport function safeParseSwaralipi(data: unknown) {\n return swaralipiSchema.safeParse(data);\n}\n"]}
|