@tspro/web-music-score 4.2.1 → 5.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +63 -26
  3. package/dist/audio/index.d.mts +23 -27
  4. package/dist/audio/index.d.ts +23 -27
  5. package/dist/audio/index.js +63 -85
  6. package/dist/audio/index.mjs +53 -73
  7. package/dist/audio-cg/index.d.mts +18 -3
  8. package/dist/audio-cg/index.d.ts +18 -3
  9. package/dist/audio-cg/index.js +54 -51
  10. package/dist/audio-cg/index.mjs +49 -52
  11. package/dist/audio-synth/index.d.mts +15 -0
  12. package/dist/audio-synth/index.d.ts +15 -0
  13. package/dist/audio-synth/index.js +95 -0
  14. package/dist/audio-synth/index.mjs +58 -0
  15. package/dist/{chunk-64N22LCV.mjs → chunk-2EQHSQWO.mjs} +2 -2
  16. package/dist/{chunk-RQFFLRWF.mjs → chunk-QVYFIK3L.mjs} +5 -6
  17. package/dist/chunk-ROPTZBKD.mjs +11 -0
  18. package/dist/core/index.d.mts +2 -1
  19. package/dist/core/index.d.ts +2 -1
  20. package/dist/core/index.js +3 -2
  21. package/dist/core/index.mjs +4 -3
  22. package/dist/iife/audio-cg.global.js +220 -0
  23. package/dist/iife/index.global.js +11 -11
  24. package/dist/instrument-DYboobMW.d.mts +44 -0
  25. package/dist/instrument-DYboobMW.d.ts +44 -0
  26. package/dist/{music-objects-CI7IjsjE.d.ts → music-objects-CMdYZeC6.d.ts} +118 -36
  27. package/dist/{music-objects-3Hxlkxy6.d.mts → music-objects-DTDFSro0.d.mts} +118 -36
  28. package/dist/pieces/index.d.mts +1 -1
  29. package/dist/pieces/index.d.ts +1 -1
  30. package/dist/pieces/index.js +1 -1
  31. package/dist/pieces/index.mjs +2 -2
  32. package/dist/react-ui/index.d.mts +52 -33
  33. package/dist/react-ui/index.d.ts +52 -33
  34. package/dist/react-ui/index.js +41 -32
  35. package/dist/react-ui/index.mjs +42 -33
  36. package/dist/score/index.d.mts +8 -8
  37. package/dist/score/index.d.ts +8 -8
  38. package/dist/score/index.js +1998 -1626
  39. package/dist/score/index.mjs +1584 -1211
  40. package/dist/theory/index.js +3 -4
  41. package/dist/theory/index.mjs +3 -3
  42. package/package.json +13 -3
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Instrument interface.
3
+ * <p>To create your own instrument just create a class that implement this simple interface.</p>
4
+ *
5
+ * ```ts
6
+ * import * as Audio from "@tspro/web-music-score/audio";
7
+ *
8
+ * class MyCoolInstrument implements Audio.Instrument {
9
+ * constructor() { }
10
+ * getName() { return "My Cool Instrument"; }
11
+ * playNote(note: string, duration: number, linearVolume: number) { }
12
+ * stop() { }
13
+ * }
14
+ *
15
+ * // Add and use my cool instrument.
16
+ * Audio.addInstrument(new MyCoolInstrument());
17
+ * ```
18
+ */
19
+ interface Instrument {
20
+ /**
21
+ * Get instrument name.
22
+ * @return - Instrument name.
23
+ */
24
+ getName(): string;
25
+ /**
26
+ * Play a note.
27
+ * @param note - Note to play (e.g. "C4").
28
+ * @param duration - Play duration in seconds.
29
+ * @param linearVolume - Linear volume in range [0, 1].
30
+ */
31
+ playNote(note: string, duration: number, linearVolume: number): void;
32
+ /**
33
+ * Stop playback.
34
+ */
35
+ stop(): void;
36
+ }
37
+ /**
38
+ * Linear volume to decibels converter.
39
+ * @param linearVolume - Linear volume in range [0, 1].
40
+ * @returns - Volume in decibels.
41
+ */
42
+ declare function linearToDecibels(linearVolume: number): number;
43
+
44
+ export { type Instrument as I, linearToDecibels as l };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Instrument interface.
3
+ * <p>To create your own instrument just create a class that implement this simple interface.</p>
4
+ *
5
+ * ```ts
6
+ * import * as Audio from "@tspro/web-music-score/audio";
7
+ *
8
+ * class MyCoolInstrument implements Audio.Instrument {
9
+ * constructor() { }
10
+ * getName() { return "My Cool Instrument"; }
11
+ * playNote(note: string, duration: number, linearVolume: number) { }
12
+ * stop() { }
13
+ * }
14
+ *
15
+ * // Add and use my cool instrument.
16
+ * Audio.addInstrument(new MyCoolInstrument());
17
+ * ```
18
+ */
19
+ interface Instrument {
20
+ /**
21
+ * Get instrument name.
22
+ * @return - Instrument name.
23
+ */
24
+ getName(): string;
25
+ /**
26
+ * Play a note.
27
+ * @param note - Note to play (e.g. "C4").
28
+ * @param duration - Play duration in seconds.
29
+ * @param linearVolume - Linear volume in range [0, 1].
30
+ */
31
+ playNote(note: string, duration: number, linearVolume: number): void;
32
+ /**
33
+ * Stop playback.
34
+ */
35
+ stop(): void;
36
+ }
37
+ /**
38
+ * Linear volume to decibels converter.
39
+ * @param linearVolume - Linear volume in range [0, 1].
40
+ * @returns - Volume in decibels.
41
+ */
42
+ declare function linearToDecibels(linearVolume: number): number;
43
+
44
+ export { type Instrument as I, linearToDecibels as l };
@@ -225,34 +225,39 @@ declare enum Clef {
225
225
  /** F-clef (bass cleff) */
226
226
  F = "F"
227
227
  }
