tone 14.8.37 → 14.8.40

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 (32) hide show
  1. package/Tone/component/filter/FeedbackCombFilter.test.ts +16 -0
  2. package/Tone/core/context/BaseContext.ts +1 -2
  3. package/Tone/core/context/Context.ts +6 -12
  4. package/Tone/core/context/DummyContext.test.ts +1 -1
  5. package/Tone/core/context/DummyContext.ts +1 -1
  6. package/Tone/core/type/TransportTime.ts +3 -3
  7. package/Tone/core/worklet/ToneAudioWorklet.ts +1 -1
  8. package/Tone/effect/BitCrusher.test.ts +16 -0
  9. package/Tone/event/Sequence.ts +1 -1
  10. package/Tone/instrument/PolySynth.ts +1 -1
  11. package/Tone/version.ts +1 -1
  12. package/build/Tone.js +1 -1
  13. package/build/Tone.js.map +1 -1
  14. package/build/esm/core/context/BaseContext.d.ts +1 -1
  15. package/build/esm/core/context/BaseContext.js.map +1 -1
  16. package/build/esm/core/context/Context.d.ts +2 -3
  17. package/build/esm/core/context/Context.js +6 -9
  18. package/build/esm/core/context/Context.js.map +1 -1
  19. package/build/esm/core/context/DummyContext.d.ts +1 -1
  20. package/build/esm/core/context/DummyContext.js +1 -1
  21. package/build/esm/core/context/DummyContext.js.map +1 -1
  22. package/build/esm/core/type/TransportTime.d.ts +3 -3
  23. package/build/esm/core/type/TransportTime.js +3 -3
  24. package/build/esm/core/worklet/ToneAudioWorklet.js +1 -1
  25. package/build/esm/core/worklet/ToneAudioWorklet.js.map +1 -1
  26. package/build/esm/event/Sequence.d.ts +1 -1
  27. package/build/esm/event/Sequence.js +1 -1
  28. package/build/esm/instrument/PolySynth.d.ts +1 -1
  29. package/build/esm/instrument/PolySynth.js +1 -1
  30. package/build/esm/version.js +1 -1
  31. package/docs/tone.json +1 -1
  32. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import { expect } from "chai";
2
2
  import { FeedbackCombFilter } from "./FeedbackCombFilter";
3
+ import { BitCrusher } from "Tone/effect/BitCrusher";
3
4
  import { BasicTests } from "test/helper/Basic";
4
5
  import { PassAudio } from "test/helper/PassAudio";
5
6
  import { Offline } from "test/helper/Offline";
@@ -76,5 +77,20 @@ describe("FeedbackCombFilter", () => {
76
77
  });
77
78
  });
78
79
  });
80
+
81
+ it("should be usable with the BitCrusher", (done) => {
82
+ new FeedbackCombFilter();
83
+ new BitCrusher(4);
84
+
85
+ const handle = setTimeout(() => {
86
+ window.onunhandledrejection = null;
87
+ done();
88
+ }, 100);
89
+
90
+ window.onunhandledrejection = (event) => {
91
+ done(event.reason);
92
+ clearTimeout(handle);
93
+ };
94
+ });
79
95
  });
80
96
 
@@ -105,8 +105,7 @@ export abstract class BaseContext
105
105
  abstract get rawContext(): AnyAudioContext;
106
106
 
107
107
  abstract addAudioWorkletModule(
108
- _url: string,
109
- _name: string
108
+ _url: string
110
109
  ): Promise<void>;
111
110
 
112
111
  abstract lookAhead: number;
