tone 14.8.46 → 14.8.48

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.
package/README.md CHANGED
@@ -12,22 +12,24 @@ Tone.js is a Web Audio framework for creating interactive music in the browser.
12
12
 
13
13
  # Installation
14
14
 
15
- To install the latest stable version.
15
+ There are two ways to incorporate Tone.js into a proejct. First, it can be installed locally into a project using `npm`:
16
16
 
17
17
  ```bash
18
- npm install tone
18
+ npm install tone // Install the latest stable version
19
+ npm install tone@next // Or, alternatively, use the 'next' version
19
20
  ```
20
21
 
21
- Or to install the 'next' version
22
+ Add Tone.js to a project using the JavaScript `import` syntax:
22
23
 
23
- ```bash
24
- npm install tone@next
24
+ ```js
25
+ import * as Tone from 'tone';
25
26
  ```
26
27
 
27
- To import Tone.js:
28
+ Tone.js is also hosted at unpkg.com. It can be added directly within an HTML document, as long as it precedes any project scripts. [See the example here](https://github.com/Tonejs/Tone.js/blob/master/examples/simpleHtml.html) for more details.
28
29
 
29
- ```js
30
- import * as Tone from 'tone'
30
+ ```html
31
+ <script src="http://unpkg.com/tone"></script>
32
+ <script src="myScript.js"></script>
31
33
  ```
32
34
 
33
35
  # Hello Tone
@@ -4,7 +4,7 @@ import { MeterBase, MeterBaseOptions } from "./MeterBase";
4
4
  export type DCMeterOptions = MeterBaseOptions;
5
5
 
6
6
  /**
7
- * DCMeter gets the raw value of the input signal at the current time.
7
+ * DCMeter gets the raw value of the input signal at the current time. See also {@link Meter}.
8
8
  *
9
9
  * @example
10
10
  * const meter = new Tone.DCMeter();
@@ -14,6 +14,9 @@ export interface MeterOptions extends MeterBaseOptions {
14
14
  /**
15
15
  * Meter gets the [RMS](https://en.wikipedia.org/wiki/Root_mean_square)
16
16
  * of an input signal. It can also get the raw value of the input signal.
17
+ * Setting `normalRange` to `true` will covert the output to a range of
18
+ * 0-1. See an example using a graphical display
19
+ * [here](https://tonejs.github.io/examples/meter). See also {@link DCMeter}.
17
20
  *
18
21
  * @example
19
22
  * const meter = new Tone.Meter();
@@ -120,8 +120,7 @@ describe("Context", () => {
120
120
  await context.resume();
121
121
  await new Promise<void>((done) => setTimeout(() => done(), 10));
122
122
  expect(triggerChange).to.equal(true);
123
- context.dispose();
124
- return ac.close();
123
+ return context.dispose();
125
124
  });
126
125
  });
127
126
 
@@ -94,6 +94,11 @@ export class Context extends BaseContext {
94
94
  */
95
95
  private _initialized = false;
96
96
 
97
+ /**
98
+ * Private indicator if a close() has been called on the context, since close is async
99
+ */
100
+ private _closeStarted = false;
101
+
97
102
  /**
98
103
  * Indicates if the context is an OfflineAudioContext or an AudioContext
99
104
  */
@@ -485,7 +490,8 @@ export class Context extends BaseContext {
485
490
  * any AudioNodes created from the context will be silent.
486
491
  */
487
492
  async close(): Promise<void> {
488
- if (isAudioContext(this._context)) {
493
+ if (isAudioContext(this._context) && (this.state !== "closed") && !this._closeStarted) {
494
+ this._closeStarted = true;
489
495
  await this._context.close();
490
496
  }
491
497
  if (this._initialized) {
@@ -530,6 +536,7 @@ export class Context extends BaseContext {
530
536
  Object.keys(this._constants).map((val) =>
531
537
  this._constants[val].disconnect()
532
538
  );
539
+ this.close();
533
540
  return this;
534
541
  }
535
542
 
package/Tone/version.ts CHANGED
@@ -1 +1 @@
1
- export const version: string = "14.8.46";
1
+ export const version: string = "14.8.48";