@ugfoundation/swaralipi-js 0.13.0 → 0.14.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.
Files changed (38) hide show
  1. package/README.md +21 -0
  2. package/dist/{batch-BS2AIZOR.js → batch-D4HRATTH.js} +4 -4
  3. package/dist/{batch-BS2AIZOR.js.map → batch-D4HRATTH.js.map} +1 -1
  4. package/dist/{chunk-5N6HGPFH.js → chunk-QQOC6LRA.js} +3 -3
  5. package/dist/{chunk-5N6HGPFH.js.map → chunk-QQOC6LRA.js.map} +1 -1
  6. package/dist/{chunk-3ZBNANDF.js → chunk-UV5OJYT3.js} +3 -3
  7. package/dist/{chunk-3ZBNANDF.js.map → chunk-UV5OJYT3.js.map} +1 -1
  8. package/dist/{chunk-ZNJTMQIX.js → chunk-YBFM5NLW.js} +159 -23
  9. package/dist/chunk-YBFM5NLW.js.map +1 -0
  10. package/dist/cli.cjs +1 -1
  11. package/dist/cli.cjs.map +1 -1
  12. package/dist/cli.js +2 -2
  13. package/dist/convert/index.cjs +1 -1
  14. package/dist/convert/index.cjs.map +1 -1
  15. package/dist/convert/index.js +2 -2
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/player/index.cjs +172 -26
  20. package/dist/player/index.cjs.map +1 -1
  21. package/dist/player/index.d.cts +9 -5
  22. package/dist/player/index.d.ts +9 -5
  23. package/dist/player/index.js +15 -6
  24. package/dist/player/index.js.map +1 -1
  25. package/dist/{schedule-ClyON98C.d.ts → schedule-DsVESieT.d.ts} +27 -2
  26. package/dist/{schedule-V-fgepvP.d.cts → schedule-oJgg_bnc.d.cts} +27 -2
  27. package/dist/spec/index.cjs +1 -1
  28. package/dist/spec/index.cjs.map +1 -1
  29. package/dist/spec/index.d.cts +1 -1
  30. package/dist/spec/index.d.ts +1 -1
  31. package/dist/spec/index.js +1 -1
  32. package/dist/viewer/index.cjs +68 -33
  33. package/dist/viewer/index.cjs.map +1 -1
  34. package/dist/viewer/index.d.cts +1 -1
  35. package/dist/viewer/index.d.ts +1 -1
  36. package/dist/viewer/index.js +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-ZNJTMQIX.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import { S as Swaralipi, T as Taal, O as Octave, a as SvaraLetter, N as Note } from '../schema-DZag9qkF.cjs';
2
2
  import { a as LaySpeeds, T as TaalId } from '../lay-CXhC-HRO.cjs';
3
3
  export { b as LAYS, c as LAY_SPEEDS, L as Lay, p as printedLay, r as resolveLaySpeeds, d as rowLay } from '../lay-CXhC-HRO.cjs';
