@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,15 @@
1
+ import { I as Instrument } from '../instrument-DYboobMW.mjs';
2
+
3
+ /**
4
+ * Make this module "audio-synth" in typedoc instead of "audio-instruments/audio-synth".
5
+ * @module audio-synth
6
+ */
7
+
8
+ /**
9
+ * Export synthesizer instrument object.
10
+ *
11
+ * Synthesizer is default instrument and enabled out of the box.
12
+ */
13
+ declare const Synthesizer: Instrument;
14
+
15
+ export { Synthesizer };
@@ -0,0 +1,15 @@
1
+ import { I as Instrument } from '../instrument-DYboobMW.js';
2
+
3
+ /**
4
+ * Make this module "audio-synth" in typedoc instead of "audio-instruments/audio-synth".
5
+ * @module audio-synth
6
+ */
7
+
8
+ /**
9
+ * Export synthesizer instrument object.
10
+ *
11
+ * Synthesizer is default instrument and enabled out of the box.
12
+ */
13
+ declare const Synthesizer: Instrument;
14
+
15
+ export { Synthesizer };
@@ -0,0 +1,95 @@
1
+ /* WebMusicScore v5.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
+
33
+ // src/audio-instruments/audio-synth/index.ts
34
+ var audio_synth_exports = {};
35
+ __export(audio_synth_exports, {
36
+ Synthesizer: () => Synthesizer
37
+ });
38
+ module.exports = __toCommonJS(audio_synth_exports);
39
+
40
+ // src/audio/instrument.ts
41
+ function linearToDecibels(linearVolume) {
42
+ return !isFinite(linearVolume) || linearVolume <= 0 ? -Infinity : 20 * Math.log10(linearVolume);
43
+ }
44
+
45
+ // src/audio-instruments/audio-synth/index.ts
46
+ var Tone = __toESM(require("tone"));
47
+ var SynthesizerInstr = class {
48
+ constructor() {
49
+ __publicField(this, "audioSource");
50
+ try {
51
+ const reverb = new Tone.Reverb({ decay: 3, wet: 0.4 }).toDestination();
52
+ const filter = new Tone.Filter(800, "lowpass").connect(reverb);
53
+ this.audioSource = new Tone.PolySynth(Tone.Synth, {
54
+ oscillator: {
55
+ type: "triangle"
56
+ },
57
+ envelope: {
58
+ attack: 1e-3,
59
+ decay: 2,
60
+ sustain: 0.1,
61
+ release: 1.2
62
+ }
63
+ }).connect(filter);
64
+ } catch (err) {
65
+ this.audioSource = void 0;
66
+ console.error(err);
67
+ }
68
+ }
69
+ getName() {
70
+ return "Synthesizer";
71
+ }
72
+ playNote(note, duration, linearVolume) {
73
+ try {
74
+ if (this.audioSource) {
75
+ this.audioSource.volume.value = linearToDecibels(linearVolume);
76
+ this.audioSource.triggerAttackRelease(note, duration);
77
+ }
78
+ } catch (err) {
79
+ }
80
+ }
81
+ stop() {
82
+ try {
83
+ if (this.audioSource) {
84
+ this.audioSource.releaseAll();
85
+ }
86
+ } catch (err) {
87
+ }
88
+ }
89
+ };
90
+ var Synthesizer = new SynthesizerInstr();
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ Synthesizer
94
+ });
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,58 @@
1
+ /* WebMusicScore v5.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
+ import {
3
+ linearToDecibels
4
+ } from "../chunk-ROPTZBKD.mjs";
5
+ import {
6
+ __publicField
7
+ } from "../chunk-2EQHSQWO.mjs";
8
+
9
+ // src/audio-instruments/audio-synth/index.ts
10
+ import * as Tone from "tone";
11
+ var SynthesizerInstr = class {
12
+ constructor() {
13
+ __publicField(this, "audioSource");
14
+ try {
15
+ const reverb = new Tone.Reverb({ decay: 3, wet: 0.4 }).toDestination();
16
+ const filter = new Tone.Filter(800, "lowpass").connect(reverb);
17
+ this.audioSource = new Tone.PolySynth(Tone.Synth, {
18
+ oscillator: {
19
+ type: "triangle"
20
+ },
21
+ envelope: {
22
+ attack: 1e-3,
23
+ decay: 2,
24
+ sustain: 0.1,
25
+ release: 1.2
26
+ }
27
+ }).connect(filter);
28
+ } catch (err) {
29
+ this.audioSource = void 0;
30
+ console.error(err);
31
+ }
32
+ }
33
+ getName() {
34
+ return "Synthesizer";
35
+ }
36
+ playNote(note, duration, linearVolume) {
37
+ try {
38
+ if (this.audioSource) {
39
+ this.audioSource.volume.value = linearToDecibels(linearVolume);
40
+ this.audioSource.triggerAttackRelease(note, duration);
41
+ }
42
+ } catch (err) {
43
+ }
44
+ }
45
+ stop() {
46
+ try {
47
+ if (this.audioSource) {
48
+ this.audioSource.releaseAll();
49
+ }
50
+ } catch (err) {
51
+ }
52
+ }
53
+ };
54
+ var Synthesizer = new SynthesizerInstr();
55
+ export {
56
+ Synthesizer
57
+ };
58
+ //# sourceMappingURL=index.mjs.map
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v4.2.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -6,4 +6,4 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
6
6
  export {
7
7
  __publicField
8
8
  };
9
- //# sourceMappingURL=chunk-64N22LCV.mjs.map
9
+ //# sourceMappingURL=chunk-2EQHSQWO.mjs.map
@@ -1,12 +1,11 @@
1
- /* WebMusicScore v4.2.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  import {
3
3
  __publicField
4
- } from "./chunk-64N22LCV.mjs";
4
+ } from "./chunk-2EQHSQWO.mjs";
5
5
 
6
6
  // src/theory/rhythm.ts
7
7
  import { Utils } from "@tspro/ts-utils-lib";
8
8
  import { MusicError, MusicErrorType } from "@tspro/web-music-score/core";
9
- var cmp = (a, b) => a === b ? 0 : a < b ? -1 : 1;
10
9
  var MaxTupletRatioValue = 12;
11
10
  var TicksMultiplier = 12 * 11 * 9 * 7 * 5;
12
11
  var NoteLength = /* @__PURE__ */ ((NoteLength2) => {
@@ -122,7 +121,7 @@ var _NoteLengthProps = class _NoteLengthProps {
122
121
  static cmp(a, b) {
123
122
  let aNoteSize = a instanceof _NoteLengthProps ? a.noteSize : typeof a === "number" ? a : _NoteLengthProps.get(a).noteSize;
124
123
  let bNoteSize = b instanceof _NoteLengthProps ? b.noteSize : typeof b === "number" ? b : _NoteLengthProps.get(b).noteSize;
125
- return cmp(bNoteSize, aNoteSize);
124
+ return Utils.Math.cmp(bNoteSize, aNoteSize);
126
125
  }
127
126
  /**
128
127
  * Compare note lengths/sizes for equality.
@@ -237,7 +236,7 @@ var _RhythmProps = class _RhythmProps {
237
236
  * @returns - -1: a < b, 0: a === b, +1: a > b (duration comparisons)
238
237
  */
239
238
  static cmp(a, b) {
240
- return cmp(a.ticks, b.ticks);
239
+ return Utils.Math.cmp(a.ticks, b.ticks);
241
240
  }
242
241
  /**
243
242
  * Compare duration equality of rhythm props.
@@ -261,4 +260,4 @@ export {
261
260
  Tuplet,
262
261
  RhythmProps
263
262
  };
264
- //# sourceMappingURL=chunk-RQFFLRWF.mjs.map
263
+ //# sourceMappingURL=chunk-QVYFIK3L.mjs.map
@@ -0,0 +1,11 @@
1
+ /* WebMusicScore v5.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
+
3
+ // src/audio/instrument.ts
4
+ function linearToDecibels(linearVolume) {
5
+ return !isFinite(linearVolume) || linearVolume <= 0 ? -Infinity : 20 * Math.log10(linearVolume);
6
+ }
7
+
8
+ export {
9
+ linearToDecibels
10
+ };
11
+ //# sourceMappingURL=chunk-ROPTZBKD.mjs.map
@@ -6,7 +6,8 @@ declare enum MusicErrorType {
6
6
  Scale = 3,
7
7
  KeySignature = 4,
8
8
  Timesignature = 5,
9
- Score = 6
9
+ Score = 6,
10
+ Audio = 7
10
11
  }
11
12
  /** Music error class. */
12
13
  declare class MusicError extends Error {
@@ -6,7 +6,8 @@ declare enum MusicErrorType {
6
6
  Scale = 3,
7
7
  KeySignature = 4,
8
8
  Timesignature = 5,
9
- Score = 6
9
+ Score = 6,
10
+ Audio = 7
10
11
  }
11
12
  /** Music error class. */
12
13
  declare class MusicError extends Error {
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v4.2.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.1.0 | (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;
@@ -38,6 +38,7 @@ var MusicErrorType = /* @__PURE__ */ ((MusicErrorType2) => {
38
38
  MusicErrorType2[MusicErrorType2["KeySignature"] = 4] = "KeySignature";
39
39
  MusicErrorType2[MusicErrorType2["Timesignature"] = 5] = "Timesignature";
40
40
  MusicErrorType2[MusicErrorType2["Score"] = 6] = "Score";
41
+ MusicErrorType2[MusicErrorType2["Audio"] = 7] = "Audio";
41
42
  return MusicErrorType2;
42
43
  })(MusicErrorType || {});
43
44
  function formatType(type) {
@@ -62,7 +63,7 @@ function init() {
62
63
  return;
63
64
  }
64
65
  initialized = true;
65
- console.log("%cWebMusicScore v4.2.1 (cjs) initialized.", "background: black; color: white; padding: 2px;");
66
+ console.log("%cWebMusicScore v5.1.0 (cjs) initialized.", "background: black; color: white; padding: 2px;");
66
67
  }
67
68
  // Annotate the CommonJS export names for ESM import in node:
68
69
  0 && (module.exports = {
@@ -1,7 +1,7 @@
1
- /* WebMusicScore v4.2.1 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.1.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  import {
3
3
  __publicField
4
- } from "../chunk-64N22LCV.mjs";
4
+ } from "../chunk-2EQHSQWO.mjs";
5
5
 
6
6
  // src/core/error.ts
7
7
  var MusicErrorType = /* @__PURE__ */ ((MusicErrorType2) => {
@@ -12,6 +12,7 @@ var MusicErrorType = /* @__PURE__ */ ((MusicErrorType2) => {
12
12
  MusicErrorType2[MusicErrorType2["KeySignature"] = 4] = "KeySignature";
13
13
  MusicErrorType2[MusicErrorType2["Timesignature"] = 5] = "Timesignature";
14
14
  MusicErrorType2[MusicErrorType2["Score"] = 6] = "Score";
15
+ MusicErrorType2[MusicErrorType2["Audio"] = 7] = "Audio";
15
16
  return MusicErrorType2;
16
17
  })(MusicErrorType || {});
17
18
  function formatType(type) {
@@ -36,7 +37,7 @@ function init() {
36
37
  return;
37
38
  }
38
39
  initialized = true;
39
- console.log("%cWebMusicScore v4.2.1 (esm) initialized.", "background: black; color: white; padding: 2px;");
40
+ console.log("%cWebMusicScore v5.1.0 (esm) initialized.", "background: black; color: white; padding: 2px;");
40
41
  }
41
42
  export {
42
43
  MusicError,