tone 15.1.22 → 15.1.23
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/Tone/core/context/Context.ts +9 -7
- package/Tone/core/worklet/ToneAudioWorklet.ts +11 -1
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/core/context/Context.d.ts +2 -2
- package/build/esm/core/context/Context.js +7 -7
- package/build/esm/core/context/Context.js.map +1 -1
- package/build/esm/core/worklet/ToneAudioWorklet.d.ts +1 -0
- package/build/esm/core/worklet/ToneAudioWorklet.js +7 -1
- package/build/esm/core/worklet/ToneAudioWorklet.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -346,9 +346,9 @@ export class Context extends BaseContext {
|
|
|
346
346
|
//--------------------------------------------
|
|
347
347
|
|
|
348
348
|
/**
|
|
349
|
-
*
|
|
349
|
+
* A set of unsettled promises returned by the addModule method
|
|
350
350
|
*/
|
|
351
|
-
private
|
|
351
|
+
private _workletPromises = new Set<Promise<void>>();
|
|
352
352
|
|
|
353
353
|
/**
|
|
354
354
|
* Create an audio worklet node from a name and options. The module
|
|
@@ -370,17 +370,19 @@ export class Context extends BaseContext {
|
|
|
370
370
|
isDefined(this.rawContext.audioWorklet),
|
|
371
371
|
"AudioWorkletNode is only available in a secure context (https or localhost)"
|
|
372
372
|
);
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
373
|
+
const workletPromise = this.rawContext.audioWorklet.addModule(url);
|
|
374
|
+
|
|
375
|
+
this._workletPromises.add(workletPromise);
|
|
376
|
+
workletPromise.finally(() => this._workletPromises.delete(workletPromise));
|
|
377
|
+
|
|
378
|
+
return workletPromise;
|
|
377
379
|
}
|
|
378
380
|
|
|
379
381
|
/**
|
|
380
382
|
* Returns a promise which resolves when all of the worklets have been loaded on this context
|
|
381
383
|
*/
|
|
382
384
|
protected async workletsAreReady(): Promise<void> {
|
|
383
|
-
|
|
385
|
+
await Promise.all(this._workletPromises);
|
|
384
386
|
}
|
|
385
387
|
|
|
386
388
|
//---------------------------
|
|
@@ -59,7 +59,15 @@ export abstract class ToneAudioWorklet<
|
|
|
59
59
|
this._dummyParam = this._dummyGain.gain;
|
|
60
60
|
|
|
61
61
|
// Register the processor
|
|
62
|
-
|
|
62
|
+
let workletPromise = ToneAudioWorklet._workletPromises.get(this.context);
|
|
63
|
+
|
|
64
|
+
if (workletPromise === undefined) {
|
|
65
|
+
workletPromise = this.context.addAudioWorkletModule(blobUrl);
|
|
66
|
+
|
|
67
|
+
ToneAudioWorklet._workletPromises.set(this.context, workletPromise);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
workletPromise.then(() => {
|
|
63
71
|
// create the worklet when it's read
|
|
64
72
|
if (!this.disposed) {
|
|
65
73
|
this._worklet = this.context.createAudioWorkletNode(
|
|
@@ -73,6 +81,8 @@ export abstract class ToneAudioWorklet<
|
|
|
73
81
|
});
|
|
74
82
|
}
|
|
75
83
|
|
|
84
|
+
private static _workletPromises = new WeakMap<any, Promise<void>>();
|
|
85
|
+
|
|
76
86
|
dispose(): this {
|
|
77
87
|
super.dispose();
|
|
78
88
|
this._dummyGain.disconnect();
|
package/Tone/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version: string = "15.1.
|
|
1
|
+
export const version: string = "15.1.23";
|