@@ -340,7 +340,7 @@ export class Context extends BaseContext {
340
340
  /**
341
341
  * Maps a module name to promise of the addModule method
342
342
  */
343
- private _workletModules: Map<string, Promise<void>> = new Map();
343
+ private _workletPromise: null | Promise<void> = null;
344
344
 
345
345
  /**
346
346
  * Create an audio worklet node from a name and options. The module
@@ -356,29 +356,23 @@ export class Context extends BaseContext {
356
356
  /**
357
357
  * Add an AudioWorkletProcessor module
358
358
  * @param url The url of the module
359
- * @param name The name of the module
360
359
  */
361
- async addAudioWorkletModule(url: string, name: string): Promise<void> {
360
+ async addAudioWorkletModule(url: string): Promise<void> {
362
361
  assert(
363
362
  isDefined(this.rawContext.audioWorklet),
364
363
  "AudioWorkletNode is only available in a secure context (https or localhost)"
365
364
  );
366
- if (!this._workletModules.has(name)) {
367
- this._workletModules.set(
368
- name,
369
- this.rawContext.audioWorklet.addModule(url)
370
- );
365
+ if (!this._workletPromise) {
366
+ this._workletPromise = this.rawContext.audioWorklet.addModule(url);
371
367
  }
372
- await this._workletModules.get(name);
368
+ await this._workletPromise;
373
369
  }
374
370
 
375
371
  /**
376
372
  * Returns a promise which resolves when all of the worklets have been loaded on this context
377
373
  */
378
374
  protected async workletsAreReady(): Promise<void> {
379
- const promises: Promise<void>[] = [];
380
- this._workletModules.forEach((promise) => promises.push(promise));
381
- await Promise.all(promises);
375
+ await this._workletPromise ? this._workletPromise : Promise.resolve();
382
376
  }
383
377
 
384
378
  //---------------------------
@@ -25,7 +25,7 @@ describe("DummyContext", () => {
25
25
  context.decodeAudioData(new Float32Array(100));
26
26
  context.createAudioWorkletNode("test.js");
27
27
  context.rawContext;
28
- context.addAudioWorkletModule("test.js", "test");
28
+ context.addAudioWorkletModule("test.js");
29
29
  context.resume();
30
30
  context.setTimeout(() => {}, 1);
31
31
  context.clearTimeout(1);
@@ -127,7 +127,7 @@ export class DummyContext extends BaseContext {
127
127
  return {} as AnyAudioContext;
128
128
  }
129
129
 
130
- async addAudioWorkletModule(_url: string, _name: string): Promise<void> {
130
+ async addAudioWorkletModule(_url: string): Promise<void> {
131
131
  return Promise.resolve();
132
132
  }
133
133
 
@@ -4,7 +4,7 @@ import { TimeClass } from "./Time";
4
4
  import { TimeBaseUnit, TimeValue } from "./TimeBase";
5
5
 
6
6
  /**
7
- * TransportTime is a the time along the Transport's
7
+ * TransportTime is a time along the Transport's
8
8
  * timeline. It is similar to Tone.Time, but instead of evaluating
9
9
  * against the AudioContext's clock, it is evaluated against
10
10
  * the Transport's position. See [TransportTime wiki](https://github.com/Tonejs/Tone.js/wiki/TransportTime).
@@ -23,8 +23,8 @@ export class TransportTimeClass<Type extends Seconds | Ticks = Seconds> extends
23
23
  }
24
24
 
25
25
  /**
26
- * TransportTime is a the time along the Transport's
27
- * timeline. It is similar to [[Time]], but instead of evaluating
26
+ * TransportTime is a time along the Transport's
27
+ * timeline. It is similar to Tone.Time, but instead of evaluating
28
28
  * against the AudioContext's clock, it is evaluated against
29
29
  * the Transport's position. See [TransportTime wiki](https://github.com/Tonejs/Tone.js/wiki/TransportTime).
30
30
  * @category Unit
@@ -53,7 +53,7 @@ export abstract class ToneAudioWorklet<Options extends ToneAudioWorkletOptions>
53
53
  this._dummyParam = this._dummyGain.gain;
54
54
 
55
55
  // Register the processor
56
- this.context.addAudioWorkletModule(blobUrl, name).then(() => {
56
+ this.context.addAudioWorkletModule(blobUrl).then(() => {
57
57
  // create the worklet when it's read
58
58
  if (!this.disposed) {
59
59
  this._worklet = this.context.createAudioWorkletNode(name, this.workletOptions);
@@ -1,4 +1,5 @@
1
1
  import { BitCrusher } from "./BitCrusher";
2
+ import { FeedbackCombFilter } from "Tone/component/filter/FeedbackCombFilter";
2
3
  import { Oscillator } from "Tone/source/oscillator/Oscillator";
3
4
  import { BasicTests } from "test/helper/Basic";
4
5
  import { EffectTests } from "test/helper/EffectTests";
@@ -38,5 +39,20 @@ describe("BitCrusher", () => {
38
39
  crusher.dispose();
39
40
  });
40
41
  });
42
+
43
+ it("should be usable with the FeedbackCombFilter", (done) => {
44
+ new BitCrusher(4);
45
+ new FeedbackCombFilter();
46
+
47
+ const handle = setTimeout(() => {
48
+ window.onunhandledrejection = null;
49
+ done();
50
+ }, 100);
51
+
52
+ window.onunhandledrejection = (event) => {
53
+ done(event.reason);
54
+ clearTimeout(handle);
55
+ };
56
+ });
41
57
  });
42
58
 
@@ -20,7 +20,7 @@ interface SequenceOptions<T> extends Omit<ToneEventOptions<T>, "value"> {
20
20
  * in an array of events which will be spaced at the
21
21
  * given subdivision. Sub-arrays will subdivide that beat
22
22
  * by the number of items are in the array.
23
- * Sequence notation inspiration from [Tidal](http://yaxu.org/tidal/)
23
+ * Sequence notation inspiration from [Tidal Cycles](http://tidalcycles.org/)
24
24
  * @example
25
25
  * const synth = new Tone.Synth().toDestination();
26
26
  * const seq = new Tone.Sequence((time, note) => {
@@ -42,7 +42,7 @@ export interface PolySynthOptions<Voice> extends InstrumentOptions {
42
42
 
43
43
  /**
44
44
  * PolySynth handles voice creation and allocation for any
45
- * instruments passed in as the second paramter. PolySynth is
45
+ * instruments passed in as the second parameter. PolySynth is
46
46
  * not a synthesizer by itself, it merely manages voices of
47
47
  * one of the other types of synths, allowing any of the
48
48
  * monophonic synthesizers to be polyphonic.
package/Tone/version.ts CHANGED
@@ -1 +1 @@
1
- export const version: string = "14.8.37";
1
+ export const version: string = "14.8.40";