@tspro/web-music-score 5.0.0 → 5.2.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 (43) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +16 -13
  3. package/dist/audio/index.d.mts +15 -2
  4. package/dist/audio/index.d.ts +16 -3
  5. package/dist/audio/index.js +37 -78
  6. package/dist/audio/index.mjs +34 -68
  7. package/dist/audio-cg/index.d.mts +6 -1
  8. package/dist/audio-cg/index.d.ts +6 -1
  9. package/dist/audio-cg/index.js +1 -1
  10. package/dist/audio-cg/index.mjs +3 -3
  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-AAL3CMRO.mjs → chunk-6S5BDSCM.mjs} +2 -2
  16. package/dist/{chunk-J3KU3U4W.mjs → chunk-LC5JMIVF.mjs} +2 -2
  17. package/dist/{chunk-EYFT3RWB.mjs → chunk-XUGM7SCC.mjs} +5 -6
  18. package/dist/core/index.js +2 -2
  19. package/dist/core/index.mjs +3 -3
  20. package/dist/{guitar-CaZJDA05.d.ts → guitar-BsSayRsH.d.ts} +1 -1
  21. package/dist/iife/audio-cg.global.js +9 -2
  22. package/dist/iife/index.global.js +11 -11
  23. package/dist/{music-objects-3Hxlkxy6.d.mts → music-objects-CB05XryE.d.mts} +121 -45
  24. package/dist/{music-objects-CI7IjsjE.d.ts → music-objects-CwPOlqFi.d.ts} +123 -47
  25. package/dist/{note-eA2xPPiG.d.ts → note-CgCIBwvR.d.ts} +1 -1
  26. package/dist/pieces/index.d.mts +1 -1
  27. package/dist/pieces/index.d.ts +3 -3
  28. package/dist/pieces/index.js +1 -1
  29. package/dist/pieces/index.mjs +2 -2
  30. package/dist/react-ui/index.d.mts +34 -15
  31. package/dist/react-ui/index.d.ts +38 -19
  32. package/dist/react-ui/index.js +41 -32
  33. package/dist/react-ui/index.mjs +42 -33
  34. package/dist/{scale-DGx3tJH4.d.ts → scale-CBW4eTz7.d.ts} +2 -2
  35. package/dist/score/index.d.mts +2 -2
  36. package/dist/score/index.d.ts +5 -5
  37. package/dist/score/index.js +1951 -1514
  38. package/dist/score/index.mjs +1664 -1226
  39. package/dist/{tempo-GrstpD9G.d.ts → tempo-DMt3iwz9.d.ts} +1 -1
  40. package/dist/theory/index.d.ts +6 -6
  41. package/dist/theory/index.js +3 -4
  42. package/dist/theory/index.mjs +3 -3
  43. package/package.json +12 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.2.0] - 2025-10-10
4
+ ## Fixed
5
+ - Beam not created correctly near tuplet.
6
+ - Create beam only if all beam notes are visible.
7
+ - Not all beams in group were created.
8
+ - play() on empty music document crashed.
9
+
10
+ ## Changed
11
+ - Renamed audio-cg iife global name to Audio_CG but also support old name Audio_ClassicalGuitar.
12
+
13
+ ## [5.1.0] - 2025-10-08
14
+ ## Added
15
+ - Audio functions: mute(), unmute() and isMuted().
16
+ - Added audio-synth as an own module.
17
+ - Added PlaybackButtons properties singlePlayStop, playStop and playPauseStop (deprecated buttonLayout).
18
+ - Added grandId property to staff config, deprecated isGrand property.
19
+ - Added tab signature (show tempo, measure number and time siganture).
20
+ - Draw rhythms above tab.
21
+
22
+ ## Fixed
23
+ - Documentation errors.
24
+ - Correctly apply NoteOptions.string for each note when using addNote with arrya of notes.
25
+ - Incorrect detection upbeat beams.
26
+ - Increase beam separation by angle.
27
+ - Better tempo position above staff.
28
+ - Distance between staff and tab.
29
+
3
30
  ## [5.0.0] - 2025-10-05
4
31
  Major update required to enable independent browser iife instrument modules.
5
32
 
package/README.md CHANGED
@@ -71,19 +71,19 @@ React module `react-ui` is not included available for browser usage.
71
71
  It is recommended to use exact version number and direct link to the bundle so
72
72
  that if something breaks between versions then your web site does not stop working.