228
+ /** Base config for staff and tab configs. */
229
+ type BaseConfig = {
230
+ /** Name for this staff/tab config. */
231
+ name?: string;
232
+ /** Voice ids that are presented in this staff/tab. */
233
+ voiceIds?: number[];
234
+ };
228
235
  /** Staff config to add staff notation line in score configuration. */
229
- type StaffConfig = {
236
+ type StaffConfig = BaseConfig & {
230
237
  /** Config type, must be "staff" for staff config. */
231
238
  type: "staff";
232
239
  /** G-clef or F-clef for this staff config? */
233
240
  clef: Clef | `${Clef}`;
234
- /** Set name for this staff config. */
235
- name?: string;
236
241
  /** Set octave down with G-clef for guitar treble staff notation line. */
237
242
  isOctaveDown?: boolean;
238
243
  /** Lowest note (e.g. "C2")that can be presented in this staff notation line. */
239
244
  minNote?: string;
240
245
  /** Highest note (e.g. "C6") that can be presented in this staff notation line. */
241
246
  maxNote?: string;
242
- /** Voice ids that are presented in this staff notation line. */
243
- voiceIds?: number[];
244
- /** Set true for two staff configs with G-clef and F-clef to create grand staff. */
247
+ /**
248
+ * To create grand staff: use same `grandId` value (e.g. "grand1") for two
249
+ * consequtive staves, first having G-clef and second having F-clef.
250
+ */
251
+ grandId?: string;
252
+ /** @deprecated - Use `grandId` property instead. */
245
253
  isGrand?: boolean;
246
254
  };
247
255
  /** Tab config to add guitar tab in score configuration. */
248
- type TabConfig = {
256
+ type TabConfig = BaseConfig & {
249
257
  /** Config type, must be "tab" for tab config. */
250
258
  type: "tab";
251
- /** Set name for this tab config. */
252
- name?: string;
259
+ /** Tuning name or array six notes (tune for each string). */
253
260
  tuning?: string | string[];
254
- /** Voice ids that are presented in this guitar tab notation line. */
255
- voiceIds?: number[];
256
261
  };
257
262
  /** Score configuration. */
258
263
  type ScoreConfiguration = StaffConfig | TabConfig | (StaffConfig | TabConfig)[];
@@ -613,7 +618,6 @@ declare class ObjStaff extends ObjNotationLine {
613
618
  isLine(diatonicId: number): boolean;
614
619
  isSpace(diatonicId: number): boolean;
615
620
  containsVoiceId(voiceId: number): boolean;
616
- isGrand(): boolean;
617
621
  calcTop(): number;
618
622
  calcBottom(): number;
619
623
  pick(x: number, y: number): MusicObject[];
@@ -743,6 +747,9 @@ declare class ObjNoteGroup extends MusicObject {
743
747
  hasBeamCount(): boolean;
744
748
  getLeftBeamCount(): number;
745
749
  getRightBeamCount(): number;
750
+ setLeftBeamCount(count: number): void;
751
+ setRightBeamCount(count: number): void;
752
+ hasTuplet(): boolean;
746
753
  isEmpty(): boolean;
747
754
  visibleInStaff(staff: ObjStaff): boolean;
748
755
  getPlayTicks(note: Note): number;
@@ -752,8 +759,6 @@ declare class ObjNoteGroup extends MusicObject {
752
759
  setStemTipY(staff: ObjStaff, stemTipY: number): void;
753
760
  offset(dx: number, dy: number): void;
754
761
  draw(renderer: Renderer): void;
755
- static setBeamCounts(groupNotes: (ObjNoteGroup | undefined)[]): void;
756
- static setTupletBeamCounts(tuplet: ObjBeamGroup): void;
757
762
  getDotVerticalDisplacement(staff: ObjStaff, diatonicId: number, stemDir: Stem): 1 | 0 | -1;
758
763
  static hasSameNotes(ng1: ObjNoteGroup, ng2: ObjNoteGroup): boolean;
759
764
  }
@@ -805,6 +810,7 @@ declare class ObjBeamGroup extends MusicObject {
805
810
  pick(x: number, y: number): MusicObject[];
806
811
  getType(): BeamGroupType;
807
812
  isTuplet(): boolean;
813
+ getTupletRatioText(): string;
808
814
  getSymbols(): ReadonlyArray<RhythmSymbol>;
809
815
  getFirstSymbol(): RhythmSymbol | undefined;
810
816
  getLastSymbol(): RhythmSymbol | undefined;
@@ -814,6 +820,8 @@ declare class ObjBeamGroup extends MusicObject {
814
820
  updateStemTips(): void;
815
821
  offset(dx: number, dy: number): void;
816
822
  draw(renderer: Renderer): void;
823
+ private setBeamCounts;
824
+ private setTupletBeamCounts;
817
825
  }
818
826
 
819
827
  declare class ObjStaffRest extends MusicObject {
@@ -858,6 +866,7 @@ declare class ObjRest extends MusicObject {
858
866
  y: number;
859
867
  stemHeight: number;
860
868
  } | undefined)[];
869
+ hasTuplet(): boolean;
861
870
  isEmpty(): boolean;
862
871
  visibleInStaff(staff: ObjStaff): boolean;
863
872
  private getRestDotVerticalDisplacement;
@@ -1183,8 +1192,8 @@ declare class ObjMeasure extends MusicObject {
1183
1192
  addBeamGroup(beam: ObjBeamGroup): void;
1184
1193
  requestBeamsUpdate(): void;
1185
1194
  private createOldStyleTriplets;
1195
+ getBeamGroups(): ReadonlyArray<ObjBeamGroup>;
1186
1196
  createBeams(): void;
1187
- private static setupBeamGroup;
1188
1197
  getBarLineLeft(): ObjBarLineLeft;
1189
1198
  getBarLineRight(): ObjBarLineRight;
1190
1199
  getVoiceSymbols(voiceId: VoiceId): ReadonlyArray<RhythmSymbol>;
@@ -1243,7 +1252,7 @@ declare class ObjScoreRow extends MusicObject {
1243
1252
  layoutWidth(renderer: Renderer, width: number): void;
1244
1253
  updateRect(): void;
1245
1254
  alignStemsToBeams(): void;
1246
- layoutPositionLines(renderer: Renderer): void;
1255
+ layoutSetNotationLines(renderer: Renderer): void;
1247
1256
  layoutPadding(renderer: Renderer): void;
1248
1257
  layoutDone(): void;
1249
1258
  offset(dx: number, dy: number): void;
@@ -1364,6 +1373,9 @@ declare class Renderer {
1364
1373
  drawLine(startX: number, startY: number, endX: number, endY: number, color?: string, lineWidth?: number): void;
1365
1374
  drawPartialLine(startX: number, startY: number, endX: number, endY: number, startT: number, endT: number, color?: string, lineWidth?: number): void;
1366
1375
  drawLedgerLines(staff: ObjStaff, diatonicId: number, x: number): void;
1376
+ getRestRect(restSize: number): DivRect;
1377
+ drawRest(restSize: number, x: number, y: number, color: string): void;
1378
+ drawFlag(rect: DivRect, dir: "up" | "down"): void;
1367
1379
  }
1368
1380
 
1369
1381
  declare class ObjEnding extends MusicObject {
@@ -1458,23 +1470,40 @@ declare class ObjExtensionLine extends MusicObject {
1458
1470
  draw(renderer: Renderer): void;
1459
1471
  }
1460
1472
 
1473
+ declare class ObjTabRhythm extends MusicObject {
1474
+ readonly measure: ObjMeasure;
1475
+ readonly tab: ObjTab;
1476
+ private readonly voiceIds;
1477
+ readonly mi: MTabRhythm;
1478
+ constructor(measure: ObjMeasure, tab: ObjTab);
1479
+ getMusicInterface(): MTabRhythm;
1480
+ pick(x: number, y: number): MusicObject[];
1481
+ layout(renderer: Renderer): void;
1482
+ private hasTuplets;
1483
+ layoutFitToMeasure(renderer: Renderer): void;
1484
+ offset(dx: number, dy: number): void;
1485
+ private readonly tupletPartsTextObjMap;
1486
+ draw(renderer: Renderer): void;
1487
+ }
1488
+
1461
1489
  declare enum LayoutGroupId {
1462
- Fermata = 0,
1463
- NoteLabel = 1,
1464
- Navigation = 2,
1465
- Ending = 3,
1466
- TempoAnnotation = 4,
1467
- DynamicsAnnotation = 5,
1468
- ChordLabel = 6,
1469
- LyricsVerse1 = 7,
1470
- LyricsVerse2 = 8,
1471
- LyricsVerse3 = 9
1490
+ TabRhythm = 0,
1491
+ Fermata = 1,
1492
+ NoteLabel = 2,
1493
+ Navigation = 3,
1494
+ Ending = 4,
1495
+ TempoAnnotation = 5,
1496
+ DynamicsAnnotation = 6,
1497
+ ChordLabel = 7,
1498
+ LyricsVerse1 = 8,
1499
+ LyricsVerse2 = 9,
1500
+ LyricsVerse3 = 10
1472
1501
  }
1473
1502
  declare enum VerticalPos {
1474
1503
  Above = 0,
1475
1504
  Below = 1
1476
1505
  }
1477
- type LayoutableMusicObject = ObjText | ObjSpecialText | ObjExtensionLine | ObjFermata | ObjEnding | ObjLyrics;
1506
+ type LayoutableMusicObject = ObjText | ObjSpecialText | ObjExtensionLine | ObjFermata | ObjEnding | ObjLyrics | ObjTabRhythm;
1478
1507
  declare class StaffGroup {
1479
1508
  readonly groupName: string;
1480
1509
  readonly staffsTabsAndGroups: number | string | (number | string)[];
@@ -1605,7 +1634,7 @@ declare class ObjImage extends MusicObject {
1605
1634
  draw(renderer: Renderer): void;
1606
1635
  }
1607
1636
 
1608
- declare class ObjSignature extends MusicObject {
1637
+ declare class ObjStaffSignature extends MusicObject {
1609
1638
  readonly measure: ObjMeasure;
1610
1639
  readonly staff: ObjStaff;
1611
1640
  private clefImage?;
@@ -1616,9 +1645,9 @@ declare class ObjSignature extends MusicObject {
1616
1645
  private beatCountText?;
1617
1646
  private beatSizeText?;
1618
1647
  private tempoText?;
1619
- readonly mi: MSignature;
1648
+ readonly mi: MStaffSignature;
1620
1649
  constructor(measure: ObjMeasure, staff: ObjStaff);
1621
- getMusicInterface(): MSignature;
1650
+ getMusicInterface(): MStaffSignature;
1622
1651
  updateClefImage(renderer: Renderer, showClef: boolean): void;
1623
1652
  updateMeasureNumber(showMeasureNumber: boolean): void;
1624
1653
  updateKeySignature(showKeySignature: boolean): void;
@@ -1630,6 +1659,24 @@ declare class ObjSignature extends MusicObject {
1630
1659
  offset(dx: number, dy: number): void;
1631
1660
  draw(renderer: Renderer): void;
1632
1661
  }
1662
+ declare class ObjTabSignature extends MusicObject {
1663
+ readonly measure: ObjMeasure;
1664
+ readonly tab: ObjTab;
1665
+ private measureNumber?;
1666
+ private beatCountText?;
1667
+ private beatSizeText?;
1668
+ private tempoText?;
1669
+ readonly mi: MTabSignature;
1670
+ constructor(measure: ObjMeasure, tab: ObjTab);
1671
+ getMusicInterface(): MTabSignature;
1672
+ updateMeasureNumber(showMeasureNumber: boolean): void;
1673
+ updateTimeSignature(showTimeSignature: boolean): void;
1674
+ updateTempo(showTempo: boolean): void;
1675
+ pick(x: number, y: number): MusicObject[];
1676
+ layout(renderer: Renderer): void;
1677
+ offset(dx: number, dy: number): void;
1678
+ draw(renderer: Renderer): void;
1679
+ }
1633
1680
 
1634
1681
  /** Score event type. */
1635
1682
  type ScoreEventType = "enter" | "leave" | "click";
@@ -2321,21 +2368,56 @@ declare class MTab extends MusicInterface {
2321
2368
  */
2322
2369
  getRow(): MScoreRow;
2323
2370
  }
2324
- /** Signature object contains clef, key signature, time signature and tempo, all optional depending on measure. */
2325
- declare class MSignature extends MusicInterface {
2371
+ /** Staff signature object contains clef, key signature, time signature, tempo and measure number, all optional depending on measure. */
2372
+ declare class MStaffSignature extends MusicInterface {
2326
2373
  private readonly obj;
2327
2374
  /** Object name. */
2328
- static readonly Name = "Signature";
2375
+ static readonly Name = "StaffSignature";
2329
2376
  /** @internal */
2330
- constructor(obj: ObjSignature);
2377
+ constructor(obj: ObjStaffSignature);
2331
2378
  /** @internal */
2332
- getMusicObject(): ObjSignature;
2379
+ getMusicObject(): ObjStaffSignature;
2333
2380
  /**
2334
2381
  * Get staff notation line this signature is in.
2335
2382
  * @returns - Staff object.
2336
2383
  */
2337
2384
  getStaff(): MStaff;
2338
2385
  }
2386
+ /** Tab signature object contains time signature, tempo and measure number, all optional depending on measure. */
2387
+ declare class MTabSignature extends MusicInterface {
2388
+ private readonly obj;
2389
+ /** Object name. */
2390
+ static readonly Name = "TabSignature";
2391
+ /** @internal */
2392
+ constructor(obj: ObjTabSignature);
2393
+ /** @internal */
2394
+ getMusicObject(): ObjTabSignature;
2395
+ /**
2396
+ * Get tab notation line this signature is in.
2397
+ * @returns - Tab object.
2398
+ */
2399
+ getTab(): MTab;
2400
+ }
2401
+ /** Tab rhythm object. */
2402
+ declare class MTabRhythm extends MusicInterface {
2403
+ private readonly obj;
2404
+ /** Object name. */
2405
+ static readonly Name = "TabRhythm";
2406
+ /** @internal */
2407
+ constructor(obj: ObjTabRhythm);
2408
+ /** @internal */
2409
+ getMusicObject(): ObjTabRhythm;
2410
+ /**
2411
+ * Get measure.
2412
+ * @returns - Measure.
2413
+ */
2414
+ getMeasure(): MMeasure;
2415
+ /**
2416
+ * Get tab.
2417
+ * @returns - Tab.
2418
+ */
2419
+ getTab(): MTab;
2420
+ }
2339
2421
  /** Spacial text object contains text and possibly special symbols (e.g. Segno or Coda). */
2340
2422
  declare class MSpecialText extends MusicInterface {
2341
2423
  private readonly obj;
@@ -2392,4 +2474,4 @@ declare class MExtensionLine extends MusicInterface {
2392
2474
  getMusicObject(): ObjExtensionLine;
2393
2475
  }
2394
2476
 
2395
- export { MText as $, type AnnotationText as A, MImage as B, Connective as C, DivRect as D, MMeasure as E, Fermata as F, MBarLineRight as G, MBarLineLeft as H, MStaffTabBarLine as I, MNoteGroup as J, MStaffNoteGroup as K, type LyricsOptions as L, MDocument as M, type NoteOptions as N, MTabNoteGroup as O, MRest as P, MStaffRest as Q, type RestOptions as R, StaffPreset as S, type TupletOptions as T, MRhythmColumn as U, type VoiceId as V, MScoreRow as W, MStaff as X, MTab as Y, MSignature as Z, MSpecialText as _, type ScoreConfiguration as a, MLyrics as a0, MExtensionLine as a1, Clef as a2, type StaffConfig as a3, type TabConfig as a4, getVoiceIds as a5, type StringNumber as a6, getStringNumbers as a7, getVerseNumbers as a8, Stem as a9, Arpeggio as aa, type StaffTabOrGroup as ab, LyricsAlign as ac, LyricsHyphen as ad, DynamicsAnnotation as ae, TempoAnnotation as af, PlayState as ag, type PlayStateChangeListener as ah, type VerseNumber as b, type StaffTabOrGroups as c, Navigation as d, Annotation as e, Label as f, TieType as g, NoteAnchor as h, VerticalPosition as i, type ScoreEventType as j, ScoreEvent as k, ScoreStaffPosEvent as l, ScoreObjectEvent as m, type ScoreEventListener as n, MPlayer as o, MRenderer as p, MPlaybackButtons as q, MusicInterface as r, MAccidental as s, MConnective as t, MArpeggio as u, MBeamGroup as v, MStaffBeamGroup as w, MEnding as x, MFermata as y, MHeader as z };
2477
+ export { MTabRhythm as $, type AnnotationText as A, MImage as B, Connective as C, DivRect as D, MMeasure as E, Fermata as F, MBarLineRight as G, MBarLineLeft as H, MStaffTabBarLine as I, MNoteGroup as J, MStaffNoteGroup as K, type LyricsOptions as L, MDocument as M, type NoteOptions as N, MTabNoteGroup as O, MRest as P, MStaffRest as Q, type RestOptions as R, StaffPreset as S, type TupletOptions as T, MRhythmColumn as U, type VoiceId as V, MScoreRow as W, MStaff as X, MTab as Y, MStaffSignature as Z, MTabSignature as _, type ScoreConfiguration as a, MSpecialText as a0, MText as a1, MLyrics as a2, MExtensionLine as a3, Clef as a4, type BaseConfig as a5, type StaffConfig as a6, type TabConfig as a7, getVoiceIds as a8, type StringNumber as a9, getStringNumbers as aa, getVerseNumbers as ab, Stem as ac, Arpeggio as ad, type StaffTabOrGroup as ae, LyricsAlign as af, LyricsHyphen as ag, DynamicsAnnotation as ah, TempoAnnotation as ai, PlayState as aj, type PlayStateChangeListener as ak, type VerseNumber as b, type StaffTabOrGroups as c, Navigation as d, Annotation as e, Label as f, TieType as g, NoteAnchor as h, VerticalPosition as i, type ScoreEventType as j, ScoreEvent as k, ScoreStaffPosEvent as l, ScoreObjectEvent as m, type ScoreEventListener as n, MPlayer as o, MRenderer as p, MPlaybackButtons as q, MusicInterface as r, MAccidental as s, MConnective as t, MArpeggio as u, MBeamGroup as v, MStaffBeamGroup as w, MEnding as x, MFermata as y, MHeader as z };
@@ -225,34 +225,39 @@ declare enum Clef {
225
225
  /** F-clef (bass cleff) */
226
226
  F = "F"
227
227
  }
228
+ /** Base config for staff and tab configs. */
229
+ type BaseConfig = {
230
+ /** Name for this staff/tab config. */
231
+ name?: string;
232
+ /** Voice ids that are presented in this staff/tab. */
233
+ voiceIds?: number[];
234
+ };
228
235
  /** Staff config to add staff notation line in score configuration. */
229
- type StaffConfig = {
236
+ type StaffConfig = BaseConfig & {
230
237
  /** Config type, must be "staff" for staff config. */
231
238
  type: "staff";
232
239
  /** G-clef or F-clef for this staff config? */
233
240
  clef: Clef | `${Clef}`;
234
- /** Set name for this staff config. */
235
- name?: string;
236
241
  /** Set octave down with G-clef for guitar treble staff notation line. */
237
242
  isOctaveDown?: boolean;
238
243
  /** Lowest note (e.g. "C2")that can be presented in this staff notation line. */
239
244
  minNote?: string;
240
245
  /** Highest note (e.g. "C6") that can be presented in this staff notation line. */
241
246
  maxNote?: string;
242
- /** Voice ids that are presented in this staff notation line. */
243
- voiceIds?: number[];
244
- /** Set true for two staff configs with G-clef and F-clef to create grand staff. */
247
+ /**
248
+ * To create grand staff: use same `grandId` value (e.g. "grand1") for two
249
+ * consequtive staves, first having G-clef and second having F-clef.
250
+ */
251
+ grandId?: string;
252
+ /** @deprecated - Use `grandId` property instead. */
245
253
  isGrand?: boolean;
246
254
  };
247
255
  /** Tab config to add guitar tab in score configuration. */
248
- type TabConfig = {
256
+ type TabConfig = BaseConfig & {
249
257
  /** Config type, must be "tab" for tab config. */
250
258
  type: "tab";
251
- /** Set name for this tab config. */
252
- name?: string;
259
+ /** Tuning name or array six notes (tune for each string). */
253
260
  tuning?: string | string[];
254
- /** Voice ids that are presented in this guitar tab notation line. */
255
- voiceIds?: number[];
256
261
  };
257
262
  /** Score configuration. */
258
263
  type ScoreConfiguration = StaffConfig | TabConfig | (StaffConfig | TabConfig)[];
@@ -613,7 +618,6 @@ declare class ObjStaff extends ObjNotationLine {
613
618
  isLine(diatonicId: number): boolean;
614
619
  isSpace(diatonicId: number): boolean;
615
620
  containsVoiceId(voiceId: number): boolean;
616
- isGrand(): boolean;
617
621
  calcTop(): number;
618
622
  calcBottom(): number;
619
623
  pick(x: number, y: number): MusicObject[];
@@ -743,6 +747,9 @@ declare class ObjNoteGroup extends MusicObject {
743
747
  hasBeamCount(): boolean;
744
748
  getLeftBeamCount(): number;
745
749
  getRightBeamCount(): number;
750
+ setLeftBeamCount(count: number): void;
751
+ setRightBeamCount(count: number): void;
752
+ hasTuplet(): boolean;
746
753
  isEmpty(): boolean;
747
754
  visibleInStaff(staff: ObjStaff): boolean;
748
755
  getPlayTicks(note: Note): number;
@@ -752,8 +759,6 @@ declare class ObjNoteGroup extends MusicObject {
752
759
  setStemTipY(staff: ObjStaff, stemTipY: number): void;
753
760
  offset(dx: number, dy: number): void;
754
761
  draw(renderer: Renderer): void;
755
- static setBeamCounts(groupNotes: (ObjNoteGroup | undefined)[]): void;
756
- static setTupletBeamCounts(tuplet: ObjBeamGroup): void;
757
762
  getDotVerticalDisplacement(staff: ObjStaff, diatonicId: number, stemDir: Stem): 1 | 0 | -1;
758
763
  static hasSameNotes(ng1: ObjNoteGroup, ng2: ObjNoteGroup): boolean;
759
764
  }
@@ -805,6 +810,7 @@ declare class ObjBeamGroup extends MusicObject {
805
810
  pick(x: number, y: number): MusicObject[];
806
811
  getType(): BeamGroupType;
807
812
  isTuplet(): boolean;
813
+ getTupletRatioText(): string;
808
814
  getSymbols(): ReadonlyArray<RhythmSymbol>;
809
815
  getFirstSymbol(): RhythmSymbol | undefined;
810
816
  getLastSymbol(): RhythmSymbol | undefined;
@@ -814,6 +820,8 @@ declare class ObjBeamGroup extends MusicObject {
814
820
  updateStemTips(): void;
815
821
  offset(dx: number, dy: number): void;
816
822
  draw(renderer: Renderer): void;
823
+ private setBeamCounts;
824
+ private setTupletBeamCounts;
817
825
  }
818
826
 
819
827
  declare class ObjStaffRest extends MusicObject {
@@ -858,6 +866,7 @@ declare class ObjRest extends MusicObject {
858
866
  y: number;
859
867
  stemHeight: number;
860
868
  } | undefined)[];
869
+ hasTuplet(): boolean;
861
870
  isEmpty(): boolean;
862
871
  visibleInStaff(staff: ObjStaff): boolean;
863
872
  private getRestDotVerticalDisplacement;
@@ -1183,8 +1192,8 @@ declare class ObjMeasure extends MusicObject {
1183
1192
  addBeamGroup(beam: ObjBeamGroup): void;
1184
1193
  requestBeamsUpdate(): void;
1185
1194
  private createOldStyleTriplets;
1195
+ getBeamGroups(): ReadonlyArray<ObjBeamGroup>;
1186
1196
  createBeams(): void;
1187
- private static setupBeamGroup;
1188
1197
  getBarLineLeft(): ObjBarLineLeft;
1189
1198
  getBarLineRight(): ObjBarLineRight;
1190
1199
  getVoiceSymbols(voiceId: VoiceId): ReadonlyArray<RhythmSymbol>;
@@ -1243,7 +1252,7 @@ declare class ObjScoreRow extends MusicObject {
1243
1252
  layoutWidth(renderer: Renderer, width: number): void;
1244
1253
  updateRect(): void;
1245
1254
  alignStemsToBeams(): void;
1246
- layoutPositionLines(renderer: Renderer): void;
1255
+ layoutSetNotationLines(renderer: Renderer): void;
1247
1256
  layoutPadding(renderer: Renderer): void;
1248
1257
  layoutDone(): void;
1249
1258
  offset(dx: number, dy: number): void;
@@ -1364,6 +1373,9 @@ declare class Renderer {
1364
1373
  drawLine(startX: number, startY: number, endX: number, endY: number, color?: string, lineWidth?: number): void;
1365
1374
  drawPartialLine(startX: number, startY: number, endX: number, endY: number, startT: number, endT: number, color?: string, lineWidth?: number): void;
1366
1375
  drawLedgerLines(staff: ObjStaff, diatonicId: number, x: number): void;
1376
+ getRestRect(restSize: number): DivRect;
1377
+ drawRest(restSize: number, x: number, y: number, color: string): void;
1378
+ drawFlag(rect: DivRect, dir: "up" | "down"): void;
1367
1379
  }
1368
1380
 
1369
1381
  declare class ObjEnding extends MusicObject {
@@ -1458,23 +1470,40 @@ declare class ObjExtensionLine extends MusicObject {
1458
1470
  draw(renderer: Renderer): void;
1459
1471
  }
1460
1472
 
1473
+ declare class ObjTabRhythm extends MusicObject {
1474
+ readonly measure: ObjMeasure;
1475
+ readonly tab: ObjTab;
1476
+ private readonly voiceIds;
1477
+ readonly mi: MTabRhythm;
1478
+ constructor(measure: ObjMeasure, tab: ObjTab);
1479
+ getMusicInterface(): MTabRhythm;
1480
+ pick(x: number, y: number): MusicObject[];
1481
+ layout(renderer: Renderer): void;
1482
+ private hasTuplets;
1483
+ layoutFitToMeasure(renderer: Renderer): void;
1484
+ offset(dx: number, dy: number): void;
1485
+ private readonly tupletPartsTextObjMap;
1486
+ draw(renderer: Renderer): void;
1487
+ }
1488
+
1461
1489
  declare enum LayoutGroupId {
1462
- Fermata = 0,
1463
- NoteLabel = 1,
1464
- Navigation = 2,
1465
- Ending = 3,
1466
- TempoAnnotation = 4,
1467
- DynamicsAnnotation = 5,
1468
- ChordLabel = 6,
1469
- LyricsVerse1 = 7,
1470
- LyricsVerse2 = 8,
1471
- LyricsVerse3 = 9
1490
+ TabRhythm = 0,
1491
+ Fermata = 1,
1492
+ NoteLabel = 2,
1493
+ Navigation = 3,
1494
+ Ending = 4,
1495
+ TempoAnnotation = 5,
1496
+ DynamicsAnnotation = 6,
1497
+ ChordLabel = 7,
1498
+ LyricsVerse1 = 8,
1499
+ LyricsVerse2 = 9,
1500
+ LyricsVerse3 = 10
1472
1501
  }
1473
1502
  declare enum VerticalPos {
1474
1503
  Above = 0,
1475
1504
  Below = 1
1476
1505
  }
1477
- type LayoutableMusicObject = ObjText | ObjSpecialText | ObjExtensionLine | ObjFermata | ObjEnding | ObjLyrics;
1506
+ type LayoutableMusicObject = ObjText | ObjSpecialText | ObjExtensionLine | ObjFermata | ObjEnding | ObjLyrics | ObjTabRhythm;
1478
1507
  declare class StaffGroup {
1479
1508
  readonly groupName: string;
1480
1509
  readonly staffsTabsAndGroups: number | string | (number | string)[];
@@ -1605,7 +1634,7 @@ declare class ObjImage extends MusicObject {
1605
1634
  draw(renderer: Renderer): void;
1606
1635
  }
1607
1636
 
1608
- declare class ObjSignature extends MusicObject {
1637
+ declare class ObjStaffSignature extends MusicObject {
1609
1638
  readonly measure: ObjMeasure;
1610
1639
  readonly staff: ObjStaff;
1611
1640
  private clefImage?;
@@ -1616,9 +1645,9 @@ declare class ObjSignature extends MusicObject {
1616
1645
  private beatCountText?;
1617
1646
  private beatSizeText?;
1618
1647
  private tempoText?;
1619
- readonly mi: MSignature;
1648
+ readonly mi: MStaffSignature;
1620
1649
  constructor(measure: ObjMeasure, staff: ObjStaff);
1621
- getMusicInterface(): MSignature;
1650
+ getMusicInterface(): MStaffSignature;
1622
1651
  updateClefImage(renderer: Renderer, showClef: boolean): void;
1623
1652
  updateMeasureNumber(showMeasureNumber: boolean): void;
1624
1653
  updateKeySignature(showKeySignature: boolean): void;
@@ -1630,6 +1659,24 @@ declare class ObjSignature extends MusicObject {
1630
1659
  offset(dx: number, dy: number): void;
1631
1660
  draw(renderer: Renderer): void;
1632
1661
  }
1662
+ declare class ObjTabSignature extends MusicObject {
1663
+ readonly measure: ObjMeasure;
1664
+ readonly tab: ObjTab;
1665
+ private measureNumber?;
1666
+ private beatCountText?;
1667
+ private beatSizeText?;
1668
+ private tempoText?;
1669
+ readonly mi: MTabSignature;
1670
+ constructor(measure: ObjMeasure, tab: ObjTab);
1671
+ getMusicInterface(): MTabSignature;
1672
+ updateMeasureNumber(showMeasureNumber: boolean): void;
1673
+ updateTimeSignature(showTimeSignature: boolean): void;
1674
+ updateTempo(showTempo: boolean): void;
1675
+ pick(x: number, y: number): MusicObject[];
1676
+ layout(renderer: Renderer): void;
1677
+ offset(dx: number, dy: number): void;
1678
+ draw(renderer: Renderer): void;
1679
+ }
1633
1680
 
1634
1681
  /** Score event type. */
1635
1682
  type ScoreEventType = "enter" | "leave" | "click";
@@ -2321,21 +2368,56 @@ declare class MTab extends MusicInterface {
2321
2368
  */
2322
2369
  getRow(): MScoreRow;
2323
2370
  }
2324
- /** Signature object contains clef, key signature, time signature and tempo, all optional depending on measure. */
2325
- declare class MSignature extends MusicInterface {
2371
+ /** Staff signature object contains clef, key signature, time signature, tempo and measure number, all optional depending on measure. */
2372
+ declare class MStaffSignature extends MusicInterface {
2326
2373
  private readonly obj;
2327
2374
  /** Object name. */
2328
- static readonly Name = "Signature";
2375
+ static readonly Name = "StaffSignature";
2329
2376
  /** @internal */
2330
- constructor(obj: ObjSignature);
2377
+ constructor(obj: ObjStaffSignature);
2331
2378
  /** @internal */
2332
- getMusicObject(): ObjSignature;
2379
+ getMusicObject(): ObjStaffSignature;
2333
2380
  /**
2334
2381
  * Get staff notation line this signature is in.
2335
2382
  * @returns - Staff object.
2336
2383
  */
2337
2384
  getStaff(): MStaff;
2338
2385
  }
2386
+ /** Tab signature object contains time signature, tempo and measure number, all optional depending on measure. */
2387
+ declare class MTabSignature extends MusicInterface {
2388
+ private readonly obj;
2389
+ /** Object name. */
2390
+ static readonly Name = "TabSignature";
2391
+ /** @internal */
2392
+ constructor(obj: ObjTabSignature);
2393
+ /** @internal */
2394
+ getMusicObject(): ObjTabSignature;
2395
+ /**
2396
+ * Get tab notation line this signature is in.
2397
+ * @returns - Tab object.
2398
+ */
2399
+ getTab(): MTab;
2400
+ }
2401
+ /** Tab rhythm object. */
2402
+ declare class MTabRhythm extends MusicInterface {
2403
+ private readonly obj;
2404
+ /** Object name. */
2405
+ static readonly Name = "TabRhythm";
2406
+ /** @internal */
2407
+ constructor(obj: ObjTabRhythm);
2408
+ /** @internal */
2409
+ getMusicObject(): ObjTabRhythm;
2410
+ /**
2411
+ * Get measure.
2412
+ * @returns - Measure.
2413
+ */
2414
+ getMeasure(): MMeasure;
2415
+ /**
2416
+ * Get tab.
2417
+ * @returns - Tab.
2418
+ */
2419
+ getTab(): MTab;
2420
+ }
2339
2421
  /** Spacial text object contains text and possibly special symbols (e.g. Segno or Coda). */
2340
2422
  declare class MSpecialText extends MusicInterface {
2341
2423
  private readonly obj;
@@ -2392,4 +2474,4 @@ declare class MExtensionLine extends MusicInterface {
2392
2474
  getMusicObject(): ObjExtensionLine;
2393
2475
  }
2394
2476
 
2395
- export { MText as $, type AnnotationText as A, MImage as B, Connective as C, DivRect as D, MMeasure as E, Fermata as F, MBarLineRight as G, MBarLineLeft as H, MStaffTabBarLine as I, MNoteGroup as J, MStaffNoteGroup as K, type LyricsOptions as L, MDocument as M, type NoteOptions as N, MTabNoteGroup as O, MRest as P, MStaffRest as Q, type RestOptions as R, StaffPreset as S, type TupletOptions as T, MRhythmColumn as U, type VoiceId as V, MScoreRow as W, MStaff as X, MTab as Y, MSignature as Z, MSpecialText as _, type ScoreConfiguration as a, MLyrics as a0, MExtensionLine as a1, Clef as a2, type StaffConfig as a3, type TabConfig as a4, getVoiceIds as a5, type StringNumber as a6, getStringNumbers as a7, getVerseNumbers as a8, Stem as a9, Arpeggio as aa, type StaffTabOrGroup as ab, LyricsAlign as ac, LyricsHyphen as ad, DynamicsAnnotation as ae, TempoAnnotation as af, PlayState as ag, type PlayStateChangeListener as ah, type VerseNumber as b, type StaffTabOrGroups as c, Navigation as d, Annotation as e, Label as f, TieType as g, NoteAnchor as h, VerticalPosition as i, type ScoreEventType as j, ScoreEvent as k, ScoreStaffPosEvent as l, ScoreObjectEvent as m, type ScoreEventListener as n, MPlayer as o, MRenderer as p, MPlaybackButtons as q, MusicInterface as r, MAccidental as s, MConnective as t, MArpeggio as u, MBeamGroup as v, MStaffBeamGroup as w, MEnding as x, MFermata as y, MHeader as z };
2477
+ export { MTabRhythm as $, type AnnotationText as A, MImage as B, Connective as C, DivRect as D, MMeasure as E, Fermata as F, MBarLineRight as G, MBarLineLeft as H, MStaffTabBarLine as I, MNoteGroup as J, MStaffNoteGroup as K, type LyricsOptions as L, MDocument as M, type NoteOptions as N, MTabNoteGroup as O, MRest as P, MStaffRest as Q, type RestOptions as R, StaffPreset as S, type TupletOptions as T, MRhythmColumn as U, type VoiceId as V, MScoreRow as W, MStaff as X, MTab as Y, MStaffSignature as Z, MTabSignature as _, type ScoreConfiguration as a, MSpecialText as a0, MText as a1, MLyrics as a2, MExtensionLine as a3, Clef as a4, type BaseConfig as a5, type StaffConfig as a6, type TabConfig as a7, getVoiceIds as a8, type StringNumber as a9, getStringNumbers as aa, getVerseNumbers as ab, Stem as ac, Arpeggio as ad, type StaffTabOrGroup as ae, LyricsAlign as af, LyricsHyphen as ag, DynamicsAnnotation as ah, TempoAnnotation as ai, PlayState as aj, type PlayStateChangeListener as ak, type VerseNumber as b, type StaffTabOrGroups as c, Navigation as d, Annotation as e, Label as f, TieType as g, NoteAnchor as h, VerticalPosition as i, type ScoreEventType as j, ScoreEvent as k, ScoreStaffPosEvent as l, ScoreObjectEvent as m, type ScoreEventListener as n, MPlayer as o, MRenderer as p, MPlaybackButtons as q, MusicInterface as r, MAccidental as s, MConnective as t, MArpeggio as u, MBeamGroup as v, MStaffBeamGroup as w, MEnding as x, MFermata as y, MHeader as z };