tone 15.2.0 → 15.2.2

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 (69) hide show
  1. package/Tone/component/analysis/Follower.test.ts +38 -42
  2. package/Tone/component/channel/Channel.test.ts +3 -4
  3. package/Tone/component/channel/Merge.test.ts +5 -6
  4. package/Tone/component/channel/MidSideSplit.test.ts +21 -25
  5. package/Tone/component/channel/Mono.test.ts +18 -20
  6. package/Tone/component/channel/PanVol.test.ts +3 -4
  7. package/Tone/component/channel/Panner.test.ts +28 -32
  8. package/Tone/component/channel/Recorder.ts +1 -1
  9. package/Tone/component/channel/Volume.test.ts +9 -12
  10. package/Tone/component/dynamics/Gate.test.ts +10 -14
  11. package/Tone/component/envelope/AmplitudeEnvelope.test.ts +7 -9
  12. package/Tone/component/envelope/Envelope.test.ts +347 -384
  13. package/Tone/component/filter/BiquadFilter.test.ts +5 -6
  14. package/Tone/component/filter/Convolver.test.ts +6 -9
  15. package/Tone/component/filter/FeedbackCombFilter.test.ts +14 -16
  16. package/Tone/component/filter/Filter.test.ts +5 -6
  17. package/Tone/component/filter/LowpassCombFilter.test.ts +15 -17
  18. package/Tone/core/clock/Clock.test.ts +12 -15
  19. package/Tone/core/clock/TickSignal.test.ts +18 -21
  20. package/Tone/core/clock/Transport.test.ts +133 -162
  21. package/Tone/core/clock/TransportEvent.test.ts +3 -4
  22. package/Tone/core/clock/TransportRepeatEvent.test.ts +6 -6
  23. package/Tone/core/context/Context.test.ts +8 -10
  24. package/Tone/core/context/Context.ts +8 -4
  25. package/Tone/core/context/Destination.test.ts +3 -4
  26. package/Tone/core/context/Offline.test.ts +23 -41
  27. package/Tone/core/context/OfflineContext.test.ts +20 -22
  28. package/Tone/core/context/Param.test.ts +33 -40
  29. package/Tone/core/context/ToneAudioBuffer.test.ts +3 -10
  30. package/Tone/core/context/ToneAudioBuffers.test.ts +9 -13
  31. package/Tone/core/worklet/ToneAudioWorklet.ts +3 -1
  32. package/Tone/effect/AutoFilter.test.ts +10 -12
  33. package/Tone/effect/AutoPanner.test.ts +10 -12
  34. package/Tone/effect/Chorus.test.ts +10 -14
  35. package/Tone/effect/FrequencyShifter.test.ts +6 -7
  36. package/Tone/effect/Reverb.test.ts +12 -15
  37. package/Tone/effect/Tremolo.test.ts +10 -12
  38. package/Tone/event/Loop.test.ts +29 -36
  39. package/Tone/event/Part.test.ts +152 -180
  40. package/Tone/event/Pattern.test.ts +16 -20
  41. package/Tone/event/Sequence.test.ts +86 -101
  42. package/Tone/event/ToneEvent.test.ts +60 -70
  43. package/Tone/instrument/MonoSynth.test.ts +3 -4
  44. package/Tone/instrument/PolySynth.test.ts +62 -74
  45. package/Tone/instrument/Sampler.test.ts +39 -48
  46. package/Tone/instrument/Synth.test.ts +40 -47
  47. package/Tone/signal/AudioToGain.test.ts +4 -5
  48. package/Tone/signal/Signal.test.ts +120 -143
  49. package/Tone/signal/SyncedSignal.test.ts +108 -122
  50. package/Tone/signal/ToneConstantSource.test.ts +21 -25
  51. package/Tone/signal/WaveShaper.test.ts +5 -6
  52. package/Tone/source/Source.test.ts +42 -48
  53. package/Tone/source/buffer/GrainPlayer.test.ts +29 -35
  54. package/Tone/source/buffer/Player.test.ts +162 -191
  55. package/Tone/source/buffer/Players.test.ts +44 -50
  56. package/Tone/source/buffer/ToneBufferSource.test.ts +176 -211
  57. package/Tone/source/oscillator/LFO.test.ts +49 -61
  58. package/Tone/source/oscillator/Oscillator.test.ts +24 -28
  59. package/Tone/source/oscillator/PulseOscillator.test.ts +36 -40
  60. package/Tone/source/oscillator/ToneOscillatorNode.test.ts +25 -29
  61. package/Tone/version.ts +1 -1
  62. package/build/Tone.js +1 -1
  63. package/build/Tone.js.map +1 -1
  64. package/build/esm/component/channel/Recorder.js.map +1 -1
  65. package/build/esm/core/context/Context.js +6 -3
  66. package/build/esm/core/context/Context.js.map +1 -1
  67. package/build/esm/core/worklet/ToneAudioWorklet.js.map +1 -1
  68. package/build/esm/version.js +1 -1
  69. package/package.json +1 -1