73
73
  -->
74
- <script src="https://unpkg.com/@tspro/web-music-score@5.0.0/dist/iife/index.global.js"></script>
74
+ <script src="https://unpkg.com/@tspro/web-music-score@5.2.0/dist/iife/index.global.js"></script>
75
75
 
76
76
  <!--
77
77
  Classical guitar now also available for browser module.
78
78
  -->
79
- <script src="https://unpkg.com/@tspro/web-music-score@5.0.0/dist/iife/audio-cg.global.js"></script>
79
+ <script src="https://unpkg.com/@tspro/web-music-score@5.2.0/dist/iife/audio-cg.global.js"></script>
80
80
 
81
81
  <script>
82
82
  // The lib is available via global name WebMusicScore.
83
83
  const { Core, Audio, Theory, Score, Pieces } = window.WebMusicScore;
84
84
 
85
- // Classical guitar audio is available via global name Audio_ClassicalGuitar.
86
- const { ClassicalGuitar } = window.Audio_ClassicalGuitar;
85
+ // Classical guitar instrument is available via global name Audio_CG.
86
+ const { ClassicalGuitar } = window.Audio_CG;
87
87
 
88
88
  // Add and use classical guitar instrument.
89
89
  Audio.addInstrument(ClassicalGuitar);
@@ -150,8 +150,8 @@ or corresponding string values (e.g. `"treble"`).
150
150
  voiceIds: [0, 1] // (optional) only present voices 0 and 1 in this staff
151
151
  })
152
152
  .setScoreConfiguration([
153
- { type: "staff", clef: "G", isGrand: true },
154
- { type: "staff", clef: "F", isGrand: true }
153
+ { type: "staff", clef: "G", grandId: "grand1" },
154
+ { type: "staff", clef: "F", grandId: "grand1" }
155
155
  ]) // Grand staff
