tone 14.8.28 → 14.8.29

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.
@@ -30,9 +30,15 @@ export function getContext(): BaseContext {
30
30
 
31
31
  /**
32
32
  * Set the default audio context
33
+ * @param context
34
+ * @param disposeOld Pass `true` if you don't need the old context to dispose it.
33
35
  * @category Core
34
36
  */
35
- export function setContext(context: BaseContext | AnyAudioContext): void {
37
+ export function setContext(context: BaseContext | AnyAudioContext, disposeOld = false): void {
38
+ if (disposeOld) {
39
+ globalContext.dispose();
40
+ }
41
+
36
42
  if (isAudioContext(context)) {
37
43
  globalContext = new Context(context);
38
44
  } else if (isOfflineAudioContext(context)) {
@@ -278,6 +278,13 @@ describe("PolySynth", () => {
278
278
  polySynth.dispose();
279
279
  });
280
280
 
281
+ it("throws an error when used without a monophonic synth", () => {
282
+ expect(() => {
283
+ // @ts-ignore
284
+ new PolySynth(PluckSynth);
285
+ }).throws(Error)
286
+ });
287
+
281
288
  it("can pass in the volume", () => {
282
289
  const polySynth = new PolySynth({
283
290
  volume: -12,
@@ -176,6 +176,7 @@ export class PolySynth<Voice extends Monophonic<any> = Synth> extends Instrument
176
176
  context: this.context,
177
177
  onsilence: this._makeVoiceAvailable.bind(this),
178
178
  }));
179
+ assert(voice instanceof Monophonic, "Voice must extend Monophonic class");
179
180
  voice.connect(this.output);
180
181
  this._voices.push(voice);
181
182
  return voice;
@@ -156,9 +156,11 @@ describe("SyncedSignal", () => {
156
156
  sched.exponentialRampTo(3, 1, 1);
157
157
  transport.start(0);
158
158
  }, 3).then((buffer) => {
159
- buffer.forEach((sample, time) => {
160
- expect(sample).to.be.closeTo(sched.getValueAtTime(time), 0.02);
161
- });
159
+ expect(buffer.getValueAtTime(0)).to.closeTo(1, 0.1);
160
+ expect(buffer.getValueAtTime(0.5)).to.closeTo(1, 0.1);
161
+ expect(buffer.getValueAtTime(1)).to.closeTo(1, 0.1);
162
+ expect(buffer.getValueAtTime(1.5)).to.closeTo(1.75, 0.1);
163
+ expect(buffer.getValueAtTime(2)).to.closeTo(3, 0.1);
162
164
  });
163
165
  });
164
166
 
package/Tone/version.ts CHANGED
@@ -1 +1 @@
1
- export const version: string = "14.8.28";
1
+ export const version: string = "14.8.29";