@ugfoundation/swaralipi-js 0.7.7 → 0.8.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/dist/{batch-6MCPHHKF.js → batch-NJMT3M5Z.js} +5 -5
- package/dist/{batch-6MCPHHKF.js.map → batch-NJMT3M5Z.js.map} +1 -1
- package/dist/{chunk-ALN4SWMS.js → chunk-4HMHTXDE.js} +15 -4
- package/dist/chunk-4HMHTXDE.js.map +1 -0
- package/dist/{chunk-QM4CXKW2.js → chunk-4HNT6OAT.js} +24 -3
- package/dist/chunk-4HNT6OAT.js.map +1 -0
- package/dist/{chunk-TKTQCUKD.js → chunk-4IVUPMRK.js} +27 -9
- package/dist/chunk-4IVUPMRK.js.map +1 -0
- package/dist/{chunk-QQC6WVLJ.js → chunk-YFVAVICF.js} +4 -4
- package/dist/{chunk-QQC6WVLJ.js.map → chunk-YFVAVICF.js.map} +1 -1
- package/dist/cli.cjs +13 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/convert/index.cjs +12 -1
- package/dist/convert/index.cjs.map +1 -1
- package/dist/convert/index.d.cts +1 -1
- package/dist/convert/index.d.ts +1 -1
- package/dist/convert/index.js +3 -3
- package/dist/index.cjs +39 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{taals-CjzBuZ35.d.ts → lay-Csa4CD46.d.cts} +38 -1
- package/dist/{taals-CjzBuZ35.d.cts → lay-Ct9ky_EE.d.ts} +38 -1
- package/dist/player/index.cjs +276 -117
- package/dist/player/index.cjs.map +1 -1
- package/dist/player/index.d.cts +22 -9
- package/dist/player/index.d.ts +22 -9
- package/dist/player/index.js +230 -114
- package/dist/player/index.js.map +1 -1
- package/dist/{schedule-BpBYGXPL.d.cts → schedule-B_UaluBi.d.cts} +27 -3
- package/dist/{schedule-Tzk01FKj.d.ts → schedule-CdILTNsk.d.ts} +27 -3
- package/dist/{schema-DqBXPGkL.d.cts → schema-DGA_bNVZ.d.cts} +97 -1
- package/dist/{schema-DqBXPGkL.d.ts → schema-DGA_bNVZ.d.ts} +97 -1
- package/dist/spec/index.cjs +39 -1
- package/dist/spec/index.cjs.map +1 -1
- package/dist/spec/index.d.cts +16 -4
- package/dist/spec/index.d.ts +16 -4
- package/dist/spec/index.js +2 -2
- package/dist/viewer/index.cjs +114 -12
- package/dist/viewer/index.cjs.map +1 -1
- package/dist/viewer/index.d.cts +10 -5
- package/dist/viewer/index.d.ts +10 -5
- package/dist/viewer/index.js +43 -7
- package/dist/viewer/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-ALN4SWMS.js.map +0 -1
- package/dist/chunk-QM4CXKW2.js.map +0 -1
- package/dist/chunk-TKTQCUKD.js.map +0 -1
package/dist/spec/index.cjs
CHANGED
|
@@ -52,9 +52,17 @@ var noteSchema = zod.z.lazy(
|
|
|
52
52
|
}
|
|
53
53
|
)
|
|
54
54
|
);
|
|
55
|
+
var laySchema = zod.z.enum(["drut", "madhya", "vilambit"]);
|
|
55
56
|
var rowSchema = zod.z.object({
|
|
56
57
|
/** Optional line label (e.g. a tuk/section marker). */
|
|
57
58
|
label: zod.z.string().optional(),
|
|
59
|
+
/**
|
|
60
|
+
* লয়: the tempo tier this row switches to, held until another row changes
|
|
61
|
+
* it (absent on every row = the whole song at `meta.bpm`, i.e. দ্রুত).
|
|
62
|
+
* Read it with `rowLay()`, which also picks up the mark NLTR *prints*
|
|
63
|
+
* ("বিলম্বিত লয়:") in already-converted documents.
|
|
64
|
+
*/
|
|
65
|
+
lay: laySchema.optional(),
|
|
58
66
|
notes: zod.z.array(noteSchema)
|
|
59
67
|
});
|
|
60
68
|
var partSchema = zod.z.object({
|
|
@@ -100,6 +108,9 @@ var metaSchema = zod.z.object({
|
|
|
100
108
|
* The player adopts it on `load()` (precedence: constructor `bpm` → `setBpm`
|
|
101
109
|
* tweak → this → 90). `null` is the converter's blank placeholder = unset. */
|
|
102
110
|
bpm: zod.z.number().positive().nullable().optional(),
|
|
111
|
+
/** Per-document override of the লয় tempo factors (fractions of `bpm`).
|
|
112
|
+
* Defaults live in `LAY_SPEEDS`; a player/export option overrides both. */
|
|
113
|
+
laySpeeds: zod.z.object({ drut: zod.z.number().positive(), madhya: zod.z.number().positive(), vilambit: zod.z.number().positive() }).partial().optional(),
|
|
103
114
|
raag: zod.z.string().optional(),
|
|
104
115
|
/** আবর্তন: number of taal cycles, when the source states it. */
|
|
105
116
|
avartan: zod.z.number().int().positive().optional(),
|
|
@@ -144,6 +155,27 @@ function graceNotes(grace) {
|
|
|
144
155
|
return typeof grace[0] === "string" ? [{ svara: grace }] : grace;
|
|
145
156
|
}
|
|
146
157
|
|
|
158
|
+
// src/spec/lay.ts
|
|
159
|
+
var LAYS = ["drut", "madhya", "vilambit"];
|
|
160
|
+
var LAY_SPEEDS = {
|
|
161
|
+
drut: 1,
|
|
162
|
+
madhya: 0.75,
|
|
163
|
+
vilambit: 0.5
|
|
164
|
+
};
|
|
165
|
+
function resolveLaySpeeds(doc, opt) {
|
|
166
|
+
return { ...LAY_SPEEDS, ...doc, ...opt };
|
|
167
|
+
}
|
|
168
|
+
var PRINTED = { \u09A6\u09CD\u09B0\u09C1\u09A4: "drut", \u09AE\u09A7\u09CD\u09AF: "madhya", \u09AC\u09BF\u09B2\u09AE\u09CD\u09AC\u09BF\u09A4: "vilambit" };
|
|
169
|
+
function printedLay(notes) {
|
|
170
|
+
const first = notes[0];
|
|
171
|
+
if (first === void 0 || first.lyric === void 0) return void 0;
|
|
172
|
+
for (const k of Object.keys(first)) if (k !== "lyric") return void 0;
|
|
173
|
+
return PRINTED[first.lyric.normalize("NFC")];
|
|
174
|
+
}
|
|
175
|
+
function rowLay(row) {
|
|
176
|
+
return row.lay ?? printedLay(row.notes);
|
|
177
|
+
}
|
|
178
|
+
|
|
147
179
|
// src/spec/svara.ts
|
|
148
180
|
function hasKomal(letter) {
|
|
149
181
|
return letter === "r" || letter === "g" || letter === "d" || letter === "n";
|
|
@@ -153,7 +185,7 @@ function hasTivra(letter) {
|
|
|
153
185
|
}
|
|
154
186
|
|
|
155
187
|
// src/spec/index.ts
|
|
156
|
-
var SPEC_VERSION = "0.
|
|
188
|
+
var SPEC_VERSION = "0.8.0";
|
|
157
189
|
function parseSwaralipi(data) {
|
|
158
190
|
return swaralipiSchema.parse(data);
|
|
159
191
|
}
|
|
@@ -161,6 +193,8 @@ function safeParseSwaralipi(data) {
|
|
|
161
193
|
return swaralipiSchema.safeParse(data);
|
|
162
194
|
}
|
|
163
195
|
|
|
196
|
+
exports.LAYS = LAYS;
|
|
197
|
+
exports.LAY_SPEEDS = LAY_SPEEDS;
|
|
164
198
|
exports.SPEC_VERSION = SPEC_VERSION;
|
|
165
199
|
exports.TAALS = TAALS;
|
|
166
200
|
exports.barSchema = barSchema;
|
|
@@ -169,12 +203,16 @@ exports.graceNotes = graceNotes;
|
|
|
169
203
|
exports.graceSchema = graceSchema;
|
|
170
204
|
exports.hasKomal = hasKomal;
|
|
171
205
|
exports.hasTivra = hasTivra;
|
|
206
|
+
exports.laySchema = laySchema;
|
|
172
207
|
exports.metaSchema = metaSchema;
|
|
173
208
|
exports.microtoneSchema = microtoneSchema;
|
|
174
209
|
exports.noteSchema = noteSchema;
|
|
175
210
|
exports.octaveSchema = octaveSchema;
|
|
176
211
|
exports.parseSwaralipi = parseSwaralipi;
|
|
177
212
|
exports.partSchema = partSchema;
|
|
213
|
+
exports.printedLay = printedLay;
|
|
214
|
+
exports.resolveLaySpeeds = resolveLaySpeeds;
|
|
215
|
+
exports.rowLay = rowLay;
|
|
178
216
|
exports.rowSchema = rowSchema;
|
|
179
217
|
exports.safeParseSwaralipi = safeParseSwaralipi;
|
|
180
218
|
exports.svaraLetterSchema = svaraLetterSchema;
|
package/dist/spec/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/spec/schema.ts","../../src/sp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EAAA,IAAI,KAAA,KAAU,MAAA,EAAW,OAAO,EAAC;AACjC,EAAA,OAAO,OAAO,KAAA,CAAM,CAAC,CAAA,KAAM,QAAA,GAAW,CAAC,EAAE,KAAA,EAAO,KAAA,EAAgB,CAAA,GAAK,KAAA;AACvE;;;ACCO,SAAS,SAAS,MAAA,EAA8B;AACrD,EAAA,OAAO,WAAW,GAAA,IAAO,MAAA,KAAW,GAAA,IAAO,MAAA,KAAW,OAAO,MAAA,KAAW,GAAA;AAC1E;AAEO,SAAS,SAAS,MAAA,EAA8B;AACrD,EAAA,OAAO,MAAA,KAAW,GAAA;AACpB;;;ACVO,IAAM,YAAA,GAAe;AAuCrB,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 কণ / রেশ payload. Historically one `Svara` tuple; real notation puts\n * *several* svaras in a grace, and each may itself be a melisma, so the\n * richer form is a list of notes — reusing `Note` brings komal/tivra/\n * microtone/sustain along for free. The tuple form stays valid, so 0.7.x\n * documents parse unchanged; read either with `graceNotes()`.\n */\nexport type Grace = Svara | Note[];\nexport const graceSchema: z.ZodType<Grace> = z.lazy(() =>\n z.union([svaraSchema, z.array(noteSchema).min(1)]),\n);\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 /** কণ স্বর: one or more grace notes attached before this note. */\n kan?: Grace;\n /**\n * রেশ: an after-touch grace — the legend's mirror of কণ, written small to\n * the *right* of the note (\"আসল স্বরের পরে … অন্য স্বরের ঈষৎ রেশ লাগে;\n * তখন সেই স্বর ক্ষুদ্র অক্ষরে দক্ষিণ পার্শ্বে লিখিত হয়, যথা— রা˰স\").\n * Swarabitan writes it as a trailing uppercase letter (`mpaM`, `raS`).\n */\n resh?: Grace;\n /** মীড় (glide/slur) endpoint. */\n meend?: 'start' | 'end';\n /**\n * অর্ধমাত্রা (ঃ): this note closes a cell whose matra unit is a *half* —\n * `সঃ` = ½ matra, `সরঃ` = two ¼s, `রাঃ` = 1½ (legend p. ১৩৫).\n * Explicit rather than derived, because durations alone cannot distinguish\n * two half-matra cells (`সঃ গঃ`) from one matra split in two (`সরা`); this\n * flag is what closes the cell and prints the ঃ.\n */\n halfMatra?: boolean;\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: graceSchema.optional(),\n resh: graceSchema.optional(),\n meend: z.enum(['start', 'end']).optional(),\n halfMatra: z.boolean().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 /**\n * Which tabla loop variation to play, e.g. `pro` (CDN dir suffix). Optional\n * and additive — omitted means the taal's default variation, so existing\n * docs are unaffected. The player honors it but never exposes a variation\n * picker; selecting a non-default variation is the consumer's premium policy.\n */\n variation: z.string().optional(),\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 as printed in the source (e.g. `ষষ্ঠী(২/৪)`), except\n * free rhythm which is normalised to `মুক্তছন্দ`. Always set by the NLTR\n * converter; `taal` is set only when the name resolves to a 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:\n * adachautaal, dadra, ektaal, jhaptaal, kehrwa, rupak, shashthi, teentaal,\n * jhampak, dhamaar.\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 *\n * Tabla loops live under `tabla/<id>/` by default; per-taal variation and\n * skip-bpm overrides (e.g. shashthi → `tabla/shashthi-pro/`) are in\n * instruments.ts's `TABLA_VARIATIONS`.\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 choutaal: { id: 'choutaal', numBeats: 12, bhaags: [2, 2, 2, 2, 2, 2], sam: 0, khaali: [2, 6] }, // চৌতাল\n shashthi: { id: 'shashthi', numBeats: 6, bhaags: [2, 4], sam: 0 }, // ষষ্ঠী\n teora: { id: 'teora', numBeats: 7, bhaags: [3, 2, 2], sam: 0 }, // টেওরা\n teentaal: { id: 'teentaal', numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] },\n aratheka: { id: 'aratheka', numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] }, // আড়াঠেকা\n jhampak: { id: 'jhampak', numBeats: 5, bhaags: [3, 2], sam: 0 }, // ঝম্পক\n dhamaar: { id: 'dhamaar', numBeats: 14, bhaags: [5, 2, 3, 4], sam: 0, khaali: [7] }, // ধামার\n} as const satisfies Record<string, Taal>;\n\nexport type TaalId = keyof typeof TAALS;\n","/**\n * কণ / রেশ readers. Zod-free on purpose: the viewer and the player import\n * this directly (the `spec/index.js` barrel would drag zod into their\n * browser bundles — see `taals.ts` for the same rule).\n */\nimport type { Grace, Note, Svara } from './schema.js';\n\n/** Normalise a grace payload to its note list; the legacy tuple is one note. */\nexport function graceNotes(grace: Grace | undefined): Note[] {\n if (grace === undefined) return [];\n return typeof grace[0] === 'string' ? [{ svara: grace as Svara }] : (grace as Note[]);\n}\n","/**\n * Which svaras admit which alteration — স and প are অচল (immovable), ম has\n * only its তীব্র (কড়ি) form, and র গ ধ ন only their কোমল form. The notation\n * fonts encode exactly this (no glyph exists for a কোমল প), so a flag the\n * sheet cannot draw must not move the pitch either.\n *\n * Zod-free on purpose: the viewer and the player import this directly (the\n * `spec/index.js` barrel would drag zod into their browser bundles — see\n * `taals.ts` and `grace.ts` for the same rule).\n */\nimport type { SvaraLetter } from './schema.js';\n\nexport function hasKomal(letter: SvaraLetter): boolean {\n return letter === 'r' || letter === 'g' || letter === 'd' || letter === 'n';\n}\n\nexport function hasTivra(letter: SvaraLetter): boolean {\n return letter === 'm';\n}\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.7.7';\n\nexport {\n octaveSchema,\n svaraLetterSchema,\n svaraSchema,\n microtoneSchema,\n barSchema,\n bracketSchema,\n graceSchema,\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 Grace,\n Note,\n Row,\n Part,\n Taal,\n Meta,\n Swaralipi,\n} from './schema.js';\n\nexport { TAALS, type TaalId } from './taals.js';\nexport { graceNotes } from './grace.js';\nexport { hasKomal, hasTivra } from './svara.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"]}
|
|
1
|
+
{"version":3,"sources":["../../src/spec/schema.ts","../../src/spec/taals.ts","../../src/spec/grace.ts","../../src/spec/lay.ts","../../src/spec/svara.ts","../../src/spec/index.ts"],"names":["z"],"mappings":";;;;;AAOO,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,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,GAAG,CAAC;AAIpE,IAAM,cAAcA,KAAA,CAAE,KAAA,CAAM,CAAC,YAAA,EAAc,iBAAiB,CAAC;AAI7D,IAAM,kBAAkBA,KAAA,CAAE,IAAA,CAAK,CAAC,WAAA,EAAa,UAAU,CAAC;AAWxD,IAAM,SAAA,GAAYA,MAAE,IAAA,CAAK,CAAC,QAAQ,QAAA,EAAU,QAAA,EAAU,MAAM,CAAC;AAS7D,IAAM,aAAA,GAAgBA,MAAE,MAAA,CAAO;AAAA,EACpC,MAAMA,KAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,MAAA,EAAQ,KAAK,CAAC,CAAA;AAAA,EACtC,MAAMA,KAAA,CAAE,IAAA,CAAK,CAAC,MAAA,EAAQ,OAAO,CAAC;AAChC,CAAC;AAWM,IAAM,cAAgCA,KAAA,CAAE,IAAA;AAAA,EAAK,MAClDA,KAAA,CAAE,KAAA,CAAM,CAAC,WAAA,EAAaA,KAAA,CAAE,KA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A,EAAO,QAAQ,wBAAA,EAAM,QAAA,EAAU,kDAAU,UAAA,EAAW;AAEpF,SAAS,WAAW,KAAA,EAAgC;AACzD,EAAA,MAAM,KAAA,GAAQ,MAAM,CAAC,CAAA;AACrB,EAAA,IAAI,KAAA,KAAU,MAAA,IAAa,KAAA,CAAM,KAAA,KAAU,QAAW,OAAO,MAAA;AAC7D,EAAA,KAAA,MAAW,CAAA,IAAK,OAAO,IAAA,CAAK,KAAK,GAAG,IAAI,CAAA,KAAM,SAAS,OAAO,MAAA;AAC9D,EAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,KAAA,CAAM,SAAA,CAAU,KAAK,CAAC,CAAA;AAC7C;AAIO,SAAS,OAAO,GAAA,EAA2B;AAChD,EAAA,OAAO,GAAA,CAAI,GAAA,IAAO,UAAA,CAAW,GAAA,CAAI,KAAK,CAAA;AACxC;;;ACpDO,SAAS,SAAS,MAAA,EAA8B;AACrD,EAAA,OAAO,WAAW,GAAA,IAAO,MAAA,KAAW,GAAA,IAAO,MAAA,KAAW,OAAO,MAAA,KAAW,GAAA;AAC1E;AAEO,SAAS,SAAS,MAAA,EAA8B;AACrD,EAAA,OAAO,MAAA,KAAW,GAAA;AACpB;;;ACVO,IAAM,YAAA,GAAe;AAiDrB,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';\nimport type { Lay } from './lay.js';\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 কণ / রেশ payload. Historically one `Svara` tuple; real notation puts\n * *several* svaras in a grace, and each may itself be a melisma, so the\n * richer form is a list of notes — reusing `Note` brings komal/tivra/\n * microtone/sustain along for free. The tuple form stays valid, so 0.7.x\n * documents parse unchanged; read either with `graceNotes()`.\n */\nexport type Grace = Svara | Note[];\nexport const graceSchema: z.ZodType<Grace> = z.lazy(() =>\n z.union([svaraSchema, z.array(noteSchema).min(1)]),\n);\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 /** কণ স্বর: one or more grace notes attached before this note. */\n kan?: Grace;\n /**\n * রেশ: an after-touch grace — the legend's mirror of কণ, written small to\n * the *right* of the note (\"আসল স্বরের পরে … অন্য স্বরের ঈষৎ রেশ লাগে;\n * তখন সেই স্বর ক্ষুদ্র অক্ষরে দক্ষিণ পার্শ্বে লিখিত হয়, যথা— রা˰স\").\n * Swarabitan writes it as a trailing uppercase letter (`mpaM`, `raS`).\n */\n resh?: Grace;\n /** মীড় (glide/slur) endpoint. */\n meend?: 'start' | 'end';\n /**\n * অর্ধমাত্রা (ঃ): this note closes a cell whose matra unit is a *half* —\n * `সঃ` = ½ matra, `সরঃ` = two ¼s, `রাঃ` = 1½ (legend p. ১৩৫).\n * Explicit rather than derived, because durations alone cannot distinguish\n * two half-matra cells (`সঃ গঃ`) from one matra split in two (`সরা`); this\n * flag is what closes the cell and prints the ঃ.\n */\n halfMatra?: boolean;\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: graceSchema.optional(),\n resh: graceSchema.optional(),\n meend: z.enum(['start', 'end']).optional(),\n halfMatra: z.boolean().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/** লয় tier. `Lay` (and the tempo factors) live in the zod-free ./lay.js,\n * which the viewer/player import directly; `satisfies` keeps the two in step. */\nexport const laySchema = z.enum(['drut', 'madhya', 'vilambit']) satisfies z.ZodType<Lay>;\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 /**\n * লয়: the tempo tier this row switches to, held until another row changes\n * it (absent on every row = the whole song at `meta.bpm`, i.e. দ্রুত).\n * Read it with `rowLay()`, which also picks up the mark NLTR *prints*\n * (\"বিলম্বিত লয়:\") in already-converted documents.\n */\n lay: laySchema.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 /**\n * Which tabla loop variation to play, e.g. `pro` (CDN dir suffix). Optional\n * and additive — omitted means the taal's default variation, so existing\n * docs are unaffected. The player honors it but never exposes a variation\n * picker; selecting a non-default variation is the consumer's premium policy.\n */\n variation: z.string().optional(),\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 as printed in the source (e.g. `ষষ্ঠী(২/৪)`), except\n * free rhythm which is normalised to `মুক্তছন্দ`. Always set by the NLTR\n * converter; `taal` is set only when the name resolves to a 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 /** Per-document override of the লয় tempo factors (fractions of `bpm`).\n * Defaults live in `LAY_SPEEDS`; a player/export option overrides both. */\n laySpeeds: z\n .object({ drut: z.number().positive(), madhya: z.number().positive(), vilambit: z.number().positive() })\n .partial()\n .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:\n * adachautaal, dadra, ektaal, jhaptaal, kehrwa, rupak, shashthi, teentaal,\n * jhampak, dhamaar.\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 *\n * Tabla loops live under `tabla/<id>/` by default; per-taal variation and\n * skip-bpm overrides (e.g. shashthi → `tabla/shashthi-pro/`) are in\n * instruments.ts's `TABLA_VARIATIONS`.\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 choutaal: { id: 'choutaal', numBeats: 12, bhaags: [2, 2, 2, 2, 2, 2], sam: 0, khaali: [2, 6] }, // চৌতাল\n shashthi: { id: 'shashthi', numBeats: 6, bhaags: [2, 4], sam: 0 }, // ষষ্ঠী\n teora: { id: 'teora', numBeats: 7, bhaags: [3, 2, 2], sam: 0 }, // টেওরা\n teentaal: { id: 'teentaal', numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] },\n aratheka: { id: 'aratheka', numBeats: 16, bhaags: [4, 4, 4, 4], sam: 0, khaali: [8] }, // আড়াঠেকা\n jhampak: { id: 'jhampak', numBeats: 5, bhaags: [3, 2], sam: 0 }, // ঝম্পক\n dhamaar: { id: 'dhamaar', numBeats: 14, bhaags: [5, 2, 3, 4], sam: 0, khaali: [7] }, // ধামার\n} as const satisfies Record<string, Taal>;\n\nexport type TaalId = keyof typeof TAALS;\n","/**\n * কণ / রেশ readers. Zod-free on purpose: the viewer and the player import\n * this directly (the `spec/index.js` barrel would drag zod into their\n * browser bundles — see `taals.ts` for the same rule).\n */\nimport type { Grace, Note, Svara } from './schema.js';\n\n/** Normalise a grace payload to its note list; the legacy tuple is one note. */\nexport function graceNotes(grace: Grace | undefined): Note[] {\n if (grace === undefined) return [];\n return typeof grace[0] === 'string' ? [{ svara: grace as Svara }] : (grace as Note[]);\n}\n","/**\n * লয় (laya) — the tempo tier a passage is sung at.\n *\n * Hindustani names the three tiers বিলম্বিত / মধ্য / দ্রুত (vilambit = slow,\n * madhya = medium, drut = fast), and Rabindrasangeet swaralipi uses the same\n * words: NLTR prints \"বিলম্বিত লয়:\" / \"দ্রুত লয়:\" at the head of the line\n * where the tempo changes (see `printedLay`).\n *\n * `meta.bpm` is the **দ্রুত** tempo — the fast one — so the tiers are\n * multipliers ≤ 1 on it and a document with no লয় marks plays exactly as it\n * did before this field existed.\n *\n * Zod-free on purpose: the viewer, player and creator import this directly\n * (the `spec/index.js` barrel would drag zod into their browser bundles — the\n * same rule as `taals.ts` and `grace.ts`).\n */\nimport type { Note, Row } from './schema.js';\n\nexport type Lay = 'drut' | 'madhya' | 'vilambit';\n\nexport const LAYS: readonly Lay[] = ['drut', 'madhya', 'vilambit'];\n\n/**\n * ### The tempo factors — change them HERE.\n *\n * Fraction of `meta.bpm` each tier is played at. Consumers override per\n * document (`meta.laySpeeds`) or per player/export call (`laySpeeds`), so\n * these are only the fallback.\n */\nexport const LAY_SPEEDS: Record<Lay, number> = {\n drut: 1,\n madhya: 0.75,\n vilambit: 0.5,\n};\n\nexport type LaySpeeds = Partial<Record<Lay, number>>;\n\n/** Resolve the factors actually in force: call option → document → default. */\nexport function resolveLaySpeeds(doc?: LaySpeeds, opt?: LaySpeeds): Record<Lay, number> {\n return { ...LAY_SPEEDS, ...doc, ...opt };\n}\n\n/**\n * The printed লয় mark: the leading lyric-only cells NLTR writes a tempo\n * change as (\"বিলম্বিত\" \"লয়:\"). Reading it means the 1738 already-converted\n * songs change tempo without being reconverted or edited.\n *\n * ponytail: matches the first word only, and only in the leading annotation\n * position where real lyrics never sit — so 'মধ্যমান' (a taal) can't trip it.\n * If a source ever writes the mark elsewhere in the row, give it `row.lay`.\n */\nconst PRINTED: Record<string, Lay> = { দ্রুত: 'drut', মধ্য: 'madhya', বিলম্বিত: 'vilambit' };\n\nexport function printedLay(notes: Note[]): Lay | undefined {\n const first = notes[0];\n if (first === undefined || first.lyric === undefined) return undefined;\n for (const k of Object.keys(first)) if (k !== 'lyric') return undefined;\n return PRINTED[first.lyric.normalize('NFC')];\n}\n\n/** The লয় this row switches to, if any: the explicit field wins over the\n * source's printed mark. `undefined` = carry on at the previous tier. */\nexport function rowLay(row: Row): Lay | undefined {\n return row.lay ?? printedLay(row.notes);\n}\n","/**\n * Which svaras admit which alteration — স and প are অচল (immovable), ম has\n * only its তীব্র (কড়ি) form, and র গ ধ ন only their কোমল form. The notation\n * fonts encode exactly this (no glyph exists for a কোমল প), so a flag the\n * sheet cannot draw must not move the pitch either.\n *\n * Zod-free on purpose: the viewer and the player import this directly (the\n * `spec/index.js` barrel would drag zod into their browser bundles — see\n * `taals.ts` and `grace.ts` for the same rule).\n */\nimport type { SvaraLetter } from './schema.js';\n\nexport function hasKomal(letter: SvaraLetter): boolean {\n return letter === 'r' || letter === 'g' || letter === 'd' || letter === 'n';\n}\n\nexport function hasTivra(letter: SvaraLetter): boolean {\n return letter === 'm';\n}\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.8.0';\n\nexport {\n octaveSchema,\n svaraLetterSchema,\n svaraSchema,\n microtoneSchema,\n barSchema,\n bracketSchema,\n graceSchema,\n laySchema,\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 Grace,\n Note,\n Row,\n Part,\n Taal,\n Meta,\n Swaralipi,\n} from './schema.js';\n\nexport { TAALS, type TaalId } from './taals.js';\nexport { graceNotes } from './grace.js';\nexport {\n LAYS,\n LAY_SPEEDS,\n printedLay,\n resolveLaySpeeds,\n rowLay,\n type Lay,\n type LaySpeeds,\n} from './lay.js';\nexport { hasKomal, hasTivra } from './svara.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"]}
|
package/dist/spec/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as zod from 'zod';
|
|
2
|
-
import { G as Grace, N as Note, a as SvaraLetter, S as Swaralipi } from '../schema-
|
|
3
|
-
export { B as Bar, b as Bracket, M as Meta, c as Microtone, O as Octave, P as Part, R as Row, d as Svara, T as Taal, e as barSchema, f as bracketSchema, g as graceSchema, m as metaSchema, h as microtoneSchema, n as noteSchema, o as octaveSchema, p as partSchema, r as rowSchema, s as svaraLetterSchema, i as svaraSchema, j as swaralipiSchema, t as taalSchema } from '../schema-
|
|
4
|
-
export { a as TAALS, T as TaalId } from '../
|
|
2
|
+
import { G as Grace, N as Note, a as SvaraLetter, S as Swaralipi } from '../schema-DGA_bNVZ.cjs';
|
|
3
|
+
export { B as Bar, b as Bracket, M as Meta, c as Microtone, O as Octave, P as Part, R as Row, d as Svara, T as Taal, e as barSchema, f as bracketSchema, g as graceSchema, l as laySchema, m as metaSchema, h as microtoneSchema, n as noteSchema, o as octaveSchema, p as partSchema, r as rowSchema, s as svaraLetterSchema, i as svaraSchema, j as swaralipiSchema, t as taalSchema } from '../schema-DGA_bNVZ.cjs';
|
|
4
|
+
export { b as LAYS, c as LAY_SPEEDS, L as Lay, a as LaySpeeds, e as TAALS, T as TaalId, p as printedLay, r as resolveLaySpeeds, d as rowLay } from '../lay-Csa4CD46.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* কণ / রেশ readers. Zod-free on purpose: the viewer and the player import
|
|
@@ -27,7 +27,7 @@ declare function hasKomal(letter: SvaraLetter): boolean;
|
|
|
27
27
|
declare function hasTivra(letter: SvaraLetter): boolean;
|
|
28
28
|
|
|
29
29
|
/** Current spec version. Documents declare the version they target. */
|
|
30
|
-
declare const SPEC_VERSION = "0.
|
|
30
|
+
declare const SPEC_VERSION = "0.8.0";
|
|
31
31
|
|
|
32
32
|
/** Parse + validate unknown data into a `Swaralipi`. Throws `ZodError` on failure. */
|
|
33
33
|
declare function parseSwaralipi(data: unknown): Swaralipi;
|
|
@@ -49,6 +49,11 @@ declare function safeParseSwaralipi(data: unknown): zod.SafeParseReturnType<{
|
|
|
49
49
|
taalName?: string | undefined;
|
|
50
50
|
tonic?: string | undefined;
|
|
51
51
|
bpm?: number | null | undefined;
|
|
52
|
+
laySpeeds?: {
|
|
53
|
+
drut?: number | undefined;
|
|
54
|
+
madhya?: number | undefined;
|
|
55
|
+
vilambit?: number | undefined;
|
|
56
|
+
} | undefined;
|
|
52
57
|
raag?: string | undefined;
|
|
53
58
|
avartan?: number | undefined;
|
|
54
59
|
notationBy?: string | undefined;
|
|
@@ -58,6 +63,7 @@ declare function safeParseSwaralipi(data: unknown): zod.SafeParseReturnType<{
|
|
|
58
63
|
rows: {
|
|
59
64
|
notes: Note[];
|
|
60
65
|
label?: string | undefined;
|
|
66
|
+
lay?: "drut" | "madhya" | "vilambit" | undefined;
|
|
61
67
|
}[];
|
|
62
68
|
name?: string | undefined;
|
|
63
69
|
}[];
|
|
@@ -78,6 +84,11 @@ declare function safeParseSwaralipi(data: unknown): zod.SafeParseReturnType<{
|
|
|
78
84
|
taalName?: string | undefined;
|
|
79
85
|
tonic?: string | undefined;
|
|
80
86
|
bpm?: number | null | undefined;
|
|
87
|
+
laySpeeds?: {
|
|
88
|
+
drut?: number | undefined;
|
|
89
|
+
madhya?: number | undefined;
|
|
90
|
+
vilambit?: number | undefined;
|
|
91
|
+
} | undefined;
|
|
81
92
|
raag?: string | undefined;
|
|
82
93
|
avartan?: number | undefined;
|
|
83
94
|
notationBy?: string | undefined;
|
|
@@ -87,6 +98,7 @@ declare function safeParseSwaralipi(data: unknown): zod.SafeParseReturnType<{
|
|
|
87
98
|
rows: {
|
|
88
99
|
notes: Note[];
|
|
89
100
|
label?: string | undefined;
|
|
101
|
+
lay?: "drut" | "madhya" | "vilambit" | undefined;
|
|
90
102
|
}[];
|
|
91
103
|
name?: string | undefined;
|
|
92
104
|
}[];
|
package/dist/spec/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as zod from 'zod';
|
|
2
|
-
import { G as Grace, N as Note, a as SvaraLetter, S as Swaralipi } from '../schema-
|
|
3
|
-
export { B as Bar, b as Bracket, M as Meta, c as Microtone, O as Octave, P as Part, R as Row, d as Svara, T as Taal, e as barSchema, f as bracketSchema, g as graceSchema, m as metaSchema, h as microtoneSchema, n as noteSchema, o as octaveSchema, p as partSchema, r as rowSchema, s as svaraLetterSchema, i as svaraSchema, j as swaralipiSchema, t as taalSchema } from '../schema-
|
|
4
|
-
export { a as TAALS, T as TaalId } from '../
|
|
2
|
+
import { G as Grace, N as Note, a as SvaraLetter, S as Swaralipi } from '../schema-DGA_bNVZ.js';
|
|
3
|
+
export { B as Bar, b as Bracket, M as Meta, c as Microtone, O as Octave, P as Part, R as Row, d as Svara, T as Taal, e as barSchema, f as bracketSchema, g as graceSchema, l as laySchema, m as metaSchema, h as microtoneSchema, n as noteSchema, o as octaveSchema, p as partSchema, r as rowSchema, s as svaraLetterSchema, i as svaraSchema, j as swaralipiSchema, t as taalSchema } from '../schema-DGA_bNVZ.js';
|
|
4
|
+
export { b as LAYS, c as LAY_SPEEDS, L as Lay, a as LaySpeeds, e as TAALS, T as TaalId, p as printedLay, r as resolveLaySpeeds, d as rowLay } from '../lay-Ct9ky_EE.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* কণ / রেশ readers. Zod-free on purpose: the viewer and the player import
|
|
@@ -27,7 +27,7 @@ declare function hasKomal(letter: SvaraLetter): boolean;
|
|
|
27
27
|
declare function hasTivra(letter: SvaraLetter): boolean;
|
|
28
28
|
|
|
29
29
|
/** Current spec version. Documents declare the version they target. */
|
|
30
|
-
declare const SPEC_VERSION = "0.
|
|
30
|
+
declare const SPEC_VERSION = "0.8.0";
|
|
31
31
|
|
|
32
32
|
/** Parse + validate unknown data into a `Swaralipi`. Throws `ZodError` on failure. */
|
|
33
33
|
declare function parseSwaralipi(data: unknown): Swaralipi;
|
|
@@ -49,6 +49,11 @@ declare function safeParseSwaralipi(data: unknown): zod.SafeParseReturnType<{
|
|
|
49
49
|
taalName?: string | undefined;
|
|
50
50
|
tonic?: string | undefined;
|
|
51
51
|
bpm?: number | null | undefined;
|
|
52
|
+
laySpeeds?: {
|
|
53
|
+
drut?: number | undefined;
|
|
54
|
+
madhya?: number | undefined;
|
|
55
|
+
vilambit?: number | undefined;
|
|
56
|
+
} | undefined;
|
|
52
57
|
raag?: string | undefined;
|
|
53
58
|
avartan?: number | undefined;
|
|
54
59
|
notationBy?: string | undefined;
|
|
@@ -58,6 +63,7 @@ declare function safeParseSwaralipi(data: unknown): zod.SafeParseReturnType<{
|
|
|
58
63
|
rows: {
|
|
59
64
|
notes: Note[];
|
|
60
65
|
label?: string | undefined;
|
|
66
|
+
lay?: "drut" | "madhya" | "vilambit" | undefined;
|
|
61
67
|
}[];
|
|
62
68
|
name?: string | undefined;
|
|
63
69
|
}[];
|
|
@@ -78,6 +84,11 @@ declare function safeParseSwaralipi(data: unknown): zod.SafeParseReturnType<{
|
|
|
78
84
|
taalName?: string | undefined;
|
|
79
85
|
tonic?: string | undefined;
|
|
80
86
|
bpm?: number | null | undefined;
|
|
87
|
+
laySpeeds?: {
|
|
88
|
+
drut?: number | undefined;
|
|
89
|
+
madhya?: number | undefined;
|
|
90
|
+
vilambit?: number | undefined;
|
|
91
|
+
} | undefined;
|
|
81
92
|
raag?: string | undefined;
|
|
82
93
|
avartan?: number | undefined;
|
|
83
94
|
notationBy?: string | undefined;
|
|
@@ -87,6 +98,7 @@ declare function safeParseSwaralipi(data: unknown): zod.SafeParseReturnType<{
|
|
|
87
98
|
rows: {
|
|
88
99
|
notes: Note[];
|
|
89
100
|
label?: string | undefined;
|
|
101
|
+
lay?: "drut" | "madhya" | "vilambit" | undefined;
|
|
90
102
|
}[];
|
|
91
103
|
name?: string | undefined;
|
|
92
104
|
}[];
|
package/dist/spec/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SPEC_VERSION, barSchema, bracketSchema, graceSchema, metaSchema, microtoneSchema, noteSchema, octaveSchema, parseSwaralipi, partSchema, rowSchema, safeParseSwaralipi, svaraLetterSchema, svaraSchema, swaralipiSchema, taalSchema } from '../chunk-
|
|
2
|
-
export { TAALS, graceNotes, hasKomal, hasTivra } from '../chunk-
|
|
1
|
+
export { SPEC_VERSION, barSchema, bracketSchema, graceSchema, laySchema, metaSchema, microtoneSchema, noteSchema, octaveSchema, parseSwaralipi, partSchema, rowSchema, safeParseSwaralipi, svaraLetterSchema, svaraSchema, swaralipiSchema, taalSchema } from '../chunk-4HMHTXDE.js';
|
|
2
|
+
export { LAYS, LAY_SPEEDS, TAALS, graceNotes, hasKomal, hasTivra, printedLay, resolveLaySpeeds, rowLay } from '../chunk-4HNT6OAT.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/viewer/index.cjs
CHANGED
|
@@ -12,6 +12,32 @@ var __export = (target, all) => {
|
|
|
12
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
// src/spec/lay.ts
|
|
16
|
+
function resolveLaySpeeds(doc, opt) {
|
|
17
|
+
return { ...LAY_SPEEDS, ...doc, ...opt };
|
|
18
|
+
}
|
|
19
|
+
function printedLay(notes) {
|
|
20
|
+
const first = notes[0];
|
|
21
|
+
if (first === void 0 || first.lyric === void 0) return void 0;
|
|
22
|
+
for (const k of Object.keys(first)) if (k !== "lyric") return void 0;
|
|
23
|
+
return PRINTED[first.lyric.normalize("NFC")];
|
|
24
|
+
}
|
|
25
|
+
function rowLay(row) {
|
|
26
|
+
return row.lay ?? printedLay(row.notes);
|
|
27
|
+
}
|
|
28
|
+
var LAYS, LAY_SPEEDS, PRINTED;
|
|
29
|
+
var init_lay = __esm({
|
|
30
|
+
"src/spec/lay.ts"() {
|
|
31
|
+
LAYS = ["drut", "madhya", "vilambit"];
|
|
32
|
+
LAY_SPEEDS = {
|
|
33
|
+
drut: 1,
|
|
34
|
+
madhya: 0.75,
|
|
35
|
+
vilambit: 0.5
|
|
36
|
+
};
|
|
37
|
+
PRINTED = { \u09A6\u09CD\u09B0\u09C1\u09A4: "drut", \u09AE\u09A7\u09CD\u09AF: "madhya", \u09AC\u09BF\u09B2\u09AE\u09CD\u09AC\u09BF\u09A4: "vilambit" };
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
15
41
|
// src/spec/grace.ts
|
|
16
42
|
function graceNotes(grace) {
|
|
17
43
|
if (grace === void 0) return [];
|
|
@@ -61,7 +87,7 @@ var init_taals = __esm({
|
|
|
61
87
|
};
|
|
62
88
|
}
|
|
63
89
|
});
|
|
64
|
-
var octaveSchema, svaraLetterSchema, svaraSchema, microtoneSchema, barSchema, bracketSchema, graceSchema, noteSchema, rowSchema, partSchema, taalSchema, metaSchema, swaralipiSchema;
|
|
90
|
+
var octaveSchema, svaraLetterSchema, svaraSchema, microtoneSchema, barSchema, bracketSchema, graceSchema, noteSchema, laySchema, rowSchema, partSchema, taalSchema, metaSchema, swaralipiSchema;
|
|
65
91
|
var init_schema = __esm({
|
|
66
92
|
"src/spec/schema.ts"() {
|
|
67
93
|
octaveSchema = zod.z.enum([
|
|
@@ -113,9 +139,17 @@ var init_schema = __esm({
|
|
|
113
139
|
}
|
|
114
140
|
)
|
|
115
141
|
);
|
|
142
|
+
laySchema = zod.z.enum(["drut", "madhya", "vilambit"]);
|
|
116
143
|
rowSchema = zod.z.object({
|
|
117
144
|
/** Optional line label (e.g. a tuk/section marker). */
|
|
118
145
|
label: zod.z.string().optional(),
|
|
146
|
+
/**
|
|
147
|
+
* লয়: the tempo tier this row switches to, held until another row changes
|
|
148
|
+
* it (absent on every row = the whole song at `meta.bpm`, i.e. দ্রুত).
|
|
149
|
+
* Read it with `rowLay()`, which also picks up the mark NLTR *prints*
|
|
150
|
+
* ("বিলম্বিত লয়:") in already-converted documents.
|
|
151
|
+
*/
|
|
152
|
+
lay: laySchema.optional(),
|
|
119
153
|
notes: zod.z.array(noteSchema)
|
|
120
154
|
});
|
|
121
155
|
partSchema = zod.z.object({
|
|
@@ -161,6 +195,9 @@ var init_schema = __esm({
|
|
|
161
195
|
* The player adopts it on `load()` (precedence: constructor `bpm` → `setBpm`
|
|
162
196
|
* tweak → this → 90). `null` is the converter's blank placeholder = unset. */
|
|
163
197
|
bpm: zod.z.number().positive().nullable().optional(),
|
|
198
|
+
/** Per-document override of the লয় tempo factors (fractions of `bpm`).
|
|
199
|
+
* Defaults live in `LAY_SPEEDS`; a player/export option overrides both. */
|
|
200
|
+
laySpeeds: zod.z.object({ drut: zod.z.number().positive(), madhya: zod.z.number().positive(), vilambit: zod.z.number().positive() }).partial().optional(),
|
|
164
201
|
raag: zod.z.string().optional(),
|
|
165
202
|
/** আবর্তন: number of taal cycles, when the source states it. */
|
|
166
203
|
avartan: zod.z.number().int().positive().optional(),
|
|
@@ -181,6 +218,8 @@ var init_schema = __esm({
|
|
|
181
218
|
// src/spec/index.ts
|
|
182
219
|
var spec_exports = {};
|
|
183
220
|
__export(spec_exports, {
|
|
221
|
+
LAYS: () => LAYS,
|
|
222
|
+
LAY_SPEEDS: () => LAY_SPEEDS,
|
|
184
223
|
SPEC_VERSION: () => SPEC_VERSION,
|
|
185
224
|
TAALS: () => TAALS,
|
|
186
225
|
barSchema: () => barSchema,
|
|
@@ -189,12 +228,16 @@ __export(spec_exports, {
|
|
|
189
228
|
graceSchema: () => graceSchema,
|
|
190
229
|
hasKomal: () => hasKomal,
|
|
191
230
|
hasTivra: () => hasTivra,
|
|
231
|
+
laySchema: () => laySchema,
|
|
192
232
|
metaSchema: () => metaSchema,
|
|
193
233
|
microtoneSchema: () => microtoneSchema,
|
|
194
234
|
noteSchema: () => noteSchema,
|
|
195
235
|
octaveSchema: () => octaveSchema,
|
|
196
236
|
parseSwaralipi: () => parseSwaralipi,
|
|
197
237
|
partSchema: () => partSchema,
|
|
238
|
+
printedLay: () => printedLay,
|
|
239
|
+
resolveLaySpeeds: () => resolveLaySpeeds,
|
|
240
|
+
rowLay: () => rowLay,
|
|
198
241
|
rowSchema: () => rowSchema,
|
|
199
242
|
safeParseSwaralipi: () => safeParseSwaralipi,
|
|
200
243
|
svaraLetterSchema: () => svaraLetterSchema,
|
|
@@ -215,11 +258,15 @@ var init_spec = __esm({
|
|
|
215
258
|
init_schema();
|
|
216
259
|
init_taals();
|
|
217
260
|
init_grace();
|
|
261
|
+
init_lay();
|
|
218
262
|
init_svara();
|
|
219
|
-
SPEC_VERSION = "0.
|
|
263
|
+
SPEC_VERSION = "0.8.0";
|
|
220
264
|
}
|
|
221
265
|
});
|
|
222
266
|
|
|
267
|
+
// src/player/schedule.ts
|
|
268
|
+
init_lay();
|
|
269
|
+
|
|
223
270
|
// src/player/pitch.ts
|
|
224
271
|
init_grace();
|
|
225
272
|
init_svara();
|
|
@@ -338,22 +385,38 @@ function buildSchedule(doc, opts = {}) {
|
|
|
338
385
|
const events = [];
|
|
339
386
|
let cursor = 0;
|
|
340
387
|
let lastPitched = -1;
|
|
341
|
-
let
|
|
388
|
+
let samMatra;
|
|
389
|
+
let matra = 0;
|
|
390
|
+
const speeds = resolveLaySpeeds(doc.meta.laySpeeds, opts.laySpeeds);
|
|
391
|
+
const withLay = opts.lay !== false;
|
|
392
|
+
const tempo = [{ beat: 0, endBeat: 0, scale: 1, lay: "drut" }];
|
|
393
|
+
let scale = 1;
|
|
342
394
|
doc.parts.forEach((part, p) => {
|
|
343
395
|
part.rows.forEach((row, r) => {
|
|
396
|
+
const lay = withLay ? rowLay(row) : void 0;
|
|
397
|
+
if (lay !== void 0 && speeds[lay] !== scale) {
|
|
398
|
+
scale = speeds[lay];
|
|
399
|
+
const last = tempo[tempo.length - 1];
|
|
400
|
+
if (last.beat === cursor) tempo[tempo.length - 1] = { beat: cursor, endBeat: cursor, scale, lay };
|
|
401
|
+
else {
|
|
402
|
+
last.endBeat = cursor;
|
|
403
|
+
tempo.push({ beat: cursor, endBeat: cursor, scale, lay });
|
|
404
|
+
}
|
|
405
|
+
}
|
|
344
406
|
const glides = meendContinuations(row.notes);
|
|
345
407
|
row.notes.forEach((note, i) => {
|
|
346
|
-
if (
|
|
408
|
+
if (samMatra === void 0 && note.above !== void 0) {
|
|
347
409
|
for (const a of note.above) {
|
|
348
410
|
if (a.raw !== void 0 && SAM_TICK.test(a.raw)) {
|
|
349
|
-
|
|
411
|
+
samMatra = matra;
|
|
350
412
|
break;
|
|
351
413
|
}
|
|
352
414
|
}
|
|
353
415
|
}
|
|
354
416
|
if (note.bar !== void 0 || isSilent(note)) return;
|
|
355
417
|
const path = `${p}.${r}.${i}`;
|
|
356
|
-
const
|
|
418
|
+
const written = note.durationMatra ?? 1;
|
|
419
|
+
const dur = written / scale;
|
|
357
420
|
if (note.svara !== void 0) {
|
|
358
421
|
events.push({
|
|
359
422
|
beat: cursor,
|
|
@@ -372,12 +435,14 @@ function buildSchedule(doc, opts = {}) {
|
|
|
372
435
|
events.push({ beat: cursor, durationBeats: dur, midi: null, kan: [], path, kind: "rest" });
|
|
373
436
|
}
|
|
374
437
|
cursor += dur;
|
|
438
|
+
matra += written;
|
|
375
439
|
});
|
|
376
440
|
});
|
|
377
441
|
});
|
|
378
442
|
const numBeats = doc.meta.taal?.numBeats;
|
|
379
|
-
const
|
|
380
|
-
|
|
443
|
+
const pickupMatra = samMatra !== void 0 && numBeats !== void 0 && numBeats > 0 ? (numBeats - samMatra % numBeats) % numBeats : 0;
|
|
444
|
+
tempo[tempo.length - 1].endBeat = cursor;
|
|
445
|
+
return { events, totalBeats: cursor, pickupBeats: pickupMatra / tempo[0].scale, tempo };
|
|
381
446
|
}
|
|
382
447
|
|
|
383
448
|
// src/viewer/render.ts
|
|
@@ -427,6 +492,11 @@ var LABELS = {
|
|
|
427
492
|
// one taal cycle is exactly what the number counts.
|
|
428
493
|
en: { title: "Song", taal: "Taal", raag: "Raag", avartan: "Cycles", notationBy: "Notator" }
|
|
429
494
|
};
|
|
495
|
+
var LAY_LABELS = {
|
|
496
|
+
bn: { drut: "\u09A6\u09CD\u09B0\u09C1\u09A4 \u09B2\u09AF\u09BC", madhya: "\u09AE\u09A7\u09CD\u09AF \u09B2\u09AF\u09BC", vilambit: "\u09AC\u09BF\u09B2\u09AE\u09CD\u09AC\u09BF\u09A4 \u09B2\u09AF\u09BC" },
|
|
497
|
+
hi: { drut: "\u0926\u094D\u0930\u0941\u0924 \u0932\u092F", madhya: "\u092E\u0927\u094D\u092F \u0932\u092F", vilambit: "\u0935\u093F\u0932\u0902\u092C\u093F\u0924 \u0932\u092F" },
|
|
498
|
+
en: { drut: "Fast (drut)", madhya: "Medium (madhya)", vilambit: "Slow (vilambit)" }
|
|
499
|
+
};
|
|
430
500
|
function composeCluster(letter, opts) {
|
|
431
501
|
const classes = [];
|
|
432
502
|
if (opts.lang === "bn") {
|
|
@@ -861,11 +931,18 @@ function renderToHtml(doc, opts = {}) {
|
|
|
861
931
|
if (opts.showHeader !== false) out.push(renderHeader(doc.meta, ctx));
|
|
862
932
|
out.push(`<div class="sw-scroll"><div class="sw-block" style="${tracks}">`);
|
|
863
933
|
let n = 0;
|
|
934
|
+
let lay;
|
|
864
935
|
doc.parts.forEach((part, p) => {
|
|
865
936
|
out.push('<section class="sw-part">');
|
|
866
937
|
if (part.name !== void 0)
|
|
867
938
|
out.push(`<h3 class="sw-part-name">${escapeHtml(ctx.tr(part.name))}</h3>`);
|
|
868
|
-
part.rows.forEach((row, r) =>
|
|
939
|
+
part.rows.forEach((row, r) => {
|
|
940
|
+
if (row.lay !== void 0 && row.lay !== lay) {
|
|
941
|
+
lay = row.lay;
|
|
942
|
+
out.push(`<div class="sw-lay" data-lay="${lay}">${escapeHtml(LAY_LABELS[ctx.lang][lay])}</div>`);
|
|
943
|
+
}
|
|
944
|
+
out.push(renderRow(row, p, r, layout.offsets[n++], ctx));
|
|
945
|
+
});
|
|
869
946
|
out.push("</section>");
|
|
870
947
|
});
|
|
871
948
|
out.push("</div></div></div>");
|
|
@@ -957,6 +1034,30 @@ ${FONT_FACES}
|
|
|
957
1034
|
|
|
958
1035
|
.sw-part-name { font-size: 0.85em; font-weight: 600; margin: 1em 0 0.2em; opacity: 0.85; }
|
|
959
1036
|
|
|
1037
|
+
/* \u09B2\u09AF\u09BC marker: the line where the tempo tier turns over. A full-width rule
|
|
1038
|
+
rather than a row label \u2014 the label track is what the notation columns are
|
|
1039
|
+
measured against, and a six-em word in it would shove the whole sheet right. */
|
|
1040
|
+
.sw-lay {
|
|
1041
|
+
grid-column: 1 / -1;
|
|
1042
|
+
display: flex;
|
|
1043
|
+
align-items: center;
|
|
1044
|
+
gap: 0.6em;
|
|
1045
|
+
margin: 0.8em 0 0;
|
|
1046
|
+
/* Floored like the header: fitSwaralipi shrinks the sheet to fit the
|
|
1047
|
+
notation's columns, and this label has none to align. */
|
|
1048
|
+
font-size: max(0.7em, var(--sw-lay-min, 0.72rem));
|
|
1049
|
+
font-weight: 600;
|
|
1050
|
+
letter-spacing: 0.09em;
|
|
1051
|
+
opacity: 0.75;
|
|
1052
|
+
break-after: avoid;
|
|
1053
|
+
}
|
|
1054
|
+
.sw-lay::after {
|
|
1055
|
+
content: '';
|
|
1056
|
+
flex: 1;
|
|
1057
|
+
height: 1px;
|
|
1058
|
+
background: var(--sw-rule, rgba(128, 128, 128, 0.35));
|
|
1059
|
+
}
|
|
1060
|
+
|
|
960
1061
|
/* ---- block grid: ONE column set for the whole sheet ----
|
|
961
1062
|
* NLTR emits a song as a single html table, which is why its lines align
|
|
962
1063
|
* down the page. Same here: .sw-block owns the tracks, every .sw-row
|
|
@@ -1141,7 +1242,7 @@ var SWARALIPI_PRINT_CSS = `
|
|
|
1141
1242
|
.sw-sheet, .sw-staff { -webkit-print-color-adjust: exact; print-color-adjust: exact; color: #000; }
|
|
1142
1243
|
.sw-scroll { overflow: visible !important; }
|
|
1143
1244
|
.sw-row { break-inside: avoid; page-break-inside: avoid; }
|
|
1144
|
-
.sw-part-name, .sw-header { break-after: avoid-page; page-break-after: avoid; }
|
|
1245
|
+
.sw-part-name, .sw-header, .sw-lay { break-after: avoid-page; page-break-after: avoid; }
|
|
1145
1246
|
.sw-hl { background: none !important; }
|
|
1146
1247
|
/* Keep each engraved staff system whole across a page break (the abcjs line
|
|
1147
1248
|
is a <div> wrapping the <svg>, so the break rule must sit on the div). */
|
|
@@ -1413,7 +1514,7 @@ function resolveDrumTaal(doc) {
|
|
|
1413
1514
|
return id !== void 0 && id in TAALS ? TAALS[id] : { numBeats: 4, sam: 0 };
|
|
1414
1515
|
}
|
|
1415
1516
|
function docToAbc(doc, opts = {}) {
|
|
1416
|
-
const schedule = buildSchedule(doc, { tonic: opts.tonic, baseOctave: opts.baseOctave });
|
|
1517
|
+
const schedule = buildSchedule(doc, { tonic: opts.tonic, baseOctave: opts.baseOctave, lay: false });
|
|
1417
1518
|
const bpm = opts.bpm ?? doc.meta.bpm ?? 90;
|
|
1418
1519
|
const beatsPerBar = opts.beatsPerBar ?? doc.meta.taal?.numBeats ?? 4;
|
|
1419
1520
|
const drums = opts.drums ? drumPattern(resolveDrumTaal(doc)) : void 0;
|
|
@@ -1477,7 +1578,7 @@ async function abcToSvg(abc, opts = {}, notePaths) {
|
|
|
1477
1578
|
async function renderStaffHtml(doc, opts = {}) {
|
|
1478
1579
|
const bpm = opts.bpm ?? doc.meta.bpm ?? 90;
|
|
1479
1580
|
const abc = docToAbc(doc, { ...opts, bpm });
|
|
1480
|
-
const schedule = buildSchedule(doc, { tonic: opts.tonic, baseOctave: opts.baseOctave });
|
|
1581
|
+
const schedule = buildSchedule(doc, { tonic: opts.tonic, baseOctave: opts.baseOctave, lay: false });
|
|
1481
1582
|
const engraved = await abcToSvg(abc, opts, eventPaths(schedule));
|
|
1482
1583
|
const lines = engraved.includes("sw-staff-missing") ? engraved : `<div class="sw-staff-lines">${engraved}</div>`;
|
|
1483
1584
|
const header = opts.showHeader === false ? "" : renderMetaHeader(doc.meta, opts.headerLang ?? "en", opts.transliterate);
|
|
@@ -1888,6 +1989,7 @@ exports.DEFAULT_NOTATOR = DEFAULT_NOTATOR;
|
|
|
1888
1989
|
exports.DEFAULT_WATERMARK = DEFAULT_WATERMARK;
|
|
1889
1990
|
exports.DIGITS = DIGITS;
|
|
1890
1991
|
exports.LABELS = LABELS;
|
|
1992
|
+
exports.LAY_LABELS = LAY_LABELS;
|
|
1891
1993
|
exports.MARKS = MARKS;
|
|
1892
1994
|
exports.MAX_ZOOM = MAX_ZOOM;
|
|
1893
1995
|
exports.MIN_ZOOM = MIN_ZOOM;
|