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
@@ -60,23 +60,22 @@ describe("Transport", () => {
60
60
  });
61
61
  });
62
62
 
63
- it("can loop events scheduled on the transport", () => {
63
+ it("can loop events scheduled on the transport", async () => {
64
64
  let invocations = 0;
65
- return Offline((context) => {
65
+ await Offline((context) => {
66
66
  const transport = new TransportClass({ context });
67
67
  transport.schedule((time) => {
68
68
  invocations++;
69
69
  }, 0);
70
70
  transport.setLoopPoints(0, 0.1).start(0);
71
71
  transport.loop = true;
72
- }, 0.41).then(() => {
73
- expect(invocations).to.equal(5);
74
- });
72
+ }, 0.41);
73
+ expect(invocations).to.equal(5);
75
74
  });
76
75
 
77
- it("jumps to the loopStart after the loopEnd point", () => {
76
+ it("jumps to the loopStart after the loopEnd point", async () => {
78
77
  let looped = false;
79
- return Offline((context) => {
78
+ await Offline((context) => {
80
79
  const transport = new TransportClass({ context });
81
80
  transport.on("loop", () => {
82
81
  looped = true;
@@ -85,9 +84,8 @@ describe("Transport", () => {
85
84
  transport.loopEnd = 1;
86
85
  transport.seconds = 2;
87
86
  transport.start();
88
- }, 0.4).then(() => {
89
- expect(looped).to.equal(true);
90
- });
87
+ }, 0.4);
88
+ expect(looped).to.equal(true);
91
89
  });
92
90
  });
93
91
 
@@ -99,8 +97,8 @@ describe("Transport", () => {
99
97
  });
100
98
  });
101
99
 
102
- it("can get the next subdivision of the transport", () => {
103
- return Offline((context) => {
100
+ it("can get the next subdivision of the transport", async () => {
101
+ await Offline((context) => {
104
102
  const transport = new TransportClass({ context });
105
103
  transport.start(0);
106
104
  return (time) => {
@@ -278,8 +276,8 @@ describe("Transport", () => {
278
276
  });
279
277
 
280
278
  context("state", () => {
281
- it("can start, pause, and restart", () => {
282
- return Offline(({ transport }) => {
279
+ it("can start, pause, and restart", async () => {
280
+ const buffer = await Offline(({ transport }) => {
283
281
  transport.start(0).pause(0.2).start(0.4);
284
282
 
285
283
  const pulse = new Signal(0).toDestination();
@@ -307,17 +305,16 @@ describe("Transport", () => {
307
305
  expect(transport.state).to.equal("started");
308
306
  });
309
307
  };
310
- }, 0.6).then((buffer) => {
311
- buffer.forEach((sample, time) => {
312
- whenBetween(time, 0, 0.01, () => {
313
- expect(sample).to.equal(1);
314
- });
315
- whenBetween(time, 0.1, 0.11, () => {
316
- expect(sample).to.equal(0);
317
- });
318
- whenBetween(time, 0.502, 0.51, () => {
319
- expect(sample).to.equal(1);
320
- });
308
+ }, 0.6);
309
+ buffer.forEach((sample, time) => {
310
+ whenBetween(time, 0, 0.01, () => {
311
+ expect(sample).to.equal(1);
312
+ });
313
+ whenBetween(time, 0.1, 0.11, () => {
314
+ expect(sample).to.equal(0);
315
+ });
316
+ whenBetween(time, 0.502, 0.51, () => {
317
+ expect(sample).to.equal(1);
321
318
  });
322
319
  });
323
320
  });
@@ -372,8 +369,8 @@ describe("Transport", () => {
372
369
  }, 0.1);
373
370
  });
374
371
 
375
- it("can toggle the state of the transport", () => {
376
- return Offline((context) => {
372
+ it("can toggle the state of the transport", async () => {
373
+ await Offline((context) => {
377
374
  const transport = new TransportClass({ context });
378
375
  transport.toggle(0);
379
376
  transport.toggle(0.2);
@@ -390,8 +387,8 @@ describe("Transport", () => {
390
387
  }, 0.1);
391
388
  });
392
389
 
393
- it("tracks ticks correctly with a different PPQ and BPM", () => {
394
- return Offline((context) => {
390
+ it("tracks ticks correctly with a different PPQ and BPM", async () => {
391
+ await Offline((context) => {
395
392
  const transport = new TransportClass({ context });
396
393
  transport.PPQ = 96;
397
394
  transport.bpm.value = 90;
@@ -405,10 +402,10 @@ describe("Transport", () => {
405
402
  }, 0.6);
406
403
  });
407
404
 
408
- it("can set the ticks while started", () => {
405
+ it("can set the ticks while started", async () => {
409
406
  let invocations = 0;
410
407
  const times = [0, 1.5];
411
- return Offline(({ transport }) => {
408
+ await Offline(({ transport }) => {
412
409
  transport.PPQ = 1;
413
410
  transport.schedule((time) => {
414
411
  expect(time).to.be.closeTo(times[invocations], 0.01);
@@ -418,9 +415,8 @@ describe("Transport", () => {
418
415
  return atTime(1.1, () => {
419
416
  transport.ticks = 0;
420
417
  });
421
- }, 2.5).then(() => {
422
- expect(invocations).to.equal(2);
423
- });
418
+ }, 2.5);
419
+ expect(invocations).to.equal(2);
424
420
  });
425
421
  });
426
422
 
@@ -433,9 +429,9 @@ describe("Transport", () => {
433
429
  });
434
430
  });
435
431
 
436
- it("scheduled event gets invoked with the time of the event", () => {
432
+ it("scheduled event gets invoked with the time of the event", async () => {
437
433
  let wasCalled = false;
438
- return Offline((context) => {
434
+ await Offline((context) => {
439
435
  const transport = new TransportClass({ context });
440
436
  const startTime = 0.1;
441
437
  transport.schedule((time) => {
@@ -443,14 +439,13 @@ describe("Transport", () => {
443
439
  wasCalled = true;
444
440
  }, 0);
445
441
  transport.start(startTime);
446
- }, 0.2).then(() => {
447
- expect(wasCalled).to.equal(true);
448
- });
442
+ }, 0.2);
443
+ expect(wasCalled).to.equal(true);
449
444
  });
450
445
 
451
- it("can schedule events with TransportTime", () => {
446
+ it("can schedule events with TransportTime", async () => {
452
447
  let wasCalled = false;
453
- return Offline((context) => {
448
+ await Offline((context) => {
454
449
  const transport = new TransportClass({ context });
455
450
  const startTime = 0.1;
456
451
  const eighth = transport.toSeconds("8n");
@@ -459,9 +454,8 @@ describe("Transport", () => {
459
454
  wasCalled = true;
460
455
  }, TransportTime("8n"));
461
456
  transport.start(startTime);
462
- }, 0.5).then(() => {
463
- expect(wasCalled).to.equal(true);
464
- });
457
+ }, 0.5);
458
+ expect(wasCalled).to.be.true;
465
459
  });
466
460
 
467
461
  it("can clear a scheduled event", () => {
@@ -497,9 +491,9 @@ describe("Transport", () => {
497
491
  });
498
492
  });
499
493
 
500
- it("scheduled event anywhere along the timeline", () => {
494
+ it("scheduled event anywhere along the timeline", async () => {
501
495
  let wasCalled = false;
502
- return Offline((context) => {
496
+ await Offline((context) => {
503
497
  const transport = new TransportClass({ context });
504
498
  const startTime = transport.now();
505
499
  transport.schedule((time) => {
@@ -507,14 +501,13 @@ describe("Transport", () => {
507
501
  wasCalled = true;
508
502
  }, 0.5);
509
503
  transport.start(startTime);
510
- }, 0.6).then(() => {
511
- expect(wasCalled).to.equal(true);
512
- });
504
+ }, 0.6);
505
+ expect(wasCalled).to.equal(true);
513
506
  });
514
507
 
515
- it("can schedule multiple events and invoke them in the right order", () => {
508
+ it("can schedule multiple events and invoke them in the right order", async () => {
516
509
  let wasCalled = false;
517
- return Offline((context) => {
510
+ await Offline((context) => {
518
511
  const transport = new TransportClass({ context });
519
512
  let first = false;
520
513
  transport.schedule(() => {
@@ -525,27 +518,25 @@ describe("Transport", () => {
525
518
  wasCalled = true;
526
519
  }, 0.11);
527
520
  transport.start();
528
- }, 0.2).then(() => {
529
- expect(wasCalled).to.equal(true);
530
- });
521
+ }, 0.2);
522
+ expect(wasCalled).to.equal(true);
531
523
  });
532
524
 
533
- it("invokes the event again if the timeline is restarted", () => {
525
+ it("invokes the event again if the timeline is restarted", async () => {
534
526
  let iterations = 0;
535
- return Offline((context) => {
527
+ await Offline((context) => {
536
528
  const transport = new TransportClass({ context });
537
529
  transport.schedule(() => {
538
530
  iterations++;
539
531
  }, 0.05);
540
532
  transport.start(0).stop(0.1).start(0.2);
541
- }, 0.3).then(() => {
542
- expect(iterations).to.be.equal(2);
543
- });
533
+ }, 0.3);
534
+ expect(iterations).to.be.equal(2);
544
535
  });
545
536
 
546
- it("can add an event after the Transport is started", () => {
537
+ it("can add an event after the Transport is started", async () => {
547
538
  let wasCalled = false;
548
- return Offline((context) => {
539
+ await Offline((context) => {
549
540
  const transport = new TransportClass({ context });
550
541
  transport.start(0);
551
542
  let wasScheduled = false;
@@ -557,13 +548,12 @@ describe("Transport", () => {
557
548
  }, 0.15);
558
549
  }
559
550
  };
560
- }, 0.3).then(() => {
561
- expect(wasCalled).to.equal(true);
562
- });
551
+ }, 0.3);
552
+ expect(wasCalled).to.equal(true);
563
553
  });
564
554
 
565
555
  it("warns if the scheduled time was not used in the callback", async () => {
566
- return Offline(({ transport }) => {
556
+ await Offline(({ transport }) => {
567
557
  const synth = new Synth();
568
558
  transport.schedule(() => {
569
559
  warns(() => {
@@ -571,7 +561,7 @@ describe("Transport", () => {
571
561
  });
572
562
  }, 0);
573
563
  transport.start(0);
574
- }, 0.3).then(() => {});
564
+ }, 0.3);
575
565
  });
576
566
  });
577
567
 
@@ -584,9 +574,9 @@ describe("Transport", () => {
584
574
  });
585
575
  });
586
576
 
587
- it("scheduled event gets invoked with the time of the event", () => {
577
+ it("scheduled event gets invoked with the time of the event", async () => {
588
578
  let invoked = false;
589
- return Offline((context) => {
579
+ await Offline((context) => {
590
580
  const transport = new TransportClass({ context });
591
581
  const startTime = 0.1;
592
582
  const eventID = transport.scheduleRepeat(
@@ -599,9 +589,8 @@ describe("Transport", () => {
599
589
  0
600
590
  );
601
591
  transport.start(startTime);
602
- }, 0.3).then(() => {
603
- expect(invoked).to.equal(true);
604
- });
592
+ }, 0.3);
593
+ expect(invoked).to.equal(true);
605
594
  });
606
595
 
607
596
  it("can cancel the timeline of scheduleRepeat", () => {
@@ -619,9 +608,9 @@ describe("Transport", () => {
619
608
  });
620
609
  });
621
610
 
622
- it("can schedule events with TransportTime", () => {
611
+ it("can schedule events with TransportTime", async () => {
623
612
  let invoked = false;
624
- return Offline((context) => {
613
+ await Offline((context) => {
625
614
  const transport = new TransportClass({ context });
626
615
  const startTime = 0.1;
627
616
  const eighth = transport.toSeconds("8n");
@@ -634,9 +623,8 @@ describe("Transport", () => {
634
623
  TransportTime("8n")
635
624
  );
636
625
  transport.start(startTime);
637
- }, 0.4).then(() => {
638
- expect(invoked).to.equal(true);
639
- });
626
+ }, 0.4);
627
+ expect(invoked).to.equal(true);
640
628
  });
641
629
 
642
630
  it("can clear a scheduled event", () => {
@@ -654,9 +642,9 @@ describe("Transport", () => {
654
642
  });
655
643
  });
656
644
 
657
- it("can be scheduled in the future", () => {
645
+ it("can be scheduled in the future", async () => {
658
646
  let invoked = false;
659
- return Offline((context) => {
647
+ await Offline((context) => {
660
648
  const transport = new TransportClass({ context });
661
649
  const startTime = 0.1;
662
650
  const eventID = transport.scheduleRepeat(
@@ -669,14 +657,13 @@ describe("Transport", () => {
669
657
  0.2
670
658
  );
671
659
  transport.start(startTime);
672
- }, 0.5).then(() => {
673
- expect(invoked).to.equal(true);
674
- });
660
+ }, 0.5);
661
+ expect(invoked).to.equal(true);
675
662
  });
676
663
 
677
- it("repeats a repeat event", () => {
664
+ it("repeats a repeat event", async () => {
678
665
  let invocations = 0;
679
- return Offline((context) => {
666
+ await Offline((context) => {
680
667
  const transport = new TransportClass({ context });
681
668
  transport.scheduleRepeat(
682
669
  () => {
@@ -686,14 +673,13 @@ describe("Transport", () => {
686
673
  0
687
674
  );
688
675
  transport.start();
689
- }, 0.51).then(() => {
690
- expect(invocations).to.equal(6);
691
- });
676
+ }, 0.51);
677
+ expect(invocations).to.equal(6);
692
678
  });
693
679
 
694
- it("repeats at the repeat interval", () => {
680
+ it("repeats at the repeat interval", async () => {
695
681
  let wasCalled = false;
696
- return Offline((context) => {
682
+ await Offline((context) => {
697
683
  const transport = new TransportClass({ context });
698
684
  let repeatTime = -1;
699
685
  transport.scheduleRepeat(
@@ -708,15 +694,14 @@ describe("Transport", () => {
708
694
  0
709
695
  );
710
696
  transport.start();
711
- }, 0.5).then(() => {
712
- expect(wasCalled).to.equal(true);
713
- });
697
+ }, 0.5);
698
+ expect(wasCalled).to.equal(true);
714
699
  });
715
700
 
716
- it("can schedule multiple events and invoke them in the right order", () => {
701
+ it("can schedule multiple events and invoke them in the right order", async () => {
717
702
  let first = false;
718
703
  let second = false;
719
- return Offline((context) => {
704
+ await Offline((context) => {
720
705
  const transport = new TransportClass({ context });
721
706
  const firstID = transport.scheduleRepeat(
722
707
  () => {
@@ -736,15 +721,14 @@ describe("Transport", () => {
736
721
  0.11
737
722
  );
738
723
  transport.start();
739
- }, 0.3).then(() => {
740
- expect(first);
741
- expect(second);
742
- });
724
+ }, 0.3);
725
+ expect(first);
726
+ expect(second);
743
727
  });
744
728
 
745
- it("repeats for the given interval", () => {
729
+ it("repeats for the given interval", async () => {
746
730
  let repeatCount = 0;
747
- return Offline((context) => {
731
+ await Offline((context) => {
748
732
  const transport = new TransportClass({ context });
749
733
  transport.scheduleRepeat(
750
734
  (time) => {
@@ -755,14 +739,13 @@ describe("Transport", () => {
755
739
  0.5
756
740
  );
757
741
  transport.start();
758
- }, 0.61).then(() => {
759
- expect(repeatCount).to.equal(5);
760
- });
742
+ }, 0.61);
743
+ expect(repeatCount).to.equal(5);
761
744
  });
762
745
 
763
- it("can add an event after the Transport is started", () => {
746
+ it("can add an event after the Transport is started", async () => {
764
747
  let invocations = 0;
765
- return Offline((context) => {
748
+ await Offline((context) => {
766
749
  const transport = new TransportClass({ context });
767
750
  transport.start(0);
768
751
  let wasScheduled = false;
@@ -783,14 +766,13 @@ describe("Transport", () => {
783
766
  );
784
767
  }
785
768
  };
786
- }, 0.31).then(() => {
787
- expect(invocations).to.equal(2);
788
- });
769
+ }, 0.31);
770
+ expect(invocations).to.equal(2);
789
771
  });
790
772
 
791
- it("can add an event to the past after the Transport is started", () => {
773
+ it("can add an event to the past after the Transport is started", async () => {
792
774
  let invocations = 0;
793
- return Offline((context) => {
775
+ await Offline((context) => {
794
776
  const transport = new TransportClass({ context });
795
777
  transport.start(0);
796
778
  let wasScheduled = false;
@@ -811,9 +793,8 @@ describe("Transport", () => {
811
793
  );
812
794
  }
813
795
  };
814
- }, 0.3).then(() => {
815
- expect(invocations).to.equal(2);
816
- });
796
+ }, 0.3);
797
+ expect(invocations).to.equal(2);
817
798
  });
818
799
  });
819
800
 
@@ -826,9 +807,9 @@ describe("Transport", () => {
826
807
  });
827
808
  });
828
809
 
829
- it("scheduled event gets invoked with the time of the event", () => {
810
+ it("scheduled event gets invoked with the time of the event", async () => {
830
811
  let invoked = false;
831
- return Offline((context) => {
812
+ await Offline((context) => {
832
813
  const transport = new TransportClass({ context });
833
814
  const startTime = 0.1;
834
815
  const eventID = transport.scheduleOnce((time) => {
@@ -837,14 +818,13 @@ describe("Transport", () => {
837
818
  expect(time).to.be.closeTo(startTime, 0.01);
838
819
  }, 0);
839
820
  transport.start(startTime);
840
- }, 0.2).then(() => {
841
- expect(invoked).to.equal(true);
842
- });
821
+ }, 0.2);
822
+ expect(invoked).to.equal(true);
843
823
  });
844
824
 
845
- it("can schedule events with TransportTime", () => {
825
+ it("can schedule events with TransportTime", async () => {
846
826
  let invoked = false;
847
- return Offline((context) => {
827
+ await Offline((context) => {
848
828
  const transport = new TransportClass({ context });
849
829
  const startTime = 0.1;
850
830
  const eighth = transport.toSeconds("8n");
@@ -853,9 +833,8 @@ describe("Transport", () => {
853
833
  invoked = true;
854
834
  }, TransportTime("8n"));
855
835
  transport.start(startTime);
856
- }, 0.5).then(() => {
857
- expect(invoked).to.equal(true);
858
- });
836
+ }, 0.5);
837
+ expect(invoked).to.equal(true);
859
838
  });
860
839
 
861
840
  it("can clear a scheduled event", () => {
@@ -869,9 +848,9 @@ describe("Transport", () => {
869
848
  });
870
849
  });
871
850
 
872
- it("can be scheduled in the future", () => {
851
+ it("can be scheduled in the future", async () => {
873
852
  let invoked = false;
874
- return Offline((context) => {
853
+ await Offline((context) => {
875
854
  const transport = new TransportClass({ context });
876
855
  const startTime = transport.now() + 0.1;
877
856
  const eventID = transport.scheduleOnce((time) => {
@@ -880,29 +859,27 @@ describe("Transport", () => {
880
859
  invoked = true;
881
860
  }, 0.3);
882
861
  transport.start(startTime);
883
- }, 0.5).then(() => {
884
- expect(invoked).to.equal(true);
885
- });
862
+ }, 0.5);
863
+ expect(invoked).to.equal(true);
886
864
  });
887
865
 
888
- it("the event is removed after is is invoked", () => {
866
+ it("the event is removed after is is invoked", async () => {
889
867
  let iterations = 0;
890
- return Offline((context) => {
868
+ await Offline((context) => {
891
869
  const transport = new TransportClass({ context });
892
870
  transport.scheduleOnce(() => {
893
871
  iterations++;
894
872
  }, 0);
895
873
  transport.start().stop("+0.1").start("+0.2");
896
- }, 0.5).then(() => {
897
- expect(iterations).to.be.lessThan(2);
898
- });
874
+ }, 0.5);
875
+ expect(iterations).to.be.lessThan(2);
899
876
  });
900
877
  });
901
878
 
902
879
  context("events", () => {
903
- it("invokes start/stop/pause events", () => {
880
+ it("invokes start/stop/pause events", async () => {
904
881
  let invocations = 0;
905
- return Offline((context) => {
882
+ await Offline((context) => {
906
883
  const transport = new TransportClass({ context });
907
884
  transport.on("start", () => {
908
885
  invocations++;
@@ -914,14 +891,13 @@ describe("Transport", () => {
914
891
  invocations++;
915
892
  });
916
893
  transport.start().stop(0.1).start(0.2);
917
- }, 0.5).then(() => {
918
- expect(invocations).to.equal(3);
919
- });
894
+ }, 0.5);
895
+ expect(invocations).to.equal(3);
920
896
  });
921
897
 
922
- it("invokes start event with correct offset", () => {
898
+ it("invokes start event with correct offset", async () => {
923
899
  let wasCalled = false;
924
- return Offline((context) => {
900
+ await Offline((context) => {
925
901
  const transport = new TransportClass({ context });
926
902
  transport.on("start", (time, offset) => {
927
903
  expect(time).to.be.closeTo(0.2, 0.01);
@@ -929,14 +905,13 @@ describe("Transport", () => {
929
905
  wasCalled = true;
930
906
  });
931
907
  transport.start(0.2, "4n");
932
- }, 0.3).then(() => {
933
- expect(wasCalled).to.equal(true);
934
- });
908
+ }, 0.3);
909
+ expect(wasCalled).to.equal(true);
935
910
  });
936
911
 
937
- it("invokes the event just before the scheduled time", () => {
912
+ it("invokes the event just before the scheduled time", async () => {
938
913
  let invoked = false;
939
- return Offline((context) => {
914
+ await Offline((context) => {
940
915
  const transport = new TransportClass({ context });
941
916
  transport.on("start", (time, offset) => {
942
917
  expect(time - transport.context.currentTime).to.be.closeTo(
@@ -947,14 +922,13 @@ describe("Transport", () => {
947
922
  invoked = true;
948
923
  });
949
924
  transport.start(0.2);
950
- }, 0.3).then(() => {
951
- expect(invoked).to.equal(true);
952
- });
925
+ }, 0.3);
926
+ expect(invoked).to.equal(true);
953
927
  });
954
928
 
955
- it("passes in the time argument to the events", () => {
929
+ it("passes in the time argument to the events", async () => {
956
930
  let invocations = 0;
957
- return Offline((context) => {
931
+ await Offline((context) => {
958
932
  const transport = new TransportClass({ context });
959
933
  const now = transport.now();
960
934
  transport.on("start", (time) => {
@@ -966,14 +940,13 @@ describe("Transport", () => {
966
940
  expect(time).to.be.closeTo(now + 0.2, 0.01);
967
941
  });
968
942
  transport.start("+0.1").stop("+0.2");
969
- }, 0.3).then(() => {
970
- expect(invocations).to.equal(2);
971
- });
943
+ }, 0.3);
944
+ expect(invocations).to.equal(2);
972
945
  });
973
946
 
974
- it("invokes the 'loop' method on loop", () => {
947
+ it("invokes the 'loop' method on loop", async () => {
975
948
  let loops = 0;
976
- return Offline((context) => {
949
+ await Offline((context) => {
977
950
  const transport = new TransportClass({ context });
978
951
  const sixteenth = transport.toSeconds("16n");
979
952
  transport.setLoopPoints(0, sixteenth);
@@ -987,9 +960,8 @@ describe("Transport", () => {
987
960
  lastLoop = time;
988
961
  });
989
962
  transport.start(0).stop(sixteenth * 5.1);
990
- }, 0.7).then(() => {
991
- expect(loops).to.equal(5);
992
- });
963
+ }, 0.7);
964
+ expect(loops).to.equal(5);
993
965
  });
994
966
  });
995
967
 
@@ -1014,9 +986,9 @@ describe("Transport", () => {
1014
986
  });
1015
987
  });
1016
988
 
1017
- it("can swing", () => {
989
+ it("can swing", async () => {
1018
990
  let invocations = 0;
1019
- return Offline((context) => {
991
+ await Offline((context) => {
1020
992
  const transport = new TransportClass({ context });
1021
993
  transport.swing = 1;
1022
994
  transport.swingSubdivision = "8n";
@@ -1042,9 +1014,8 @@ describe("Transport", () => {
1042
1014
  expect(time).is.closeTo(eightNote * 2, 0.001);
1043
1015
  }, "4n");
1044
1016
  transport.start(0).stop(0.7);
1045
- }, 0.7).then(() => {
1046
- expect(invocations).to.equal(4);
1047
- });
1017
+ }, 0.7);
1018
+ expect(invocations).to.equal(4);
1048
1019
  });
1049
1020
  });
1050
1021
  });
@@ -25,9 +25,9 @@ describe("TransportEvent", () => {
25
25
  });
26
26
  });
27
27
 
28
- it("can invoke the callback", () => {
28
+ it("can invoke the callback", async () => {
29
29
  let wasInvoked = false;
30
- return Offline((context) => {
30
+ await Offline((context) => {
31
31
  const transport = new TransportClass({ context });
32
32
  const event = new TransportEvent(transport, {
33
33
  callback: (time) => {
@@ -37,8 +37,7 @@ describe("TransportEvent", () => {
37
37
  time: 0,
38
38
  });
39
39
  event.invoke(100);
40
- }).then(() => {
41
- expect(wasInvoked).to.equal(true);
42
40
  });
41
+ expect(wasInvoked).to.equal(true);
43
42
  });
44
43
  });