@@ -143,8 +143,8 @@ describe("Signal", () => {
143
143
  expect(buffer.getValueAtTime(1)).to.be.closeTo(0, 0.001);
144
144
  });
145
145
 
146
- it("can disconnect from all the connected notes", () => {
147
- return ConstantOutput((context) => {
146
+ it("can disconnect from all the connected notes", async () => {
147
+ await ConstantOutput(async (context) => {
148
148
  const output0 = new Signal(1).toDestination();
149
149
  const output1 = new Signal(1).toDestination();
150
150
  const sig = new Signal(0).connect(output0);
@@ -156,8 +156,8 @@ describe("Signal", () => {
156
156
  }, 0);
157
157
  });
158
158
 
159
- it("can disconnect from a specific node", () => {
160
- return ConstantOutput((context) => {
159
+ it("can disconnect from a specific node", async () => {
160
+ await ConstantOutput(async (context) => {
161
161
  const output = new Signal(1).toDestination();
162
162
  const sig = new Signal(0).connect(output);
163
163
  sig.disconnect(output);
@@ -166,8 +166,9 @@ describe("Signal", () => {
166
166
  sig.linearRampToValueAtTime(0, 1);
167
167
  }, 0);
168
168
  });
169
+
169
170
  it("can schedule multiple automations from a connected signal through a multiple nodes", async () => {
170
- const buffer = await Offline(() => {
171
+ const buffer = await Offline(async () => {
171
172
  const output = new Signal(0).toDestination();
172
173
  const proxy = new Signal(0).connect(output);
173
174
  const gain = new Gain(1).connect(proxy);
@@ -192,6 +193,7 @@ describe("Signal", () => {
192
193
  sig.cancelScheduledValues(0);
193
194
  }, 1);
194
195
  });
196
+
195
197
  it("can cancel and hold a linear automation curve", async () => {
196
198
  const buffer = await Offline(() => {
197
199
  const sig = new Signal(0).toDestination();
@@ -204,188 +206,164 @@ describe("Signal", () => {
204
206
  expect(buffer.getValueAtTime(0.75)).to.be.closeTo(1, 0.1);
205
207
  });
206
208
 
207
- it("can cancel and hold an exponential automation curve", () => {
208
- return Offline(() => {
209
+ it("can cancel and hold an exponential automation curve", async () => {
210
+ const buffer = await Offline(() => {
209
211
  const sig = new Signal(1).toDestination();
210
212
  sig.exponentialRampTo(2, 1);
211
213
  sig.cancelAndHoldAtTime(0.5);
212
- }, 1).then((buffer) => {
213
- expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.1);
214
- expect(buffer.getValueAtTime(0.25)).to.be.closeTo(1.2, 0.1);
215
- expect(buffer.getValueAtTime(0.5)).to.be.closeTo(1.4, 0.1);
216
- expect(buffer.getValueAtTime(0.75)).to.be.closeTo(1.4, 0.1);
217
- });
214
+ }, 1);
215
+ expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.1);
216
+ expect(buffer.getValueAtTime(0.25)).to.be.closeTo(1.2, 0.1);
217
+ expect(buffer.getValueAtTime(0.5)).to.be.closeTo(1.4, 0.1);
218
+ expect(buffer.getValueAtTime(0.75)).to.be.closeTo(1.4, 0.1);
218
219
  });
219
220
 
220
- it("can set a linear ramp from the current time", () => {
221
- return Offline(() => {
221
+ it("can set a linear ramp from the current time", async () => {
222
+ const buffer = await Offline(() => {
222
223
  const sig = new Signal(0).toDestination();
223
224
  sig.linearRampTo(2, 0.3);
224
- }, 0.5).then((buffer) => {
225
- buffer.forEach((sample, time) => {
226
- if (time > 0.3) {
227
- expect(sample).to.be.closeTo(2, 0.02);
228
- }
229
- });
225
+ }, 0.5);
226
+ buffer.forEach((sample, time) => {
227
+ if (time > 0.3) {
228
+ expect(sample).to.be.closeTo(2, 0.02);
229
+ }
230
230
  });
231
231
  });
232
232
 
233
- it("can set an linear ramp in the future", () => {
234
- return Offline(() => {
233
+ it("can set an linear ramp in the future", async () => {
234
+ const buffer = await Offline(() => {
235
235
  const sig = new Signal(1).toDestination();
236
236
  sig.linearRampTo(50, 0.3, 0.2);
237
- }, 0.7).then((buffer) => {
238
- buffer.forEach((sample, time) => {
239
- if (time >= 0.6) {
240
- expect(sample).to.be.closeTo(50, 0.5);
241
- } else if (time < 0.2) {
242
- expect(sample).to.closeTo(1, 0.01);
243
- }
244
- });
237
+ }, 0.7);
238
+ buffer.forEach((sample, time) => {
239
+ if (time >= 0.6) {
240
+ expect(sample).to.be.closeTo(50, 0.5);
241
+ } else if (time < 0.2) {
242
+ expect(sample).to.closeTo(1, 0.01);
243
+ }
245
244
  });
246
245
  });
247
246
 
248
- it("can set a exponential approach ramp from the current time", () => {
249
- return Offline(() => {
247
+ it("can set a exponential approach ramp from the current time", async () => {
248
+ const buffer = await Offline(() => {
250
249
  const sig = new Signal(0).toDestination();
251
250
  sig.targetRampTo(1, 0.3);
252
- }, 0.5).then((buffer) => {
253
- expect(buffer.getValueAtTime(0)).to.be.below(0.0001);
254
- expect(buffer.getValueAtTime(0.3)).to.be.closeTo(1, 0.02);
255
- });
251
+ }, 0.5);
252
+ expect(buffer.getValueAtTime(0)).to.be.below(0.0001);
253
+ expect(buffer.getValueAtTime(0.3)).to.be.closeTo(1, 0.02);
256
254
  });
257
255
 
258
- it("can set an exponential approach ramp in the future", () => {
259
- return Offline(() => {
256
+ it("can set an exponential approach ramp in the future", async () => {
257
+ const buffer = await Offline(() => {
260
258
  const sig = new Signal(1).toDestination();
261
259
  sig.targetRampTo(50, 0.3, 0.2);
262
- }, 0.7).then((buffer) => {
263
- expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.0001);
264
- expect(buffer.getValueAtTime(0.2)).to.be.closeTo(1, 0.0001);
265
- expect(buffer.getValueAtTime(0.6)).to.be.closeTo(50, 0.5);
266
- });
260
+ }, 0.7);
261
+ expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.0001);
262
+ expect(buffer.getValueAtTime(0.2)).to.be.closeTo(1, 0.0001);
263
+ expect(buffer.getValueAtTime(0.6)).to.be.closeTo(50, 0.5);
267
264
  });
268
- it("can set an exponential ramp from the current time", () => {
269
- return Offline(() => {
265
+
266
+ it("can set an exponential ramp from the current time", async () => {
267
+ const buffer = await Offline(() => {
270
268
  const sig = new Signal(1).toDestination();
271
269
  sig.exponentialRampTo(50, 0.4);
272
- }, 0.6).then((buffer) => {
273
- buffer.forEach((sample, time) => {
274
- if (time >= 0.4) {
275
- expect(sample).to.be.closeTo(50, 0.5);
276
- } else if (time < 0.39) {
277
- expect(sample).to.be.lessThan(50);
278
- }
279
- });
270
+ }, 0.6);
271
+ buffer.forEach((sample, time) => {
272
+ if (time >= 0.4) {
273
+ expect(sample).to.be.closeTo(50, 0.5);
274
+ } else if (time < 0.39) {
275
+ expect(sample).to.be.lessThan(50);
276
+ }
280
277
  });
281
278
  });
282
279
 
283
- it("can set an exponential ramp in the future", () => {
284
- return Offline(() => {
280
+ it("can set an exponential ramp in the future", async () => {
281
+ const buffer = await Offline(() => {
285
282
  const sig = new Signal(1).toDestination();
286
283
  sig.exponentialRampTo(50, 0.3, 0.2);
287
- }, 0.8).then((buffer) => {
288
- buffer.forEach((sample, time) => {
289
- if (time >= 0.6) {
290
- expect(sample).to.be.closeTo(50, 0.5);
291
- } else if (time < 0.2) {
292
- expect(sample).to.equal(1);
293
- }
294
- });
284
+ }, 0.8);
285
+ buffer.forEach((sample, time) => {
286
+ if (time >= 0.6) {
287
+ expect(sample).to.be.closeTo(50, 0.5);
288
+ } else if (time < 0.2) {
289
+ expect(sample).to.equal(1);
290
+ }
295
291
  });
296
292
  });
297
293
 
298
- it("rampTo ramps from the current value", () => {
299
- return Offline(() => {
294
+ it("rampTo ramps from the current value", async () => {
295
+ const buffer = await Offline(() => {
300
296
  const sig = new Signal(3).toDestination();
301
297
  sig.rampTo(0.2, 0.1);
302
- }, 0.4).then((buffer) => {
303
- buffer.forEach((sample, time) => {
304
- if (time >= 0.1) {
305
- expect(sample).to.be.closeTo(0.2, 0.1);
306
- } else {
307
- expect(sample).to.be.greaterThan(0.2);
308
- }
309
- });
298
+ }, 0.4);
299
+ buffer.forEach((sample, time) => {
300
+ if (time >= 0.1) {
301
+ expect(sample).to.be.closeTo(0.2, 0.1);
302
+ } else {
303
+ expect(sample).to.be.greaterThan(0.2);
304
+ }
310
305
  });
311
306
  });
312
307
 
313
- it("rampTo ramps from the current value at a specific time", () => {
314
- return Offline(() => {
308
+ it("rampTo ramps from the current value at a specific time", async () => {
309
+ const buffer = await Offline(() => {
315
310
  const sig = new Signal(0).toDestination();
316
311
  sig.rampTo(2, 0.1, 0.4);
317
- }, 0.6).then((buffer) => {
318
- buffer.forEach((sample, time) => {
319
- if (time < 0.4) {
320
- expect(sample).to.be.closeTo(0, 0.1);
321
- } else if (time > 0.5) {
322
- expect(sample).to.be.closeTo(2, 0.1);
323
- }
324
- });
312
+ }, 0.6);
313
+ buffer.forEach((sample, time) => {
314
+ if (time < 0.4) {
315
+ expect(sample).to.be.closeTo(0, 0.1);
316
+ } else if (time > 0.5) {
317
+ expect(sample).to.be.closeTo(2, 0.1);
318
+ }
325
319
  });
326
320
  });
327
321
 
328
- it("can set a value curve", () => {
329
- return Offline(() => {
322
+ it("can set a value curve", async () => {
323
+ const buffer = await Offline(() => {
330
324
  const sig = new Signal(0).toDestination();
331
325
  sig.setValueCurveAtTime([0, 1, 0.5, 0.2], 0, 1);
332
- }, 1).then((buffer) => {
333
- expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
334
- expect(buffer.getValueAtTime(0.33 / 2)).to.be.closeTo(
335
- 0.5,
336
- 0.01
337
- );
338
- expect(buffer.getValueAtTime(0.33)).to.be.closeTo(1, 0.02);
339
- expect(buffer.getValueAtTime(0.66)).to.be.closeTo(0.5, 0.02);
340
- expect(buffer.getValueAtTime(0.99)).to.be.closeTo(0.2, 0.02);
341
- });
326
+ }, 1);
327
+ expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
328
+ expect(buffer.getValueAtTime(0.33 / 2)).to.be.closeTo(0.5, 0.01);
329
+ expect(buffer.getValueAtTime(0.33)).to.be.closeTo(1, 0.02);
330
+ expect(buffer.getValueAtTime(0.66)).to.be.closeTo(0.5, 0.02);
331
+ expect(buffer.getValueAtTime(0.99)).to.be.closeTo(0.2, 0.02);
342
332
  });
343
333
 
344
- it("can set a value curve in the future", () => {
345
- return Offline(() => {
334
+ it("can set a value curve in the future", async () => {
335
+ const buffer = await Offline(() => {
346
336
  const sig = new Signal(0).toDestination();
347
337
  sig.setValueCurveAtTime([0, 1, 0.5, 0.2], 0.5, 1);
348
- }, 1.5).then((buffer) => {
349
- expect(buffer.getValueAtTime(0 + 0.5)).to.be.closeTo(0, 0.01);
350
- expect(buffer.getValueAtTime(0.33 / 2 + 0.5)).to.be.closeTo(
351
- 0.5,
352
- 0.01
353
- );
354
- expect(buffer.getValueAtTime(0.33 + 0.5)).to.be.closeTo(
355
- 1,
356
- 0.02
357
- );
358
- expect(buffer.getValueAtTime(0.66 + 0.5)).to.be.closeTo(
359
- 0.5,
360
- 0.02
361
- );
362
- expect(buffer.getValueAtTime(0.99 + 0.5)).to.be.closeTo(
363
- 0.2,
364
- 0.02
365
- );
366
- });
367
- });
368
-
369
- it("can set an exponential approach", () => {
370
- return Offline(() => {
338
+ }, 1.5);
339
+ expect(buffer.getValueAtTime(0 + 0.5)).to.be.closeTo(0, 0.01);
340
+ expect(buffer.getValueAtTime(0.33 / 2 + 0.5)).to.be.closeTo(
341
+ 0.5,
342
+ 0.01
343
+ );
344
+ expect(buffer.getValueAtTime(0.33 + 0.5)).to.be.closeTo(1, 0.02);
345
+ expect(buffer.getValueAtTime(0.66 + 0.5)).to.be.closeTo(0.5, 0.02);
346
+ expect(buffer.getValueAtTime(0.99 + 0.5)).to.be.closeTo(0.2, 0.02);
347
+ });
348
+
349
+ it("can set an exponential approach", async () => {
350
+ const buffer = await Offline(() => {
371
351
  const sig = new Signal(0).toDestination();
372
352
  sig.exponentialApproachValueAtTime(2, 0.1, 0.5);
373
- }, 1).then((buffer) => {
374
- expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
375
- expect(buffer.getValueAtTime(0.1)).to.be.closeTo(0, 0.01);
376
- expect(buffer.getValueAtTime(0.4)).to.be.closeTo(1.9, 0.1);
377
- expect(buffer.getValueAtTime(0.6)).to.be.closeTo(2, 0.01);
378
- });
353
+ }, 1);
354
+ expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
355
+ expect(buffer.getValueAtTime(0.1)).to.be.closeTo(0, 0.01);
356
+ expect(buffer.getValueAtTime(0.4)).to.be.closeTo(1.9, 0.1);
357
+ expect(buffer.getValueAtTime(0.6)).to.be.closeTo(2, 0.01);
379
358
  });
380
359
 
381
- it("can set a target at time", () => {
382
- return Offline(() => {
360
+ it("can set a target at time", async () => {
361
+ const buffer = await Offline(() => {
383
362
  const sig = new Signal(0).toDestination();
384
363
  sig.setTargetAtTime(2, 0.1, 0.1);
385
- }, 1).then((buffer) => {
386
- expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
387
- expect(buffer.getValueAtTime(0.6)).to.be.closeTo(2, 0.1);
388
- });
364
+ }, 1);
365
+ expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.01);
366
+ expect(buffer.getValueAtTime(0.6)).to.be.closeTo(2, 0.1);
389
367
  });
390
368
  });
391
369
 
@@ -507,20 +485,19 @@ describe("Signal", () => {
507
485
  }, 0);
508
486
  });
509
487
 
510
- it("can ramp along with the bpm", () => {
511
- return Offline(({ transport }) => {
488
+ it("can ramp along with the bpm", async () => {
489
+ const buffer = await Offline(({ transport }) => {
512
490
  transport.bpm.value = 120;
513
491
  const sig = new Signal(2).toDestination();
514
492
  transport.syncSignal(sig);
515
493
  transport.bpm.rampTo(240, 0.5);
516
- }).then((buffer) => {
517
- buffer.forEach((sample, time) => {
518
- if (time >= 0.5) {
519
- expect(sample).to.be.closeTo(4, 0.04);
520
- } else if (time < 0.4) {
521
- expect(sample).to.be.within(1.95, 3);
522
- }
523
- });
494
+ });
495
+ buffer.forEach((sample, time) => {
496
+ if (time >= 0.5) {
497
+ expect(sample).to.be.closeTo(4, 0.04);
498
+ } else if (time < 0.4) {
499
+ expect(sample).to.be.within(1.95, 3);
500
+ }
524
501
  });
525
502
  });
526
503