@tspro/web-music-score 4.0.0 → 4.0.1

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 (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/audio/index.d.mts +40 -1
  4. package/dist/audio/index.d.ts +40 -1
  5. package/dist/audio/index.js +1 -1
  6. package/dist/audio/index.mjs +2 -2
  7. package/dist/audio-cg/index.d.mts +3 -0
  8. package/dist/audio-cg/index.d.ts +3 -0
  9. package/dist/audio-cg/index.js +1 -1
  10. package/dist/audio-cg/index.mjs +2 -2
  11. package/dist/{chunk-D643HZHM.mjs → chunk-YFPLOHP2.mjs} +2 -2
  12. package/dist/core/index.d.mts +12 -0
  13. package/dist/core/index.d.ts +12 -0
  14. package/dist/core/index.js +3 -2
  15. package/dist/core/index.mjs +4 -3
  16. package/dist/guitar-CaZJDA05.d.ts +35 -0
  17. package/dist/guitar-DdexKdN6.d.mts +35 -0
  18. package/dist/iife/index.global.js +11 -11
  19. package/dist/{interface-XoKiryoV.d.mts → music-objects-DJQ4d2OA.d.mts} +549 -53
  20. package/dist/{interface-7k8qGG44.d.ts → music-objects-Dc3kR-XF.d.ts} +549 -53
  21. package/dist/note-eA2xPPiG.d.mts +294 -0
  22. package/dist/note-eA2xPPiG.d.ts +294 -0
  23. package/dist/pieces/index.d.mts +22 -3
  24. package/dist/pieces/index.d.ts +22 -3
  25. package/dist/pieces/index.js +5 -2
  26. package/dist/pieces/index.mjs +6 -3
  27. package/dist/react-ui/index.d.mts +166 -17
  28. package/dist/react-ui/index.d.ts +166 -17
  29. package/dist/react-ui/index.js +78 -1
  30. package/dist/react-ui/index.mjs +79 -2
  31. package/dist/scale-B2Icbetz.d.ts +230 -0
  32. package/dist/scale-BbDJTbrG.d.mts +230 -0
  33. package/dist/score/index.d.mts +299 -46
  34. package/dist/score/index.d.ts +299 -46
  35. package/dist/score/index.js +553 -76
  36. package/dist/score/index.mjs +550 -75
  37. package/dist/{tempo-BAYoZ_Li.d.mts → tempo-CtUhvJbr.d.mts} +187 -5
  38. package/dist/{tempo-r2sb6Ku2.d.ts → tempo-Dt8aHpol.d.ts} +187 -5
  39. package/dist/theory/index.d.mts +29 -13
  40. package/dist/theory/index.d.ts +29 -13
  41. package/dist/theory/index.js +369 -25
  42. package/dist/theory/index.mjs +370 -26
  43. package/package.json +1 -1
  44. package/dist/guitar-DggbM2UL.d.mts +0 -17
  45. package/dist/guitar-cNmE-EvH.d.ts +0 -17
  46. package/dist/note-BFa43I86.d.mts +0 -85
  47. package/dist/note-CcVdUFqS.d.ts +0 -85
  48. package/dist/scale-C2pCNxdE.d.mts +0 -75
  49. package/dist/scale-CvPbJvfN.d.ts +0 -75
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v4.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v4.0.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  "use strict";
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -132,8 +132,11 @@ var DiatonicToChromaticMap = [0, 2, 4, 5, 7, 9, 11];
132
132
  var NoteNameRegex = /^([A-G])((?:bb|𝄫|♭|b|#|♯|x|𝄪)?)?(-?\d+)?$/;
133
133
  var _Note = class _Note {
134
134
  constructor(arg, accidental, octave) {
135
+ /** Diatonic class */
135
136
  __publicField(this, "diatonicClass");
137
+ /** Accidental. */
136
138
  __publicField(this, "accidental");
139
+ /** Octave. */
137
140
  __publicField(this, "octave");
138
141
  if (typeof arg === "number" && typeof accidental === "number" && octave === void 0) {
139
142
  _Note.validateDiatonicId(arg);
@@ -152,21 +155,32 @@ var _Note = class _Note {
152
155
  throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid args: ${arg}, ${accidental}, ${octave}`);
153
156
  }
154
157
  }
158
+ /** Diatonic id getter. */
155
159
  get diatonicId() {
156
160
  return _Note.getDiatonicIdInOctave(this.diatonicClass, this.octave);
157
161
  }
162
+ /** Chromatic id getter. */
158
163
  get chromaticId() {
159
164
  return _Note.getChromaticIdInOctave(DiatonicToChromaticMap[this.diatonicClass] + this.accidental, this.octave);
160
165
  }
166
+ /** Midi number getter (implemented same as chromatic id). */
161
167
  get midiNumber() {
162
168
  return this.chromaticId;
163
169
  }
170
+ /** Chromatic class getter. */
164
171
  get chromaticClass() {
165
172
  return _Note.getChromaticClass(DiatonicToChromaticMap[this.diatonicClass] + this.accidental);
166
173
  }
174
+ /** Note letter getter. */
167
175
  get noteLetter() {
168
176
  return NoteLetters[this.diatonicClass];
169
177
  }
178
+ /**
179
+ * Format note to string presentation.
180
+ * @param pitchNotation - Pitchy notation.
181
+ * @param symbolSet - Symbol set.
182
+ * @returns - String presentation of note.
183
+ */
170
184
  format(pitchNotation, symbolSet) {
171
185
  let { noteLetter, octave } = this;
172
186
  let accidentalSymbol = _Note.getAccidentalSymbol(this.accidental, symbolSet);
@@ -180,11 +194,21 @@ var _Note = class _Note {
180
194
  return noteLetter + accidentalSymbol + octave;
181
195
  }
182
196
  }
197
+ /**
198
+ * Format note to string presentation without octave number.
199
+ * @param symbolSet - Symbol set.
200
+ * @returns - String presentation of note without octave number.
201
+ */
183
202
  formatOmitOctave(symbolSet) {
184
203
  let noteLetter = NoteLetters[this.diatonicClass];
185
204
  let accidental = _Note.getAccidentalSymbol(this.accidental, symbolSet);
186
205
  return noteLetter + accidental;
187
206
  }
207
+ /**
208
+ * Get note.
209
+ * @param noteName - Note name (e.g. "C4").
210
+ * @returns - Note.
211
+ */
188
212
  static getNote(noteName) {
189
213
  let note = this.noteByNameCache.get(noteName);
190
214
  if (note === void 0) {
@@ -200,6 +224,11 @@ var _Note = class _Note {
200
224
  }
201
225
  return note;
202
226
  }
227
+ /**
228
+ * Get chromatic note. There are number of alternatives, this function uses simple logic to choose one.
229
+ * @param chromaticId - Chromatic id.
230
+ * @returns - Note.
231
+ */
203
232
  static getChromaticNote(chromaticId) {
204
233
  let note = this.chromaticNoteCache.get(chromaticId);
205
234
  if (note === void 0) {
@@ -226,21 +255,54 @@ var _Note = class _Note {
226
255
  throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid arg: ${arg}`);
227
256
  }
228
257
  }
258
+ /**
259
+ * Get octave from diatonic id.
260
+ * @param diatonicId - Diatonic id.
261
+ * @returns - Octave.
262
+ */
229
263
  static getOctaveFromDiatonicId(diatonicId) {
230
264
  return Math.floor((diatonicId - C0_diatonicId) / 7);
231
265
  }
266
+ /**
267
+ * Get diatonic id in given octave (transposes diatonic id to given octave).
268
+ * @param diatonicId - Original diatonic id.
269
+ * @param octave - Octave.
270
+ * @returns - Transposed diatonic id.
271
+ */
232
272
  static getDiatonicIdInOctave(diatonicId, octave) {
233
273
  return _Note.getDiatonicClass(diatonicId) + octave * 7 + C0_diatonicId;
234
274
  }
275
+ /**
276
+ * Get chromatic class from chromatic id.
277
+ * @param chromaticId - Chromatic id.
278
+ * @returns - Chromatic class.
279
+ */
235
280
  static getChromaticClass(chromaticId) {
236
281
  return mod(chromaticId, 12);
237
282
  }
283
+ /**
284
+ * Get octave from chromatic id.
285
+ * @param chromaticId - Chromatic id.
286
+ * @returns - Octave.
287
+ */
238
288
  static getOctaveFromChromaticId(chromaticId) {
239
289
  return Math.floor((chromaticId - C0_chromaticId) / 12);
240
290
  }
291
+ /**
292
+ * Get chromatic id in given octave (transposes chromatic id to given octave).
293
+ * @param chromaticId - Original chromatic id.
294
+ * @param octave - Octave.
295
+ * @returns - Transpose chromatic id.
296
+ */
241
297
  static getChromaticIdInOctave(chromaticId, octave) {
242
298
  return _Note.getChromaticClass(chromaticId) + octave * 12 + C0_chromaticId;
243
299
  }
300
+ /**
301
+ * Test if given two notes are equal.
302
+ * @param a - Note a.
303
+ * @param b - Note b.
304
+ * @returns - True/false.
305
+ */
244
306
  static equals(a, b) {
245
307
  if (a == null && b == null) {
246
308
  return true;
@@ -250,6 +312,12 @@ var _Note = class _Note {
250
312
  return a === b || a.diatonicId === b.diatonicId && a.accidental === b.accidental;
251
313
  }
252
314
  }
315
+ /**
316
+ * Replace accidental symbols in given string to givn symbol set (ascii/unicode).
317
+ * @param str - String to replace.
318
+ * @param symbolSet - Symbol set.
319
+ * @returns - String with updated accidental symbols.
320
+ */
253
321
  static replaceAccidentalSymbols(str, symbolSet) {
254
322
  if (symbolSet === 1 /* Unicode */) {
255
323
  return str.replace("bb", "\u{1D12B}").replace("b", "\u266D").replace("#", "\u266F").replace("x", "\u{1D12A}");
@@ -257,9 +325,19 @@ var _Note = class _Note {
257
325
  return str.replace("\u{1D12B}", "bb").replace("\u266D", "b").replace("\u266F", "#").replace("\u{1D12A}", "x");
258
326
  }
259
327
  }
328
+ /**
329
+ * Test if given string is valid note name.
330
+ * @param noteName - Note name to validate.
331
+ * @returns - True/false.
332
+ */
260
333
  static isValidNoteName(noteName) {
261
334
  return NoteNameRegex.test(noteName);
262
335
  }
336
+ /**
337
+ * Parse note name string to note props.
338
+ * @param noteName - Note name to parse.
339
+ * @returns - Parsed note props or undefined if parsing error.
340
+ */
263
341
  static parseNote(noteName) {
264
342
  var _a;
265
343
  let m = NoteNameRegex.exec(noteName);
@@ -273,6 +351,12 @@ var _Note = class _Note {
273
351
  let octave = octaveStr ? _Note.validateOctave(+octaveStr) : void 0;
274
352
  return { noteLetter, accidental, octave };
275
353
  }
354
+ /**
355
+ * Get scientific note name from given note name.
356
+ * @param noteName - Note name.
357
+ * @param symbolSet - Symbol set (ascii/unicode) for scientific note name.
358
+ * @returns - Scientific note name.
359
+ */
276
360
  static getScientificNoteName(noteName, symbolSet) {
277
361
  let p = _Note.parseNote(noteName);
278
362
  if (!p) {
@@ -281,9 +365,20 @@ var _Note = class _Note {
281
365
  let { noteLetter, accidental, octave } = p;
282
366
  return noteLetter + _Note.getAccidentalSymbol(accidental, symbolSet) + (octave != null ? octave : "");
283
367
  }
368
+ /**
369
+ * Get symbol of given accidental in given symbol set (ascii/unicide).
370
+ * @param accidental - Accidental.
371
+ * @param symbolsSet - Symbol set.
372
+ * @returns - Accidental symbol or undefined (invalid accidental).
373
+ */
284
374
  static getAccidentalSymbol(accidental, symbolsSet) {
285
375
  return symbolsSet === 1 /* Unicode */ ? AccidentalUnicodeSymbolMap.get(accidental) : AccidentalAsciiSymbolMap.get(accidental);
286
376
  }
377
+ /**
378
+ * Get accidental value from given accidental symbol.
379
+ * @param accidentalSymbol - Accidental symbol (e.g. "#").
380
+ * @returns - Accidental vlaue.
381
+ */
287
382
  static getAccidental(accidentalSymbol) {
288
383
  let accidental = AccidentalMap.get(accidentalSymbol);
289
384
  if (accidental === void 0) {
@@ -291,15 +386,32 @@ var _Note = class _Note {
291
386
  }
292
387
  return accidental;
293
388
  }
389
+ /**
390
+ * Get note letter from given diatonic id.
391
+ * @param diatonicId - Diatonic id.
392
+ * @returns - Note letter.
393
+ */
294
394
  static getNoteLetter(diatonicId) {
295
395
  return NoteLetters[_Note.getDiatonicClass(diatonicId)];
296
396
  }
397
+ /**
398
+ * Find next lowest possible diatonic id that is above given bottom level.
399
+ * @param diatonicId - Diatonic id to begin with.
400
+ * @param bottomDiatonicId - Bottom diatonic id.
401
+ * @param addOctaveIfEqual - If true then add one octave if diatonic id would equal to bottom diatonic id.
402
+ * @returns - Diatonic id.
403
+ */
297
404
  static findNextDiatonicIdAbove(diatonicId, bottomDiatonicId, addOctaveIfEqual) {
298
405
  let diatonicClass = _Note.getDiatonicClass(diatonicId);
299
406
  let bottomDiatonicClass = _Note.getDiatonicClass(bottomDiatonicId);
300
407
  let addOctave = addOctaveIfEqual ? diatonicClass <= bottomDiatonicClass ? 1 : 0 : diatonicClass < bottomDiatonicClass ? 1 : 0;
301
408
  return _Note.getDiatonicIdInOctave(diatonicClass, _Note.getOctaveFromDiatonicId(bottomDiatonicId) + addOctave);
302
409
  }
410
+ /**
411
+ * Validate if given argument is diatonic id.
412
+ * @param diatonicId - Diatonic id to validate.
413
+ * @returns - Valid diatonic id or throws.
414
+ */
303
415
  static validateDiatonicId(diatonicId) {
304
416
  if (import_ts_utils_lib2.Utils.Is.isInteger(diatonicId)) {
305
417
  return diatonicId;
@@ -307,13 +419,23 @@ var _Note = class _Note {
307
419
  throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid diatonicId: ${diatonicId}`);
308
420
  }
309
421
  }
422
+ /**
423
+ * Validate if given argument is diatonic class.
424
+ * @param diatonicClass - Diatonic class to validate.
425
+ * @returns - Valid diatonic class or throws.
426
+ */
310
427
  static validateDiatonicClass(diatonicClass) {
311
- if (import_ts_utils_lib2.Utils.Is.isInteger(diatonicClass) && diatonicClass >= 0 && diatonicClass < 7) {
428
+ if (import_ts_utils_lib2.Utils.Is.isIntegerBetween(diatonicClass, 0, 6)) {
312
429
  return diatonicClass;
313
430
  } else {
314
431
  throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid diatonicClass: ${diatonicClass}`);
315
432
  }
316
433
  }
434
+ /**
435
+ * Validate if given argument is chromatic id.
436
+ * @param chromaticId - Chromatic id to validate.
437
+ * @returns - Valid chromatic id, or throws.
438
+ */
317
439
  static validateChromaticId(chromaticId) {
318
440
  if (import_ts_utils_lib2.Utils.Is.isInteger(chromaticId)) {
319
441
  return chromaticId;
@@ -321,20 +443,35 @@ var _Note = class _Note {
321
443
  throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid chromaticId: ${chromaticId}`);
322
444
  }
323
445
  }
446
+ /**
447
+ * Validate if given argument is chromatic class.
448
+ * @param chromaticClass - Chromatic class to validate.
449
+ * @returns - Valid chromatic class, or throws.
450
+ */
324
451
  static validatechromaticClass(chromaticClass) {
325
- if (import_ts_utils_lib2.Utils.Is.isInteger(chromaticClass) && chromaticClass >= 0 && chromaticClass < 12) {
452
+ if (import_ts_utils_lib2.Utils.Is.isIntegerBetween(chromaticClass, 0, 11)) {
326
453
  return chromaticClass;
327
454
  } else {
328
455
  throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid chromaticClass: ${chromaticClass}`);
329
456
  }
330
457
  }
331
- static validateNoteLetter(note) {
332
- if (NoteLetters.some((n) => n === note)) {
333
- return note;
458
+ /**
459
+ * Validate if given argument if note letter.
460
+ * @param noteLetter - Note letter to validate.
461
+ * @returns - Valid note letter or throws.
462
+ */
463
+ static validateNoteLetter(noteLetter) {
464
+ if (NoteLetters.some((n) => n === noteLetter)) {
465
+ return noteLetter;
334
466
  } else {
335
- throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid note: ${note}`);
467
+ throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid note: ${noteLetter}`);
336
468
  }
337
469
  }
470
+ /**
471
+ * Validate if given argument is octave.
472
+ * @param octave - Octave to validate.
473
+ * @returns - Valid octave or throws.
474
+ */
338
475
  static validateOctave(octave) {
339
476
  if (import_ts_utils_lib2.Utils.Is.isInteger(octave)) {
340
477
  return octave;
@@ -342,8 +479,13 @@ var _Note = class _Note {
342
479
  throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid octave: ${octave}`);
343
480
  }
344
481
  }
482
+ /**
483
+ * Validate if given argument is valid accidental.
484
+ * @param acc - Accidental to validate.
485
+ * @returns - Valid accidental or thorws.
486
+ */
345
487
  static validateAccidental(acc) {
346
- if (import_ts_utils_lib2.Utils.Is.isInteger(acc) && acc >= -2 && acc <= 2) {
488
+ if (import_ts_utils_lib2.Utils.Is.isIntegerBetween(acc, -2, 2)) {
347
489
  return acc;
348
490
  } else {
349
491
  throw new import_core2.MusicError(import_core2.MusicErrorType.Note, `Invalid accidental: ${acc}`);
@@ -371,6 +513,12 @@ var _Note = class _Note {
371
513
  });
372
514
  return uniqueSet;
373
515
  }
516
+ /**
517
+ * Function to compare two notes using diatonic id and accidental properties of notes.
518
+ * @param a - Note a.
519
+ * @param b - Note b.
520
+ * @returns - -1, 0 or 1.
521
+ */
374
522
  static compareFunc(a, b) {
375
523
  if (a.diatonicId < b.diatonicId) {
376
524
  return -1;
@@ -492,6 +640,10 @@ var _KeySignature = class _KeySignature {
492
640
  }
493
641
  this.orderedAccidentedNotes = flats.length > 0 ? flats : sharps;
494
642
  }
643
+ /**
644
+ * Get accidental type sharps, flats, or natural (without accidentals).
645
+ * @returns - Accidental type.
646
+ */
495
647
  getAccidentalType() {
496
648
  if (this.orderedAccidentedNotes.length === 0) {
497
649
  return 0 /* Natural */;
@@ -501,23 +653,40 @@ var _KeySignature = class _KeySignature {
501
653
  return 2 /* Sharps */;
502
654
  }
503
655
  }
656
+ /**
657
+ * Get natural scale notes of this key signature, natural scale has 7 steps (e.g. Major scale: W, W, H, W, W, W, H).
658
+ * @returns - Array of notes.
659
+ */
504
660
  getNaturalScaleNotes() {
505
661
  return this.naturalScaleNotes;
506
662
  }
663
+ /**
664
+ * Get accidental for given diatonic id.
665
+ * @param diatonicId - Diatonic id.
666
+ * @returns - Accidental -2, -1, 0, 1 or 2.
667
+ */
507
668
  getAccidental(diatonicId) {
508
669
  var _a;
509
670
  return (_a = this.accidentalByDiatonicClass[Note.getDiatonicClass(diatonicId)]) != null ? _a : 0;
510
671
  }
672
+ /**
673
+ * Get number of accidentals this key signature has.
674
+ * @returns - Number of accidentals.
675
+ */
511
676
  getNumAccidentals() {
512
677
  return this.orderedAccidentedNotes.length;
513
678
  }
679
+ /**
680
+ * Get accidental notes in correct order.
681
+ * @returns - Array of accidental notes.
682
+ */
514
683
  getOrderedAccidentalNotes() {
515
684
  return this.orderedAccidentedNotes;
516
685
  }
517
686
  /**
518
- *
519
- * @param degree - number 1..7 or string e.g "b5" or "#4"
520
- * @returns
687
+ * Get note of key signature by degree value.
688
+ * @param degree - Degree number in range [1, 7] or string e.g "b5" or "#4".
689
+ * @returns - Note.
521
690
  */
522
691
  getNoteByDegree(degree) {
523
692
  let { deg, acc } = parseDegree(degree);
@@ -528,6 +697,12 @@ var _KeySignature = class _KeySignature {
528
697
  return new Note(note.diatonicId, note.accidental + acc);
529
698
  }
530
699
  }
700
+ /**
701
+ * Test equality of given key signatures.
702
+ * @param a - Key signature a.
703
+ * @param b - Key signature b.
704
+ * @returns - True/false.
705
+ */
531
706
  static equals(a, b) {
532
707
  if (a == null && b == null) {
533
708
  return true;
@@ -665,9 +840,13 @@ var Interval = class _Interval {
665
840
  constructor(note1, note2) {
666
841
  this.note1 = note1;
667
842
  this.note2 = note2;
843
+ /** Interval direction. */
668
844
  __publicField(this, "direction");
845
+ /** Number of semitones. */
669
846
  __publicField(this, "semitones");
847
+ /** Interval quantity. */
670
848
  __publicField(this, "quantity");
849
+ /** Interval quality. */
671
850
  __publicField(this, "quality");
672
851
  if (note2.diatonicId >= note1.diatonicId) {
673
852
  this.direction = note2.diatonicId === note1.diatonicId ? "Unison" : "Ascending";
@@ -685,6 +864,12 @@ var Interval = class _Interval {
685
864
  throw new InvalidIntervalException("Unknown interval quality");
686
865
  }
687
866
  }
867
+ /**
868
+ * Get interval between given two notes.
869
+ * @param note1 - First note.
870
+ * @param note2 - Second note.
871
+ * @returns - Interval if valid, or undefined.
872
+ */
688
873
  static get(note1, note2) {
689
874
  try {
690
875
  return new _Interval(note1, note2);
@@ -696,12 +881,20 @@ var Interval = class _Interval {
696
881
  }
697
882
  }
698
883
  }
884
+ /**
885
+ * Get string presentation of interval (e.g. "Descending Major 2").
886
+ * @returns - Interval string.
887
+ */
699
888
  toString() {
700
889
  let direction = this.direction === "Unison" ? "" : this.direction + " ";
701
890
  let quality = this.quality + " ";
702
891
  let quantity = this.direction === "Unison" ? "Unison" : formatQuantity(this.quantity);
703
892
  return direction + quality + quantity;
704
893
  }
894
+ /**
895
+ * Get abbrevated string presentation of interval (e.g. "↓M2").
896
+ * @returns - Interval abbrevated string.
897
+ */
705
898
  toAbbrString() {
706
899
  var _a;
707
900
  let direction = this.direction === "Descending" ? "\u2193" : "";
@@ -796,12 +989,20 @@ function getMode(scaleType) {
796
989
  }
797
990
  }
798
991
  var Scale = class extends KeySignature {
992
+ /**
993
+ * Create nev scale object instance.
994
+ * @param tonic - Tonic (e.g. "C" in "C Major").
995
+ * @param scaleType - Scale typo ("e.g. "Major" in "C Major").
996
+ */
799
997
  constructor(tonic, scaleType) {
800
998
  super(tonic, getMode(scaleType));
801
999
  this.tonic = tonic;
802
1000
  this.scaleType = scaleType;
1001
+ /** Degrees of scale notes. */
803
1002
  __publicField(this, "scaleDegrees");
1003
+ /** Scale notes. */
804
1004
  __publicField(this, "scaleNotes");
1005
+ /** Degrees (or undefined) of chromatic classes. */
805
1006
  __publicField(this, "chromaticClassDegree");
806
1007
  __publicField(this, "preferredChromaticNoteCache", /* @__PURE__ */ new Map());
807
1008
  switch (scaleType) {
@@ -833,6 +1034,12 @@ var Scale = class extends KeySignature {
833
1034
  return id >= 0 ? this.scaleDegrees[id] : void 0;
834
1035
  });
835
1036
  }
1037
+ /**
1038
+ * Compare if two scales equals.
1039
+ * @param a - Scale a.
1040
+ * @param b - Scale b.
1041
+ * @returns - Boolean equality of given scales.
1042
+ */
836
1043
  static equals(a, b) {
837
1044
  if (a == null && b == null) {
838
1045
  return true;
@@ -842,6 +1049,11 @@ var Scale = class extends KeySignature {
842
1049
  return a === b || a.getScaleName() === b.getScaleName();
843
1050
  }
844
1051
  }
1052
+ /**
1053
+ * Get scale name.
1054
+ * @param symbolSet - Symbol set to format scale name in ascii or unicode.
1055
+ * @returns - Scale name string.
1056
+ */
845
1057
  getScaleName(symbolSet) {
846
1058
  switch (symbolSet) {
847
1059
  case 1 /* Unicode */:
@@ -850,6 +1062,12 @@ var Scale = class extends KeySignature {
850
1062
  return this.tonic + " " + this.scaleType;
851
1063
  }
852
1064
  }
1065
+ /**
1066
+ * Get scale notes.
1067
+ * @param bottomNote - Computed scale notes begin no lower than this note.
1068
+ * @param numOctaves - How many octaves?
1069
+ * @returns - Array of scale notes.
1070
+ */
853
1071
  getScaleNotes(bottomNote, numOctaves) {
854
1072
  if (!import_ts_utils_lib5.Utils.Is.isIntegerGte(numOctaves, 1)) {
855
1073
  throw new import_core5.MusicError(import_core5.MusicErrorType.Scale, `Invalid numOctaves: ${numOctaves}`);
@@ -865,9 +1083,17 @@ var Scale = class extends KeySignature {
865
1083
  return new Note(diatonicId, note.accidental);
866
1084
  });
867
1085
  }
1086
+ /**
1087
+ * Get scale overview (e.g. "C - D - E - F - G - A - B" for "C Major" scale).
1088
+ * @returns - Scale overview string.
1089
+ */
868
1090
  getScaleOverview() {
869
1091
  return this.getScaleNotes("C4", 1).map((note) => note.formatOmitOctave(1 /* Unicode */)).join(" - ");
870
1092
  }
1093
+ /**
1094
+ * Get scale steps, array of 1 (half step) and 2 (whole step), (e.g. [2, 2, 1, 2, 2, 2, 1] for Major scale).
1095
+ * @returns - Array of scale steps.
1096
+ */
871
1097
  getScaleSteps() {
872
1098
  let chromaticIds = this.getScaleNotes("C4", 1).map((note) => note.chromaticId);
873
1099
  let steps = [];
@@ -876,15 +1102,34 @@ var Scale = class extends KeySignature {
876
1102
  }
877
1103
  return steps;
878
1104
  }
1105
+ /**
1106
+ * Get scale steps string presentation, array of "H" (half step) and "W" (whole step), (e.g. ["W", "W", "H", "W", "W", "W", "H"] for Major scale).
1107
+ * @returns - Array of scale steps string presentation.
1108
+ */
879
1109
  getScaleStringSteps() {
880
1110
  return this.getScaleSteps().map((step) => step === 1 ? "H" : step === 2 ? "W" : step.toString() + "H");
881
1111
  }
1112
+ /**
1113
+ * Test if given note is scale note.
1114
+ * @param note - Note to test.
1115
+ * @returns - True/false.
1116
+ */
882
1117
  isScaleNote(note) {
883
1118
  return this.chromaticClassDegree[note.chromaticClass] !== void 0;
884
1119
  }
1120
+ /**
1121
+ * Test if given note is scale root note.
1122
+ * @param note - Note to test.
1123
+ * @returns - True/false.
1124
+ */
885
1125
  isScaleRootNote(note) {
886
1126
  return String(this.chromaticClassDegree[note.chromaticClass]) === "1";
887
1127
  }
1128
+ /**
1129
+ * Get interval value between scale root note and given note.
1130
+ * @param note - Note.
1131
+ * @returns - Interval.
1132
+ */
888
1133
  getIntervalFromRootNote(note) {
889
1134
  let rootNote = this.getScaleNotes("C0", 1)[0];
890
1135
  while (note.chromaticId >= rootNote.chromaticId + 12) {
@@ -900,6 +1145,11 @@ var Scale = class extends KeySignature {
900
1145
  return interval;
901
1146
  }
902
1147
  }
1148
+ /**
1149
+ * Get preferred chromatic note from given chromatic id.
1150
+ * @param chromaticId - Chromatic id.
1151
+ * @returns - Note.
1152
+ */
903
1153
  getPreferredChromaticNote(chromaticId) {
904
1154
  Note.validateChromaticId(chromaticId);
905
1155
  let note = this.preferredChromaticNoteCache.get(chromaticId);
@@ -942,6 +1192,10 @@ var Scale = class extends KeySignature {
942
1192
  }
943
1193
  };
944
1194
  var ScaleFactory = class {
1195
+ /**
1196
+ * Create new scale factory object instance.
1197
+ * @param type - Scale type.
1198
+ */
945
1199
  constructor(type) {
946
1200
  this.type = type;
947
1201
  __publicField(this, "tonicList", []);
@@ -987,15 +1241,32 @@ var ScaleFactory = class {
987
1241
  ...flatScales.sort(SortByAccidentalCountFunc).map((scale) => scale.tonic)
988
1242
  ];
989
1243
  }
1244
+ /**
1245
+ * Get list of tonics (e.g. "C", "C#", ... for Major scale type).
1246
+ * @returns - Array of tonics.
1247
+ */
990
1248
  getTonicList() {
991
1249
  return this.tonicList;
992
1250
  }
1251
+ /**
1252
+ * Get default tonic.
1253
+ * @returns - Default tonic.
1254
+ */
993
1255
  getDefaultTonic() {
994
1256
  return this.tonicList[0];
995
1257
  }
1258
+ /**
1259
+ * Get scale type.
1260
+ * @returns - SCale type.
1261
+ */
996
1262
  getType() {
997
1263
  return this.type;
998
1264
  }
1265
+ /**
1266
+ * Get scale by given tonic.
1267
+ * @param tonic - Tonic (e.g. "C").
1268
+ * @returns - Scale.
1269
+ */
999
1270
  getScale(tonic) {
1000
1271
  let scale = this.scaleMap.get(tonic);
1001
1272
  if (!scale) {
@@ -1004,6 +1275,11 @@ var ScaleFactory = class {
1004
1275
  return scale;
1005
1276
  }
1006
1277
  }
1278
+ /**
1279
+ * Test if this scale factory has scale for given tonic value.
1280
+ * @param tonic - Tonic.
1281
+ * @returns - True/false.
1282
+ */
1007
1283
  hasScale(tonic) {
1008
1284
  return this.scaleMap.get(tonic) !== void 0;
1009
1285
  }
@@ -1168,9 +1444,13 @@ var Chord = class _Chord {
1168
1444
  constructor(chordInfo, chordNotes, rootNote, bassNote) {
1169
1445
  this.chordInfo = chordInfo;
1170
1446
  this.rootNote = rootNote;
1447
+ /** Chord name. */
1171
1448
  __publicField(this, "name");
1449
+ /** Notes of this chord. */
1172
1450
  __publicField(this, "notes");
1451
+ /** Notes that are omitted in this chord (partial chord). */
1173
1452
  __publicField(this, "omitNotes");
1453
+ /** Bass note if not chord root note (e.g. "B" in "C/B"). */
1174
1454
  __publicField(this, "slashBassNote");
1175
1455
  this.name = chordInfo.name;
1176
1456
  let notesLeft = chordNotes.slice();
@@ -1209,6 +1489,11 @@ var Chord = class _Chord {
1209
1489
  throw new InvalidChordException("Power chord no bass note allowed!");
1210
1490
  }
1211
1491
  }
1492
+ /**
1493
+ * Get all chords that can be made up with given notes.
1494
+ * @param notes - Array of notes.
1495
+ * @returns - Array of chords.
1496
+ */
1212
1497
  static getChords(notes) {
1213
1498
  let chords = [];
1214
1499
  let chordNotes = Note.sort(notes);
@@ -1248,7 +1533,8 @@ var Chord = class _Chord {
1248
1533
  return true;
1249
1534
  }
1250
1535
  /**
1251
- * @returns Chord name e.g. "C/B"
1536
+ * Get chord string presentation.
1537
+ * @returns Chord string presentation (e.g. "C/B").
1252
1538
  */
1253
1539
  toString() {
1254
1540
  let symbolSet = 1 /* Unicode */;
@@ -1257,7 +1543,8 @@ var Chord = class _Chord {
1257
1543
  return rootNoteStr + this.name + slashBassStr;
1258
1544
  }
1259
1545
  /**
1260
- * @returns Degree notation string, e.g. "E - 1(C) - 3(E) - 5(G)"
1546
+ * Get degree notation string (e.g. "E - 1(C) - 3(E) - 5(G)").
1547
+ * @returns Degree notation string.
1261
1548
  */
1262
1549
  getDegreeNotationString() {
1263
1550
  let symbolSet = 1 /* Unicode */;
@@ -1268,7 +1555,8 @@ var Chord = class _Chord {
1268
1555
  return bassNoteStr + degreeNoteStr;
1269
1556
  }
1270
1557
  /**
1271
- * @returns Omitted degrees string e.g. "Omits 5(G), 9(D)"
1558
+ * Get string presentation of omitted degrees (e.g. "Omits 5(G), 9(D)").
1559
+ * @returns - String presentation of omitted degrees.
1272
1560
  */
1273
1561
  getOmittedDegreesString() {
1274
1562
  let omittedStrList = this.omitNotes.map((omit, i) => {
@@ -1277,15 +1565,17 @@ var Chord = class _Chord {
1277
1565
  return omittedStrList.length > 0 ? "Omits " + omittedStrList.join(", ") : "";
1278
1566
  }
1279
1567
  /**
1280
- * @param i - Degree index
1281
- * @returns Degree string for given degree index, e.g. "3"
1568
+ * Degree index for given degree index (e.g. "3").
1569
+ * @param i - Chord degree index (e.g. 0 is first note degree of chord).
1570
+ * @returns Degree string.
1282
1571
  */
1283
1572
  getDegreeStr(i) {
1284
1573
  return Note.replaceAccidentalSymbols("" + this.chordInfo.degrees[i], 1 /* Unicode */);
1285
1574
  }
1286
1575
  /**
1287
- * @param i - Degree index
1288
- * @returns Note string for given degree index, e.g. "E"
1576
+ * Get note name for given degree index (e.g. "E").
1577
+ * @param i - Chord degree index (e.g. 0 is first note degree of chord).
1578
+ * @returns - Note name string.
1289
1579
  */
1290
1580
  getNoteStr(i) {
1291
1581
  return this.notes[i].formatOmitOctave(1 /* Unicode */);
@@ -1597,6 +1887,7 @@ var NoteLength = /* @__PURE__ */ ((NoteLength3) => {
1597
1887
  NoteLength3["Whole"] = "1n";
1598
1888
  NoteLength3["WholeTriplet"] = "1t";
1599
1889
  NoteLength3["WholeDot"] = "1.";
1890
+ NoteLength3["Whole2Dots"] = "1..";
1600
1891
  NoteLength3["Whole12Dots"] = "1..";
1601
1892
  NoteLength3["Whole3Dots"] = "1...";
1602
1893
  NoteLength3["Whole4Dots"] = "1....";
@@ -1639,17 +1930,24 @@ function validateNoteLength(noteLength) {
1639
1930
  }
1640
1931
  }
1641
1932
  var _NoteLengthProps = class _NoteLengthProps {
1642
- // Is solid (black) note head?
1643
1933
  constructor(noteLength) {
1934
+ /** Note length. */
1644
1935
  __publicField(this, "noteLength");
1936
+ /** Note size (whole=1, half=2, quarter=4, ...). */
1645
1937
  __publicField(this, "noteSize");
1938
+ /** Number of ticks (not altered by isTriplet). */
1646
1939
  __publicField(this, "ticks");
1647
- // Not altered by isTriplet!
1940
+ /** Flag count. */
1648
1941
  __publicField(this, "flagCount");
1942
+ /** Dot count. */
1649
1943
  __publicField(this, "dotCount");
1944
+ /** Max dot count. */
1650
1945
  __publicField(this, "maxDotCount");
1946
+ /** Is triplet? */
1651
1947
  __publicField(this, "isTriplet");
1948
+ /** Has note stem. */
1652
1949
  __publicField(this, "hasStem");
1950
+ /** Is note head solid (black)? */
1653
1951
  __publicField(this, "isSolid");
1654
1952
  this.noteLength = validateNoteLength(noteLength);
1655
1953
  this.noteSize = parseInt(noteLength);
@@ -1666,6 +1964,11 @@ var _NoteLengthProps = class _NoteLengthProps {
1666
1964
  throw new import_core8.MusicError(import_core8.MusicErrorType.Note, `noteLength "${this.noteLength}" is both triplet and dotted!`);
1667
1965
  }
1668
1966
  }
1967
+ /**
1968
+ * Get note length props.
1969
+ * @param noteLength - Note length.
1970
+ * @returns - Note length props.
1971
+ */
1669
1972
  static get(noteLength) {
1670
1973
  let p = this.cache.get(noteLength);
1671
1974
  if (!p) {
@@ -1673,6 +1976,12 @@ var _NoteLengthProps = class _NoteLengthProps {
1673
1976
  }
1674
1977
  return p;
1675
1978
  }
1979
+ /**
1980
+ * Create note length props.
1981
+ * @param noteLength - Note length or note size.
1982
+ * @param dotCount - Dot count.
1983
+ * @returns - Note length props.
1984
+ */
1676
1985
  static create(noteLength, dotCount = 0) {
1677
1986
  let noteSize = typeof noteLength === "number" ? noteLength : this.get(noteLength).noteSize;
1678
1987
  return this.get(noteSize + (import_ts_utils_lib8.Utils.Is.isIntegerGte(dotCount, 1) ? ".".repeat(dotCount) : "n"));
@@ -1702,7 +2011,9 @@ var _NoteLengthProps = class _NoteLengthProps {
1702
2011
  return aNoteSize === bNoteSize;
1703
2012
  }
1704
2013
  };
2014
+ /** Longest note size (e.g. 1 = whole note). */
1705
2015
  __publicField(_NoteLengthProps, "LongestNoteSize", Math.min(...import_ts_utils_lib8.Utils.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
2016
+ /** Shortest note size (e.g. 64 = sixtyfourth note). */
1706
2017
  __publicField(_NoteLengthProps, "ShortestNoteSize", Math.max(...import_ts_utils_lib8.Utils.Enum.getEnumValues(NoteLength).map((noteLength) => parseInt(noteLength))));
1707
2018
  __publicField(_NoteLengthProps, "cache", /* @__PURE__ */ new Map());
1708
2019
  var NoteLengthProps = _NoteLengthProps;
@@ -1714,23 +2025,30 @@ function validateTupletRatio(tupletRatio) {
1714
2025
  }
1715
2026
  }
1716
2027
  var Tuplet = {
1717
- /** 2 in the time of 3 */
2028
+ /** Duplet: 2 in the time of 3 */
1718
2029
  Duplet: { parts: 2, inTimeOf: 3 },
1719
- /** 3 in the time of 2 */
2030
+ /** Triplet: 3 in the time of 2 */
1720
2031
  Triplet: { parts: 3, inTimeOf: 2 },
1721
- /** 4 in the time of 3 */
2032
+ /** Quadruplet: 4 in the time of 3 */
1722
2033
  Quadruplet: { parts: 4, inTimeOf: 3 }
1723
2034
  };
1724
2035
  var _RhythmProps = class _RhythmProps {
1725
2036
  constructor(noteLength, dotCount, tupletRatio) {
2037
+ /** Note length. */
1726
2038
  __publicField(this, "noteLength");
2039
+ /** Note size (whole=1, half=2, quarter=4, ...). */
1727
2040
  __publicField(this, "noteSize");
1728
- // whole=1, half=2, quarter=4, etc.
2041
+ /** Dot count. */
1729
2042
  __publicField(this, "dotCount");
2043
+ /** Tuplet ratio. */
1730
2044
  __publicField(this, "tupletRatio");
2045
+ /** Number of ticks. */
1731
2046
  __publicField(this, "ticks");
2047
+ /** Flag count. */
1732
2048
  __publicField(this, "flagCount");
2049
+ /** Has note stem. */
1733
2050
  __publicField(this, "hasStem");
2051
+ /** Is note head solid (black)? */
1734
2052
  __publicField(this, "isSolidNoteHead");
1735
2053
  this.noteLength = validateNoteLength(noteLength);
1736
2054
  let p = NoteLengthProps.get(noteLength);
@@ -1759,11 +2077,22 @@ var _RhythmProps = class _RhythmProps {
1759
2077
  this.ticks *= this.tupletRatio.inTimeOf / this.tupletRatio.parts;
1760
2078
  }
1761
2079
  }
2080
+ /**
2081
+ * Get string presentation of rhythm props.
2082
+ * @returns - String presentation.
2083
+ */
1762
2084
  toString() {
1763
2085
  let sym = _RhythmProps.NoteSymbolMap.get(this.noteSize);
1764
2086
  let dots = ".".repeat(this.dotCount);
1765
2087
  return sym ? sym + dots : "" + this.noteSize + (dots.length > 0 ? dots : "n");
1766
2088
  }
2089
+ /**
2090
+ * Get rhythm props with given arguments.
2091
+ * @param noteLength - Note length.
2092
+ * @param dotCount - Dot count.
2093
+ * @param tupletRatio - Tuplet ratio.
2094
+ * @returns - Rhythm props.
2095
+ */
1767
2096
  static get(noteLength, dotCount, tupletRatio) {
1768
2097
  if (dotCount !== void 0 || tupletRatio !== void 0) {
1769
2098
  return new _RhythmProps(noteLength, dotCount, tupletRatio);
@@ -1802,12 +2131,17 @@ var RhythmProps = _RhythmProps;
1802
2131
  var import_core9 = require("@tspro/web-music-score/core");
1803
2132
  var TimeSignature = class {
1804
2133
  constructor(...args) {
2134
+ /** Number of beats in measure, upper value (e.g. "3" in "3/4"). */
1805
2135
  __publicField(this, "beatCount");
2136
+ /** Beat size of time signature, lower value (e.g. "4" in "3/4"). */
1806
2137
  __publicField(this, "beatSize");
1807
- /** Lengths in ticks */
2138
+ /** Beat length. */
1808
2139
  __publicField(this, "beatLength");
2140
+ /** Number of ticks in measure. */
1809
2141
  __publicField(this, "measureTicks");
2142
+ /** Number of beam groups in measure. */
1810
2143
  __publicField(this, "beamGroupCount");
2144
+ /** Length of one beam group. */
1811
2145
  __publicField(this, "beamGroupLength");
1812
2146
  if (args.length === 1 && typeof args[0] === "string") {
1813
2147
  let parts = args[0].split("/");
@@ -1840,9 +2174,19 @@ var TimeSignature = class {
1840
2174
  throw new import_core9.MusicError(import_core9.MusicErrorType.Timesignature, `Invalid beamGroupLength: ${this.beamGroupLength}`);
1841
2175
  }
1842
2176
  }
2177
+ /**
2178
+ * Test whether this time signature has given beat count and size.
2179
+ * @param beatCount - Beat count.
2180
+ * @param beatSize - Beat size.
2181
+ * @returns - Boolean whether this time signature match given beat count and size.
2182
+ */
1843
2183
  is(beatCount, beatSize) {
1844
2184
  return this.beatCount === beatCount && this.beatSize === beatSize;
1845
2185
  }
2186
+ /**
2187
+ * Get string representation of this time signature (e.g. "3/4").
2188
+ * @returns - String representation.
2189
+ */
1846
2190
  toString() {
1847
2191
  return this.beatCount + "/" + this.beatSize;
1848
2192
  }