4
- import { I as InstrumentId, a as InstrumentDef, S as Schedule, D as DrumVoice, T as TempoSegment } from '../schedule-V-fgepvP.cjs';
5
- export { A as ARC_RAW_RE, b as DEFAULT_SOUNDS_BASE, c as DRUM_KIT_BASE, G as GRACE_STEP, d as GlideLeg, e as INSTRUMENTS, L as Line, M as MEEND_HOLD, P as PlayEvent, f as SALAMANDER_BASE, g as SAMPLED_TAALS, h as ScheduleOptions, i as TABLA_BPMS, j as TABLA_VARIATIONS, k as TONEJS_INSTRUMENTS_BASE, l as ToneModule, m as buildSchedule, n as createBuffers, o as drumPattern, p as eventAt, q as glideTargets, r as graceTouches, s as instrumentSampleUrl, t as isArcRaw, u as meendContinuations, v as nearestSampleKey, w as nearestTablaBpm, x as normalizeBase, y as probeUrl, z as quantizeLoopEnd, B as santoorUrls, C as scheduleLines, E as subsetUrls, F as tablaBpms, H as tablaUrl, J as triggerGlide } from '../schedule-V-fgepvP.cjs';
4
+ import { I as InstrumentId, a as InstrumentDef, E as Excerpt, S as Schedule, D as DrumVoice, T as TempoSegment } from '../schedule-oJgg_bnc.cjs';
5
+ export { A as ARC_RAW_RE, b as DEFAULT_SOUNDS_BASE, c as DRUM_KIT_BASE, G as GRACE_STEP, d as GlideLeg, e as INSTRUMENTS, L as Line, f as LyricMap, M as MEEND_HOLD, P as PlayEvent, g as SALAMANDER_BASE, h as SAMPLED_TAALS, i as ScheduleOptions, j as TABLA_BPMS, k as TABLA_VARIATIONS, l as TONEJS_INSTRUMENTS_BASE, m as ToneModule, n as alignLyrics, o as buildSchedule, p as createBuffers, q as drumPattern, r as eventAt, s as glideTargets, t as graceTouches, u as instrumentSampleUrl, v as isArcRaw, w as meendContinuations, x as nearestSampleKey, y as nearestTablaBpm, z as normalizeBase, B as probeUrl, C as quantizeLoopEnd, F as santoorUrls, H as scheduleLines, J as subsetUrls, K as tablaBpms, N as tablaUrl, O as triggerGlide } from '../schedule-oJgg_bnc.cjs';
6
6
  import 'zod';
7
7
  import 'tone';
8
8
 
