@ugfoundation/swaralipi-js 0.7.5 → 0.7.7
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-DLPDVNFK.js → batch-6MCPHHKF.js} +5 -5
- package/dist/{batch-DLPDVNFK.js.map → batch-6MCPHHKF.js.map} +1 -1
- package/dist/{chunk-YAXYP7BR.js → chunk-ALN4SWMS.js} +3 -3
- package/dist/{chunk-YAXYP7BR.js.map → chunk-ALN4SWMS.js.map} +1 -1
- package/dist/{chunk-UF5OSJRP.js → chunk-QM4CXKW2.js} +11 -3
- package/dist/chunk-QM4CXKW2.js.map +1 -0
- package/dist/{chunk-ZAK3QRDN.js → chunk-QQC6WVLJ.js} +4 -4
- package/dist/{chunk-ZAK3QRDN.js.map → chunk-QQC6WVLJ.js.map} +1 -1
- package/dist/{chunk-2SAZWTTK.js → chunk-TKTQCUKD.js} +5 -5
- package/dist/chunk-TKTQCUKD.js.map +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/convert/index.cjs +1 -1
- package/dist/convert/index.cjs.map +1 -1
- package/dist/convert/index.js +3 -3
- package/dist/index.cjs +11 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/player/index.cjs +41 -7
- package/dist/player/index.cjs.map +1 -1
- package/dist/player/index.d.cts +15 -1
- package/dist/player/index.d.ts +15 -1
- package/dist/player/index.js +34 -8
- package/dist/player/index.js.map +1 -1
- package/dist/spec/index.cjs +11 -1
- package/dist/spec/index.cjs.map +1 -1
- package/dist/spec/index.d.cts +18 -4
- package/dist/spec/index.d.ts +18 -4
- package/dist/spec/index.js +2 -2
- package/dist/viewer/index.cjs +21 -5
- package/dist/viewer/index.cjs.map +1 -1
- package/dist/viewer/index.d.cts +0 -27
- package/dist/viewer/index.d.ts +0 -27
- package/dist/viewer/index.js +3 -4
- package/dist/viewer/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-2SAZWTTK.js.map +0 -1
- package/dist/chunk-UF5OSJRP.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { SPEC_VERSION, graceNotes, parseSwaralipi, safeParseSwaralipi } from './spec/index.js';
|
|
1
|
+
export { SPEC_VERSION, graceNotes, hasKomal, hasTivra, parseSwaralipi, safeParseSwaralipi } from './spec/index.js';
|
|
2
2
|
export { B as Bar, b as Bracket, G as Grace, M as Meta, c as Microtone, N as Note, O as Octave, P as Part, R as Row, d as Svara, a as SvaraLetter, S as Swaralipi, 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-DqBXPGkL.js';
|
|
3
3
|
export { a as TAALS, T as TaalId } from './taals-CjzBuZ35.js';
|
|
4
4
|
import 'zod';
|
package/dist/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 } from './chunk-
|
|
1
|
+
export { SPEC_VERSION, barSchema, bracketSchema, graceSchema, metaSchema, microtoneSchema, noteSchema, octaveSchema, parseSwaralipi, partSchema, rowSchema, safeParseSwaralipi, svaraLetterSchema, svaraSchema, swaralipiSchema, taalSchema } from './chunk-ALN4SWMS.js';
|
|
2
|
+
export { TAALS, graceNotes, hasKomal, hasTivra } from './chunk-QM4CXKW2.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/player/index.cjs
CHANGED
|
@@ -29,6 +29,14 @@ function graceNotes(grace) {
|
|
|
29
29
|
return typeof grace[0] === "string" ? [{ svara: grace }] : grace;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// src/spec/svara.ts
|
|
33
|
+
function hasKomal(letter) {
|
|
34
|
+
return letter === "r" || letter === "g" || letter === "d" || letter === "n";
|
|
35
|
+
}
|
|
36
|
+
function hasTivra(letter) {
|
|
37
|
+
return letter === "m";
|
|
38
|
+
}
|
|
39
|
+
|
|
32
40
|
// src/player/pitch.ts
|
|
33
41
|
var OCTAVE_OFFSET = {
|
|
34
42
|
"ati-mandra": -2,
|
|
@@ -79,8 +87,8 @@ function svaraSemitone(note) {
|
|
|
79
87
|
if (note.svara === void 0) return null;
|
|
80
88
|
const [, letter] = note.svara;
|
|
81
89
|
let semi = SHUDDHA[letter];
|
|
82
|
-
if (note.komal === true || note.microtone !== void 0) semi -= 1;
|
|
83
|
-
if (note.tivra === true) semi += 1;
|
|
90
|
+
if ((note.komal === true || note.microtone !== void 0) && hasKomal(letter)) semi -= 1;
|
|
91
|
+
if (note.tivra === true && hasTivra(letter)) semi += 1;
|
|
84
92
|
return semi;
|
|
85
93
|
}
|
|
86
94
|
function svaraToMidi(note, tonicPc, baseOctave = 4) {
|
|
@@ -489,6 +497,7 @@ function createTanpura(Tone, base, stems = TANPURA_PCS) {
|
|
|
489
497
|
|
|
490
498
|
// src/player/player.ts
|
|
491
499
|
var STOP_FADE_SEC = 0.5;
|
|
500
|
+
var MEDIA_LEAD_SEC = 0.25;
|
|
492
501
|
function midiRange(schedule) {
|
|
493
502
|
let lo = Infinity;
|
|
494
503
|
let hi = -Infinity;
|
|
@@ -502,6 +511,9 @@ function midiRange(schedule) {
|
|
|
502
511
|
}
|
|
503
512
|
return lo <= hi ? { lo, hi } : void 0;
|
|
504
513
|
}
|
|
514
|
+
function playDurationSec(schedule, spb, rhythm) {
|
|
515
|
+
return schedule.totalBeats * spb + (rhythm !== "none" ? schedule.pickupBeats * spb : 0) + spb;
|
|
516
|
+
}
|
|
505
517
|
async function loadedOrWarn(Tone) {
|
|
506
518
|
try {
|
|
507
519
|
await Tone.loaded();
|
|
@@ -582,6 +594,27 @@ var SwaralipiPlayer = class {
|
|
|
582
594
|
const id = this.#taalId();
|
|
583
595
|
return this.#opts.rhythm === "tabla" && id !== void 0 && SAMPLED_TAALS.has(id) && !!this.#opts.soundsBaseUrl;
|
|
584
596
|
}
|
|
597
|
+
/**
|
|
598
|
+
* Length of one play-through in seconds, for a progress bar (the OS media
|
|
599
|
+
* session's, typically). Derived from the loaded notation on every read and
|
|
600
|
+
* never stored, because every input can move: re-engrave the document, drag
|
|
601
|
+
* the tempo, switch the rhythm off, and this changes with it. `Infinity` in
|
|
602
|
+
* taal mode (one avartan looping, no end — the value the Media Session spec
|
|
603
|
+
* reserves for exactly that), 0 with nothing loaded, and clamped by a preview
|
|
604
|
+
* cap when one is set, since that is when playback will really stop.
|
|
605
|
+
*/
|
|
606
|
+
get durationSec() {
|
|
607
|
+
if (this.#taal !== void 0) return Infinity;
|
|
608
|
+
if (this.#doc === void 0) return 0;
|
|
609
|
+
const schedule = buildSchedule(this.#doc, { tonic: this.#opts.tonic, baseOctave: this.#opts.baseOctave });
|
|
610
|
+
const full = playDurationSec(schedule, 60 / this.#effectiveBpm(), this.#opts.rhythm);
|
|
611
|
+
return Math.min(full, this.#opts.previewLimitSec);
|
|
612
|
+
}
|
|
613
|
+
/** Seconds played so far, off the Transport's own clock — so it holds while
|
|
614
|
+
* paused, and reads 0 before the first play and after stop(). */
|
|
615
|
+
get positionSec() {
|
|
616
|
+
return this.#tone?.getTransport().seconds ?? 0;
|
|
617
|
+
}
|
|
585
618
|
/* ----------------------------------------------------------------- */
|
|
586
619
|
/* Loading + transport control */
|
|
587
620
|
/* ----------------------------------------------------------------- */
|
|
@@ -894,6 +927,7 @@ var SwaralipiPlayer = class {
|
|
|
894
927
|
}
|
|
895
928
|
const draw = Tone.getDraw();
|
|
896
929
|
const shift = this.#opts.rhythm !== "none" ? schedule.pickupBeats * spb : 0;
|
|
930
|
+
const mediaLead = Math.min(MEDIA_LEAD_SEC, spb);
|
|
897
931
|
schedule.events.forEach((ev, i) => {
|
|
898
932
|
const at = ev.beat * spb + shift;
|
|
899
933
|
if (ev.midi !== null && ev.glide !== true) {
|
|
@@ -927,12 +961,12 @@ var SwaralipiPlayer = class {
|
|
|
927
961
|
transport.scheduleOnce((time) => melody.triggerAttackRelease(name, dur, time), at);
|
|
928
962
|
}
|
|
929
963
|
}
|
|
930
|
-
|
|
931
|
-
this.#opts.onEvent?.(ev.path);
|
|
932
|
-
|
|
933
|
-
|
|
964
|
+
if (this.#opts.onEvent !== void 0) {
|
|
965
|
+
transport.scheduleOnce(() => this.#opts.onEvent?.(ev.path), Math.max(at - mediaLead, 0));
|
|
966
|
+
}
|
|
967
|
+
transport.scheduleOnce((time) => draw.schedule(() => this.#emitHighlight(ev.path), time), at);
|
|
934
968
|
});
|
|
935
|
-
const endAt = schedule
|
|
969
|
+
const endAt = playDurationSec(schedule, spb, this.#opts.rhythm);
|
|
936
970
|
transport.scheduleOnce((time) => {
|
|
937
971
|
this.#opts.onEvent?.(null);
|
|
938
972
|
draw.schedule(() => this.#emitHighlight(null), time);
|