156
156
  .setScoreConfiguration([
157
157
  { type: "staff", clef: "G", isOctaveDown: true },
@@ -469,13 +469,16 @@ Score.MPlayer.stopAll();
469
469
  // Draw document
470
470
  <ScoreUI.MusicScoreView doc={doc} />
471
471
 
472
- // Add playback buttons
473
- <ScoreUI.PlaybackButtons doc={doc} buttonLayout={ScoreUI.PlaybackButtonsLayout.PlayStopSingle}/> // Single Play/Stopo button
474
- <ScoreUI.PlaybackButtons doc={doc} buttonLayout={ScoreUI.PlaybackButtonsLayout.PlayStop}/> // Play and Stop buttons
475
- <ScoreUI.PlaybackButtons doc={doc} buttonLayout={ScoreUI.PlaybackButtonsLayout.PlayPauseStop}/> // Play, Pause and Stop buttons
472
+ // Show playback buttons
473
+ <ScoreUI.PlaybackButtons doc={doc} singlePlayStop /> // Single play/stop button.
474
+ <ScoreUI.PlaybackButtons doc={doc} playStop /> // Play and stop buttons.
475
+ <ScoreUI.PlaybackButtons doc={doc} playPauseStop /> // Play, pause and Stop buttons.
476
+ <ScoreUI.PlaybackButtons doc={doc} /> // Default is play, pause and Stop buttons.
476
477
  ```
477
478
 
478
- Bootstrap is used for better visual appearance, but it needs to be installed and loaded.
479
+ Hint! Bootstrap is used for better visual appearance.
480
+ - Install bootstrap: `npm install bootstrap`
481
+ - Import in app entry: `import "bootstrap/dist/css/bootstrap.min.css";`
479
482
 
480
483
  ### Viewing Using Plain JS/TS
481
484
 
@@ -508,10 +511,10 @@ let p = new Score.MPlaybackButtons().
508
511
  setDocument(doc);
509
512
 
510
513
  // You can also set combined play/stop button.
511
- p.setPlayStopButton("playStopButtonId")
514
+ p.setPlayStopButton("playStopButtonId");
512
515
 
513
516
  // You can also pass HTMLButtonElement instead of element id.
514
- p.setPlayButton(playButtonElement)
517
+ p.setPlayButton(playButtonElement);
515
518
  ```
516
519
 
517
520
  ### MusicError
@@ -30,8 +30,21 @@ declare function useInstrument(instrumentName: string): void;
30
30
  */
31
31
  declare function playNote(note: Note | string | number, duration?: number, linearVolume?: number): void;
32
32
  /**
33
- * Stop playing on current instrument.
33
+ * Stop playback on current instrument.
34
34
  */
35
35
  declare function stop(): void;
36
+ /**
37
+ * Mute playback on current instrument.
38
+ */
39
+ declare function mute(): void;
40
+ /**
41
+ * Unmute playback on current instrument.
42
+ */
43
+ declare function unmute(): void;
44
+ /**
45
+ * Is playback muted?
46
+ * @returns True/false.
47
+ */
48
+ declare function isMuted(): boolean;
36
49
 
37
- export { Instrument, addInstrument, getCurrentInstrument, getInstrumentList, playNote, stop, useInstrument };
50
+ export { Instrument, addInstrument, getCurrentInstrument, getInstrumentList, isMuted, mute, playNote, stop, unmute, useInstrument };
@@ -1,4 +1,4 @@
1
- import { N as Note } from '../note-eA2xPPiG.js';
1
+ import { N as Note } from '../note-CgCIBwvR.js';
2
2
  import { I as Instrument } from '../instrument-DYboobMW.js';
3
3
  export { l as linearToDecibels } from '../instrument-DYboobMW.js';
4
4
 
@@ -30,8 +30,21 @@ declare function useInstrument(instrumentName: string): void;
30
30
  */
31
31
  declare function playNote(note: Note | string | number, duration?: number, linearVolume?: number): void;
32
32
  /**
33
- * Stop playing on current instrument.
33
+ * Stop playback on current instrument.
34
34
  */
35
35
  declare function stop(): void;
36
+ /**
37
+ * Mute playback on current instrument.
38
+ */
39
+ declare function mute(): void;
40
+ /**
41
+ * Unmute playback on current instrument.
42
+ */
43
+ declare function unmute(): void;
44
+ /**
45
+ * Is playback muted?
46
+ * @returns True/false.
47
+ */
48
+ declare function isMuted(): boolean;
36
49
 
37
- export { Instrument, addInstrument, getCurrentInstrument, getInstrumentList, playNote, stop, useInstrument };
50
+ export { Instrument, addInstrument, getCurrentInstrument, getInstrumentList, isMuted, mute, playNote, stop, unmute, useInstrument };
@@ -1,12 +1,9 @@
1
- /* WebMusicScore v5.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.2.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  "use strict";
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
6
  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
7
  var __export = (target, all) => {
11
8
  for (var name in all)
12
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -19,16 +16,7 @@ var __copyProps = (to, from, except, desc) => {
19
16
  }
20
17
  return to;
21
18
  };
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
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
32
20
 
33
21
  // src/audio/index.ts
34
22
  var audio_exports = {};
@@ -36,70 +24,25 @@ __export(audio_exports, {
36
24
  addInstrument: () => addInstrument,
37
25
  getCurrentInstrument: () => getCurrentInstrument,
38
26
  getInstrumentList: () => getInstrumentList,
27
+ isMuted: () => isMuted,
39
28
  linearToDecibels: () => linearToDecibels,
29
+ mute: () => mute,
40
30
  playNote: () => playNote,
41
31
  stop: () => stop,
32
+ unmute: () => unmute,
42
33
  useInstrument: () => useInstrument
43
34
  });
44
35
  module.exports = __toCommonJS(audio_exports);
45
36
  var import_theory = require("@tspro/web-music-score/theory");
46
-
47
- // src/audio/audio-synth.ts
48
- var Tone = __toESM(require("tone"));
37
+ var import_core = require("@tspro/web-music-score/core");
38
+ var import_audio_synth = require("@tspro/web-music-score/audio-synth");
49
39
 
50
40
  // src/audio/instrument.ts
51
41
  function linearToDecibels(linearVolume) {
52
42
  return !isFinite(linearVolume) || linearVolume <= 0 ? -Infinity : 20 * Math.log10(linearVolume);
53
43
  }
54
44
 
55
- // src/audio/audio-synth.ts
56
- var SynthesizerInstr = class {
57
- constructor() {
58
- __publicField(this, "audioSource");
59
- try {
60
- const reverb = new Tone.Reverb({ decay: 3, wet: 0.4 }).toDestination();
61
- const filter = new Tone.Filter(800, "lowpass").connect(reverb);
62
- this.audioSource = new Tone.PolySynth(Tone.Synth, {
63
- oscillator: {
64
- type: "triangle"
65
- },
66
- envelope: {
67
- attack: 1e-3,
68
- decay: 2,
69
- sustain: 0.1,
70
- release: 1.2
71
- }
72
- }).connect(filter);
73
- } catch (err) {
74
- this.audioSource = void 0;
75
- console.error(err);
76
- }
77
- }
78
- getName() {
79
- return "Synthesizer";
80
- }
81
- playNote(note, duration, linearVolume) {
82
- try {
83
- if (this.audioSource) {
84
- this.audioSource.volume.value = linearToDecibels(linearVolume);
85
- this.audioSource.triggerAttackRelease(note, duration);
86
- }
87
- } catch (err) {
88
- }
89
- }
90
- stop() {
91
- try {
92
- if (this.audioSource) {
93
- this.audioSource.releaseAll();
94
- }
95
- } catch (err) {
96
- }
97
- }
98
- };
99
- var Synthesizer = new SynthesizerInstr();
100
-
101
45
  // src/audio/index.ts
102
- var import_core = require("@tspro/web-music-score/core");
103
46
  var import_ts_utils_lib = require("@tspro/ts-utils-lib");
104
47
  (0, import_core.init)();
105
48
  function getNoteName(note) {
@@ -110,13 +53,20 @@ function getNoteName(note) {
110
53
  }
111
54
  return note.format(import_theory.PitchNotation.Scientific, import_theory.SymbolSet.Ascii);
112
55
  }
113
- var InstrumentList = [Synthesizer];
114
- var CurrentInstrument = Synthesizer;
56
+ var InstrumentList = [import_audio_synth.Synthesizer];
57
+ var currentInstrument = import_audio_synth.Synthesizer;
58
+ var DefaultDuration = (function calcDuration(noteSize, beatsPerMinute, timeTisgnature) {
59
+ var _a;
60
+ let beatSize = parseInt((_a = timeTisgnature.split("/")[1]) != null ? _a : "4");
61
+ return 60 * (1 / noteSize) / (beatsPerMinute * (1 / beatSize));
62
+ })(2, 80, "4/4");
63
+ var DefaultVolume = 1;
64
+ var mutePlayback = false;
115
65
  function getInstrumentList() {
116
66
  return InstrumentList.map((instr) => instr.getName());
117
67
  }
118
68
  function getCurrentInstrument() {
119
- return CurrentInstrument.getName();
69
+ return currentInstrument.getName();
120
70
  }
121
71
  function addInstrument(instrument) {
122
72
  (import_ts_utils_lib.Utils.Is.isArray(instrument) ? instrument : [instrument]).forEach((instr) => {
@@ -124,7 +74,7 @@ function addInstrument(instrument) {
124
74
  throw new import_core.MusicError(import_core.MusicErrorType.Audio, "Invalid instrument object: " + instr);
125
75
  }
126
76
  if (InstrumentList.some((instr2) => instr2.getName() === instr.getName())) {
127
- console.warn(`Instrument "${instr.getName()}" already registered!`);
77
+ console.warn(`Instrument "${instr.getName()}" already added!`);
128
78
  } else {
129
79
  InstrumentList.push(instr);
130
80
  }
@@ -132,35 +82,44 @@ function addInstrument(instrument) {
132
82
  });
133
83
  }
134
84
  function useInstrument(instrumentName) {
135
- if (instrumentName === CurrentInstrument.getName()) {
85
+ if (instrumentName === currentInstrument.getName()) {
136
86
  return;
137
87
  }
138
- CurrentInstrument.stop();
88
+ currentInstrument.stop();
139
89
  let instr = InstrumentList.find((instr2) => instr2.getName() === instrumentName);
140
90
  if (instr) {
141
- CurrentInstrument = instr;
91
+ currentInstrument = instr;
142
92
  }
143
93
  }
144
- var DefaultDuration = (function calcDuration(noteSize, beatsPerMinute, timeTisgnature) {
145
- var _a;
146
- let beatSize = parseInt((_a = timeTisgnature.split("/")[1]) != null ? _a : "4");
147
- return 60 * (1 / noteSize) / (beatsPerMinute * (1 / beatSize));
148
- })(2, 80, "4/4");
149
- var DefaultVolume = 1;
150
94
  function playNote(note, duration, linearVolume) {
151
- CurrentInstrument.playNote(getNoteName(note), duration != null ? duration : DefaultDuration, linearVolume != null ? linearVolume : DefaultVolume);
95
+ if (!mutePlayback) {
96
+ currentInstrument.playNote(getNoteName(note), duration != null ? duration : DefaultDuration, linearVolume != null ? linearVolume : DefaultVolume);
97
+ }
152
98
  }
153
99
  function stop() {
154
- CurrentInstrument.stop();
100
+ currentInstrument.stop();
101
+ }
102
+ function mute() {
103
+ stop();
104
+ mutePlayback = true;
105
+ }
106
+ function unmute() {
107
+ mutePlayback = false;
108
+ }
109
+ function isMuted() {
110
+ return mutePlayback;
155
111
  }
156
112
  // Annotate the CommonJS export names for ESM import in node:
157
113
  0 && (module.exports = {
158
114
  addInstrument,
159
115
  getCurrentInstrument,
160
116
  getInstrumentList,
117
+ isMuted,
161
118
  linearToDecibels,
119
+ mute,
162
120
  playNote,
163
121
  stop,
122
+ unmute,
164
123
  useInstrument
165
124
  });
166
125
  //# sourceMappingURL=index.js.map
@@ -1,63 +1,13 @@
1
- /* WebMusicScore v5.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.2.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  import {
3
3
  linearToDecibels
4
- } from "../chunk-AAL3CMRO.mjs";
5
- import {
6
- __publicField
7
- } from "../chunk-J3KU3U4W.mjs";
4
+ } from "../chunk-6S5BDSCM.mjs";
5
+ import "../chunk-LC5JMIVF.mjs";
8
6
 
9
7
  // src/audio/index.ts
10
8
  import { Note, PitchNotation, SymbolSet } from "@tspro/web-music-score/theory";
11
-
12
- // src/audio/audio-synth.ts
13
- import * as Tone from "tone";
14
- var SynthesizerInstr = class {
15
- constructor() {
16
- __publicField(this, "audioSource");
17
- try {
18
- const reverb = new Tone.Reverb({ decay: 3, wet: 0.4 }).toDestination();
19
- const filter = new Tone.Filter(800, "lowpass").connect(reverb);
20
- this.audioSource = new Tone.PolySynth(Tone.Synth, {
21
- oscillator: {
22
- type: "triangle"
23
- },
24
- envelope: {
25
- attack: 1e-3,
26
- decay: 2,
27
- sustain: 0.1,
28
- release: 1.2
29
- }
30
- }).connect(filter);
31
- } catch (err) {
32
- this.audioSource = void 0;
33
- console.error(err);
34
- }
35
- }
36
- getName() {
37
- return "Synthesizer";
38
- }
39
- playNote(note, duration, linearVolume) {
40
- try {
41
- if (this.audioSource) {
42
- this.audioSource.volume.value = linearToDecibels(linearVolume);
43
- this.audioSource.triggerAttackRelease(note, duration);
44
- }
45
- } catch (err) {
46
- }
47
- }
48
- stop() {
49
- try {
50
- if (this.audioSource) {
51
- this.audioSource.releaseAll();
52
- }
53
- } catch (err) {
54
- }
55
- }
56
- };
57
- var Synthesizer = new SynthesizerInstr();
58
-
59
- // src/audio/index.ts
60
9
  import { init as initCore, MusicError, MusicErrorType } from "@tspro/web-music-score/core";
10
+ import { Synthesizer } from "@tspro/web-music-score/audio-synth";
61
11
  import { Utils } from "@tspro/ts-utils-lib";
62
12
  initCore();
63
13
  function getNoteName(note) {
@@ -69,12 +19,19 @@ function getNoteName(note) {
69
19
  return note.format(PitchNotation.Scientific, SymbolSet.Ascii);
70
20
  }
71
21
  var InstrumentList = [Synthesizer];
72
- var CurrentInstrument = Synthesizer;
22
+ var currentInstrument = Synthesizer;
23
+ var DefaultDuration = (function calcDuration(noteSize, beatsPerMinute, timeTisgnature) {
24
+ var _a;
25
+ let beatSize = parseInt((_a = timeTisgnature.split("/")[1]) != null ? _a : "4");
26
+ return 60 * (1 / noteSize) / (beatsPerMinute * (1 / beatSize));
27
+ })(2, 80, "4/4");
28
+ var DefaultVolume = 1;
29
+ var mutePlayback = false;
73
30
  function getInstrumentList() {
74
31
  return InstrumentList.map((instr) => instr.getName());
75
32
  }
76
33
  function getCurrentInstrument() {
77
- return CurrentInstrument.getName();
34
+ return currentInstrument.getName();
78
35
  }
79
36
  function addInstrument(instrument) {
80
37
  (Utils.Is.isArray(instrument) ? instrument : [instrument]).forEach((instr) => {
@@ -82,7 +39,7 @@ function addInstrument(instrument) {
82
39
  throw new MusicError(MusicErrorType.Audio, "Invalid instrument object: " + instr);
83
40
  }
84
41
  if (InstrumentList.some((instr2) => instr2.getName() === instr.getName())) {
85
- console.warn(`Instrument "${instr.getName()}" already registered!`);
42
+ console.warn(`Instrument "${instr.getName()}" already added!`);
86
43
  } else {
87
44
  InstrumentList.push(instr);
88
45
  }
@@ -90,34 +47,43 @@ function addInstrument(instrument) {
90
47
  });
91
48
  }
92
49
  function useInstrument(instrumentName) {
93
- if (instrumentName === CurrentInstrument.getName()) {
50
+ if (instrumentName === currentInstrument.getName()) {
94
51
  return;
95
52
  }
96
- CurrentInstrument.stop();
53
+ currentInstrument.stop();
97
54
  let instr = InstrumentList.find((instr2) => instr2.getName() === instrumentName);
98
55
  if (instr) {
99
- CurrentInstrument = instr;
56
+ currentInstrument = instr;
100
57
  }
101
58
  }
102
- var DefaultDuration = (function calcDuration(noteSize, beatsPerMinute, timeTisgnature) {
103
- var _a;
104
- let beatSize = parseInt((_a = timeTisgnature.split("/")[1]) != null ? _a : "4");
105
- return 60 * (1 / noteSize) / (beatsPerMinute * (1 / beatSize));
106
- })(2, 80, "4/4");
107
- var DefaultVolume = 1;
108
59
  function playNote(note, duration, linearVolume) {
109
- CurrentInstrument.playNote(getNoteName(note), duration != null ? duration : DefaultDuration, linearVolume != null ? linearVolume : DefaultVolume);
60
+ if (!mutePlayback) {
61
+ currentInstrument.playNote(getNoteName(note), duration != null ? duration : DefaultDuration, linearVolume != null ? linearVolume : DefaultVolume);
62
+ }
110
63
  }
111
64
  function stop() {
112
- CurrentInstrument.stop();
65
+ currentInstrument.stop();
66
+ }
67
+ function mute() {
68
+ stop();
69
+ mutePlayback = true;
70
+ }
71
+ function unmute() {
72
+ mutePlayback = false;
73
+ }
74
+ function isMuted() {
75
+ return mutePlayback;
113
76
  }
114
77
  export {
115
78
  addInstrument,
116
79
  getCurrentInstrument,
117
80
  getInstrumentList,
81
+ isMuted,
118
82
  linearToDecibels,
83
+ mute,
119
84
  playNote,
120
85
  stop,
86
+ unmute,
121
87
  useInstrument
122
88
  };
123
89
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,12 @@
1
1
  import { I as Instrument } from '../instrument-DYboobMW.mjs';
2
2
 
3
3
  /**
4
- * Default export is the classical guitar instrument object.
4
+ * Make this module "audio-cg" in typedoc instead of "audio-instruments/audio-cg".
5
+ * @module audio-cg
6
+ */
7
+
8
+ /**
9
+ * Export classical guitar instrument object.
5
10
  *
6
11
  * ```ts
7
12
  * // Usage
@@ -1,7 +1,12 @@
1
1
  import { I as Instrument } from '../instrument-DYboobMW.js';
2
2
 
3
3
  /**
4
- * Default export is the classical guitar instrument object.
4
+ * Make this module "audio-cg" in typedoc instead of "audio-instruments/audio-cg".
5
+ * @module audio-cg
6
+ */
7
+
8
+ /**
9
+ * Export classical guitar instrument object.
5
10
  *
6
11
  * ```ts
7
12
  * // Usage
@@ -1,4 +1,4 @@
1
- /* WebMusicScore v5.0.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
1
+ /* WebMusicScore v5.2.0 | (c) 2023 PahkaSoft | MIT License | Includes: Tone.js (MIT License) */
2
2
  "use strict";
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;