@@ -140,8 +140,12 @@ declare class SwaralipiPlayer {
140
140
  get loop(): LineRange | null;
141
141
  /** Whether each repeat is followed by a silent pass for the learner. */
142
142
  get echo(): boolean;
143
- /** Set the document to play. Stops any current playback. */
144
- load(doc: Swaralipi): void;
143
+ /** Set the document to play. Stops any current playback. With `excerpt`,
144
+ * only the notes singing those stretches of the song's text play, in order
145
+ * (see `alignLyrics`); the length, seeks and repeats all keep to them. */
146
+ load(doc: Swaralipi, { excerpt }?: {
147
+ excerpt?: Excerpt;
148
+ }): void;
145
149
  /**
146
150
  * Taal mode: loop one avartan of a taal's theka (rhythm only, no melody) —
147
151
  * for a standalone theka player. `play()` loops indefinitely (tabla loop /
@@ -417,4 +421,4 @@ declare function sampleFileName(midi: number): string;
417
421
  */
418
422
  declare function sCurve(x: number, steepness?: number): number;
419
423
 
420
- export { type AudioExportOptions, type AudioExportResult, type AudioFormat, type BindSheetOptions, DrumVoice, InstrumentDef, InstrumentId, LaySpeeds, type LineRange, type MidiExportOptions, type MidiExportResult, OCTAVE_OFFSET, type PlayerOptions, type PlayerState, type PracticeState, type RhythmMode, SHUDDHA, Schedule, SwaralipiPlayer, TempoSegment, encodeMidi, encodeMp3, encodeWav, exportAudio, exportMidi, midiToSampleName, parseTonic, sCurve, sampleFileName, svaraSemitone, svaraToMidi };
424
+ export { type AudioExportOptions, type AudioExportResult, type AudioFormat, type BindSheetOptions, DrumVoice, Excerpt, InstrumentDef, InstrumentId, LaySpeeds, type LineRange, type MidiExportOptions, type MidiExportResult, OCTAVE_OFFSET, type PlayerOptions, type PlayerState, type PracticeState, type RhythmMode, SHUDDHA, Schedule, SwaralipiPlayer, TempoSegment, encodeMidi, encodeMp3, encodeWav, exportAudio, exportMidi, midiToSampleName, parseTonic, sCurve, sampleFileName, svaraSemitone, svaraToMidi };
@@ -1,8 +1,8 @@
1
1
  import { S as Swaralipi, T as Taal, O as Octave, a as SvaraLetter, N as Note } from '../schema-DZag9qkF.js';
2
2
  import { a as LaySpeeds, T as TaalId } from '../lay-CWlEhImP.js';
3
3
  export { b as LAYS, c as LAY_SPEEDS, L as Lay, p as printedLay, r as resolveLaySpeeds, d as rowLay } from '../lay-CWlEhImP.js';
4
- import { I as InstrumentId, a as InstrumentDef, S as Schedule, D as DrumVoice, T as TempoSegment } from '../schedule-ClyON98C.js';
5
- export { A as ARC_RAW_RE, b as DEFAULT_SOUNDS_BASE, c as DRUM_KIT_BASE, G as GRACE_STEP, d as GlideLeg, e as INSTRUMENTS, L as Line, M as MEEND_HOLD, P as PlayEvent, f as SALAMANDER_BASE, g as SAMPLED_TAALS, h as ScheduleOptions, i as TABLA_BPMS, j as TABLA_VARIATIONS, k as TONEJS_INSTRUMENTS_BASE, l as ToneModule, m as buildSchedule, n as createBuffers, o as drumPattern, p as eventAt, q as glideTargets, r as graceTouches, s as instrumentSampleUrl, t as isArcRaw, u as meendContinuations, v as nearestSampleKey, w as nearestTablaBpm, x as normalizeBase, y as probeUrl, z as quantizeLoopEnd, B as santoorUrls, C as scheduleLines, E as subsetUrls, F as tablaBpms, H as tablaUrl, J as triggerGlide } from '../schedule-ClyON98C.js';
4
+ import { I as InstrumentId, a as InstrumentDef, E as Excerpt, S as Schedule, D as DrumVoice, T as TempoSegment } from '../schedule-DsVESieT.js';
5
+ export { A as ARC_RAW_RE, b as DEFAULT_SOUNDS_BASE, c as DRUM_KIT_BASE, G as GRACE_STEP, d as GlideLeg, e as INSTRUMENTS, L as Line, f as LyricMap, M as MEEND_HOLD, P as PlayEvent, g as SALAMANDER_BASE, h as SAMPLED_TAALS, i as ScheduleOptions, j as TABLA_BPMS, k as TABLA_VARIATIONS, l as TONEJS_INSTRUMENTS_BASE, m as ToneModule, n as alignLyrics, o as buildSchedule, p as createBuffers, q as drumPattern, r as eventAt, s as glideTargets, t as graceTouches, u as instrumentSampleUrl, v as isArcRaw, w as meendContinuations, x as nearestSampleKey, y as nearestTablaBpm, z as normalizeBase, B as probeUrl, C as quantizeLoopEnd, F as santoorUrls, H as scheduleLines, J as subsetUrls, K as tablaBpms, N as tablaUrl, O as triggerGlide } from '../schedule-DsVESieT.js';
6
6
  import 'zod';
7
7
  import 'tone';
8
8
 
@@ -140,8 +140,12 @@ declare class SwaralipiPlayer {
140
140
  get loop(): LineRange | null;
141
141
  /** Whether each repeat is followed by a silent pass for the learner. */
142
142
  get echo(): boolean;
143
- /** Set the document to play. Stops any current playback. */
144
- load(doc: Swaralipi): void;
143
+ /** Set the document to play. Stops any current playback. With `excerpt`,
144
+ * only the notes singing those stretches of the song's text play, in order
145
+ * (see `alignLyrics`); the length, seeks and repeats all keep to them. */
146
+ load(doc: Swaralipi, { excerpt }?: {
147
+ excerpt?: Excerpt;
148
+ }): void;
145
149
  /**
146
150
  * Taal mode: loop one avartan of a taal's theka (rhythm only, no melody) —
147
151
  * for a standalone theka player. `play()` loops indefinitely (tabla loop /
@@ -417,4 +421,4 @@ declare function sampleFileName(midi: number): string;
417
421
  */
418
422
  declare function sCurve(x: number, steepness?: number): number;
419
423
 
420
- export { type AudioExportOptions, type AudioExportResult, type AudioFormat, type BindSheetOptions, DrumVoice, InstrumentDef, InstrumentId, LaySpeeds, type LineRange, type MidiExportOptions, type MidiExportResult, OCTAVE_OFFSET, type PlayerOptions, type PlayerState, type PracticeState, type RhythmMode, SHUDDHA, Schedule, SwaralipiPlayer, TempoSegment, encodeMidi, encodeMp3, encodeWav, exportAudio, exportMidi, midiToSampleName, parseTonic, sCurve, sampleFileName, svaraSemitone, svaraToMidi };
424
+ export { type AudioExportOptions, type AudioExportResult, type AudioFormat, type BindSheetOptions, DrumVoice, Excerpt, InstrumentDef, InstrumentId, LaySpeeds, type LineRange, type MidiExportOptions, type MidiExportResult, OCTAVE_OFFSET, type PlayerOptions, type PlayerState, type PracticeState, type RhythmMode, SHUDDHA, Schedule, SwaralipiPlayer, TempoSegment, encodeMidi, encodeMp3, encodeWav, exportAudio, exportMidi, midiToSampleName, parseTonic, sCurve, sampleFileName, svaraSemitone, svaraToMidi };
@@ -1,5 +1,5 @@
1
- import { DEFAULT_SOUNDS_BASE, INSTRUMENTS, SAMPLED_TAALS, buildSchedule, eventAt, lineAt, byRow, lineFor, quantizeLoopEnd, instrumentSampleUrl, probeUrl, scheduleLines, GRACE_STEP, normalizeBase, nearestTablaBpm, tablaBpms, graceTouches, midiToSampleName, glideTargets, triggerGlide, createSampler, createBuffers, tablaShiftSemitones, tablaUrl, TABLA_GRAIN_OVERLAP_SEC, TABLA_GRAIN_SEC, createDrumKit, drumPattern, createMetronome, TANPURA_PCS, createTanpura, parseTonic, MEEND_HOLD, sCurve } from '../chunk-ZNJTMQIX.js';
2
- export { ARC_RAW_RE, DEFAULT_SOUNDS_BASE, DRUM_KIT_BASE, GRACE_STEP, INSTRUMENTS, MEEND_HOLD, OCTAVE_OFFSET, SALAMANDER_BASE, SAMPLED_TAALS, SHUDDHA, TABLA_BPMS, TABLA_VARIATIONS, TONEJS_INSTRUMENTS_BASE, buildSchedule, createBuffers, drumPattern, eventAt, glideTargets, graceTouches, instrumentSampleUrl, isArcRaw, meendContinuations, midiToSampleName, nearestSampleKey, nearestTablaBpm, normalizeBase, parseTonic, probeUrl, quantizeLoopEnd, sCurve, sampleFileName, santoorUrls, scheduleLines, subsetUrls, svaraSemitone, svaraToMidi, tablaBpms, tablaUrl, triggerGlide } from '../chunk-ZNJTMQIX.js';
1
+ import { DEFAULT_SOUNDS_BASE, INSTRUMENTS, SAMPLED_TAALS, buildSchedule, eventAt, lineAt, byRow, lineFor, quantizeLoopEnd, instrumentSampleUrl, probeUrl, scheduleLines, GRACE_STEP, normalizeBase, nearestTablaBpm, tablaBpms, graceTouches, midiToSampleName, glideTargets, triggerGlide, createSampler, createBuffers, tablaShiftSemitones, tablaUrl, TABLA_GRAIN_OVERLAP_SEC, TABLA_GRAIN_SEC, createDrumKit, drumPattern, createMetronome, TANPURA_PCS, createTanpura, parseTonic, MEEND_HOLD, sCurve } from '../chunk-YBFM5NLW.js';
2
+ export { ARC_RAW_RE, DEFAULT_SOUNDS_BASE, DRUM_KIT_BASE, GRACE_STEP, INSTRUMENTS, MEEND_HOLD, OCTAVE_OFFSET, SALAMANDER_BASE, SAMPLED_TAALS, SHUDDHA, TABLA_BPMS, TABLA_VARIATIONS, TONEJS_INSTRUMENTS_BASE, alignLyrics, buildSchedule, createBuffers, drumPattern, eventAt, glideTargets, graceTouches, instrumentSampleUrl, isArcRaw, meendContinuations, midiToSampleName, nearestSampleKey, nearestTablaBpm, normalizeBase, parseTonic, probeUrl, quantizeLoopEnd, sCurve, sampleFileName, santoorUrls, scheduleLines, subsetUrls, svaraSemitone, svaraToMidi, tablaBpms, tablaUrl, triggerGlide } from '../chunk-YBFM5NLW.js';
3
3
  import '../chunk-BSZ3WQUP.js';
4
4
  import { TAALS } from '../chunk-KOHSKHXI.js';
5
5
  export { LAYS, LAY_SPEEDS, printedLay, resolveLaySpeeds, rowLay } from '../chunk-KOHSKHXI.js';
@@ -45,6 +45,8 @@ var SwaralipiPlayer = class {
45
45
  /** Per-song setBpm tweak: beats meta.bpm but is cleared by the next load(). */
46
46
  #bpmTweak;
47
47
  #doc;
48
+ /** Play only these stretches of the song's text (see `load`). */
49
+ #excerpt;
48
50
  /** Taal mode (`loadTaal`): loops one avartan of this taal's theka with no
49
51
  * melody. Mutually exclusive with `#doc`. */
50
52
  #taal;
@@ -87,6 +89,8 @@ var SwaralipiPlayer = class {
87
89
  /** Listeners on the bound sheet, removed on rebind. */
88
90
  #unbind;
89
91
  #sheet;
92
+ /** The bound sheet's highlight — beside, never instead of, the consumer's `onHighlight`. */
93
+ #paint;
90
94
  /** Preview cap, counted in listening time so a seek or a loop can't dodge it. */
91
95
  #listened = 0;
92
96
  #listenedSince = 0;
@@ -177,10 +181,13 @@ var SwaralipiPlayer = class {
177
181
  /* ----------------------------------------------------------------- */
178
182
  /* Loading + transport control */
179
183
  /* ----------------------------------------------------------------- */
180
- /** Set the document to play. Stops any current playback. */
181
- load(doc) {
184
+ /** Set the document to play. Stops any current playback. With `excerpt`,
185
+ * only the notes singing those stretches of the song's text play, in order
186
+ * (see `alignLyrics`); the length, seeks and repeats all keep to them. */
187
+ load(doc, { excerpt } = {}) {
182
188
  this.#halt();
183
189
  this.#doc = doc;
190
+ this.#excerpt = excerpt;
184
191
  this.#taal = void 0;
185
192
  this.#taalOverride = void 0;
186
193
  this.#bpmTweak = void 0;
@@ -503,7 +510,7 @@ var SwaralipiPlayer = class {
503
510
  */
504
511
  bindSheet(target, opts = {}) {
505
512
  const block = opts.autoScroll === true ? "center" : opts.autoScroll || void 0;
506
- this.#opts.onHighlight = (path, yourTurn) => {
513
+ this.#paint = (path, yourTurn) => {
507
514
  target.clearHighlights();
508
515
  if (path === null) return;
509
516
  const el2 = target.highlight(path, yourTurn);
@@ -615,6 +622,7 @@ var SwaralipiPlayer = class {
615
622
  this.#opts.onState?.(state);
616
623
  }
617
624
  #emitHighlight(path, yourTurn = false) {
625
+ this.#paint?.(path, yourTurn);
618
626
  this.#opts.onHighlight?.(path, yourTurn);
619
627
  }
620
628
  #emitLoop() {
@@ -772,7 +780,8 @@ var SwaralipiPlayer = class {
772
780
  tonic: this.#opts.tonic,
773
781
  baseOctave: this.#opts.baseOctave,
774
782
  laySpeeds: this.#opts.laySpeeds,
775
- repeats: this.#opts.repeats
783
+ repeats: this.#opts.repeats,
784
+ excerpt: this.#excerpt
776
785
  };
777
786
  }
778
787
  /** Effective tempo: snapped to the taal's available tabla tempos while a