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.
- package/Tone/component/analysis/Follower.test.ts +38 -42
- package/Tone/component/channel/Channel.test.ts +3 -4
- package/Tone/component/channel/Merge.test.ts +5 -6
- package/Tone/component/channel/MidSideSplit.test.ts +21 -25
- package/Tone/component/channel/Mono.test.ts +18 -20
- package/Tone/component/channel/PanVol.test.ts +3 -4
- package/Tone/component/channel/Panner.test.ts +28 -32
- package/Tone/component/channel/Recorder.ts +1 -1
- package/Tone/component/channel/Volume.test.ts +9 -12
- package/Tone/component/dynamics/Gate.test.ts +10 -14
- package/Tone/component/envelope/AmplitudeEnvelope.test.ts +7 -9
- package/Tone/component/envelope/Envelope.test.ts +347 -384
- package/Tone/component/filter/BiquadFilter.test.ts +5 -6
- package/Tone/component/filter/Convolver.test.ts +6 -9
- package/Tone/component/filter/FeedbackCombFilter.test.ts +14 -16
- package/Tone/component/filter/Filter.test.ts +5 -6
- package/Tone/component/filter/LowpassCombFilter.test.ts +15 -17
- package/Tone/core/clock/Clock.test.ts +12 -15
- package/Tone/core/clock/TickSignal.test.ts +18 -21
- package/Tone/core/clock/Transport.test.ts +133 -162
- package/Tone/core/clock/TransportEvent.test.ts +3 -4
- package/Tone/core/clock/TransportRepeatEvent.test.ts +6 -6
- package/Tone/core/context/Context.test.ts +8 -10
- package/Tone/core/context/Context.ts +8 -4
- package/Tone/core/context/Destination.test.ts +3 -4
- package/Tone/core/context/Offline.test.ts +23 -41
- package/Tone/core/context/OfflineContext.test.ts +20 -22
- package/Tone/core/context/Param.test.ts +33 -40
- package/Tone/core/context/ToneAudioBuffer.test.ts +3 -10
- package/Tone/core/context/ToneAudioBuffers.test.ts +9 -13
- package/Tone/core/worklet/ToneAudioWorklet.ts +3 -1
- package/Tone/effect/AutoFilter.test.ts +10 -12
- package/Tone/effect/AutoPanner.test.ts +10 -12
- package/Tone/effect/Chorus.test.ts +10 -14
- package/Tone/effect/FrequencyShifter.test.ts +6 -7
- package/Tone/effect/Reverb.test.ts +12 -15
- package/Tone/effect/Tremolo.test.ts +10 -12
- package/Tone/event/Loop.test.ts +29 -36
- package/Tone/event/Part.test.ts +152 -180
- package/Tone/event/Pattern.test.ts +16 -20
- package/Tone/event/Sequence.test.ts +86 -101
- package/Tone/event/ToneEvent.test.ts +60 -70
- package/Tone/instrument/MonoSynth.test.ts +3 -4
- package/Tone/instrument/PolySynth.test.ts +62 -74
- package/Tone/instrument/Sampler.test.ts +39 -48
- package/Tone/instrument/Synth.test.ts +40 -47
- package/Tone/signal/AudioToGain.test.ts +4 -5
- package/Tone/signal/Signal.test.ts +120 -143
- package/Tone/signal/SyncedSignal.test.ts +108 -122
- package/Tone/signal/ToneConstantSource.test.ts +21 -25
- package/Tone/signal/WaveShaper.test.ts +5 -6
- package/Tone/source/Source.test.ts +42 -48
- package/Tone/source/buffer/GrainPlayer.test.ts +29 -35
- package/Tone/source/buffer/Player.test.ts +162 -191
- package/Tone/source/buffer/Players.test.ts +44 -50
- package/Tone/source/buffer/ToneBufferSource.test.ts +176 -211
- package/Tone/source/oscillator/LFO.test.ts +49 -61
- package/Tone/source/oscillator/Oscillator.test.ts +24 -28
- package/Tone/source/oscillator/PulseOscillator.test.ts +36 -40
- package/Tone/source/oscillator/ToneOscillatorNode.test.ts +25 -29
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/component/channel/Recorder.js.map +1 -1
- package/build/esm/core/context/Context.js +6 -3
- package/build/esm/core/context/Context.js.map +1 -1
- package/build/esm/core/worklet/ToneAudioWorklet.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
package/Tone/event/Part.test.ts
CHANGED
|
@@ -11,8 +11,8 @@ describe("Part", () => {
|
|
|
11
11
|
BasicTests(Part);
|
|
12
12
|
|
|
13
13
|
context("Constructor", () => {
|
|
14
|
-
it("takes a callback and an array of values", () => {
|
|
15
|
-
|
|
14
|
+
it("takes a callback and an array of values", async () => {
|
|
15
|
+
await Offline(() => {
|
|
16
16
|
const callback = noOp;
|
|
17
17
|
const part = new Part(callback, [0, 1, 2]);
|
|
18
18
|
expect(part.callback).to.equal(callback);
|
|
@@ -21,16 +21,16 @@ describe("Part", () => {
|
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it("can be constructed with no arguments", () => {
|
|
25
|
-
|
|
24
|
+
it("can be constructed with no arguments", async () => {
|
|
25
|
+
await Offline(() => {
|
|
26
26
|
const part = new Part();
|
|
27
27
|
expect(part.length).to.equal(0);
|
|
28
28
|
part.dispose();
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
it("can pass in arguments in options object", () => {
|
|
33
|
-
|
|
32
|
+
it("can pass in arguments in options object", async () => {
|
|
33
|
+
await Offline(() => {
|
|
34
34
|
const callback = noOp;
|
|
35
35
|
const part = new Part({
|
|
36
36
|
callback,
|
|
@@ -52,16 +52,16 @@ describe("Part", () => {
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
context("Adding / Removing / Getting Events", () => {
|
|
55
|
-
it("can take events in the constructor as an array of times", () => {
|
|
56
|
-
|
|
55
|
+
it("can take events in the constructor as an array of times", async () => {
|
|
56
|
+
await Offline(() => {
|
|
57
57
|
const part = new Part(noOp, ["0", "8n", "4n"]);
|
|
58
58
|
expect(part.length).to.equal(3);
|
|
59
59
|
part.dispose();
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
it("can take events in the constructor as an array of times and values", () => {
|
|
64
|
-
|
|
63
|
+
it("can take events in the constructor as an array of times and values", async () => {
|
|
64
|
+
await Offline(() => {
|
|
65
65
|
const part = new Part(noOp, [
|
|
66
66
|
["0", "C4"],
|
|
67
67
|
["8n", "D3"],
|
|
@@ -72,8 +72,8 @@ describe("Part", () => {
|
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
it("can retrieve an event using 'at'", () => {
|
|
76
|
-
|
|
75
|
+
it("can retrieve an event using 'at'", async () => {
|
|
76
|
+
await Offline(() => {
|
|
77
77
|
const part = new Part(noOp, [
|
|
78
78
|
["0", 0],
|
|
79
79
|
["8n", "C2"],
|
|
@@ -89,8 +89,8 @@ describe("Part", () => {
|
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
it("can set the value of an existing event with 'at'", () => {
|
|
93
|
-
|
|
92
|
+
it("can set the value of an existing event with 'at'", async () => {
|
|
93
|
+
await Offline(() => {
|
|
94
94
|
const part = new Part({
|
|
95
95
|
events: [[0, "C3"]],
|
|
96
96
|
});
|
|
@@ -102,8 +102,8 @@ describe("Part", () => {
|
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
it("can take events in the constructor as an array of objects", () => {
|
|
106
|
-
|
|
105
|
+
it("can take events in the constructor as an array of objects", async () => {
|
|
106
|
+
await Offline(() => {
|
|
107
107
|
const part = new Part(noOp, [
|
|
108
108
|
{
|
|
109
109
|
note: "C3",
|
|
@@ -121,9 +121,9 @@ describe("Part", () => {
|
|
|
121
121
|
});
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
it("can cancel event changes", () => {
|
|
124
|
+
it("can cancel event changes", async () => {
|
|
125
125
|
let count = 0;
|
|
126
|
-
|
|
126
|
+
await Offline(({ transport }) => {
|
|
127
127
|
const part = new Part(
|
|
128
128
|
(time) => {
|
|
129
129
|
count++;
|
|
@@ -143,13 +143,12 @@ describe("Part", () => {
|
|
|
143
143
|
.stop(0.1);
|
|
144
144
|
part.cancel(0.1);
|
|
145
145
|
transport.start(0);
|
|
146
|
-
}, 0.3)
|
|
147
|
-
|
|
148
|
-
});
|
|
146
|
+
}, 0.3);
|
|
147
|
+
expect(count).to.equal(2);
|
|
149
148
|
});
|
|
150
149
|
|
|
151
|
-
it("can add an event as a time and value", () => {
|
|
152
|
-
|
|
150
|
+
it("can add an event as a time and value", async () => {
|
|
151
|
+
await Offline(() => {
|
|
153
152
|
const part = new Part();
|
|
154
153
|
expect(part.length).to.equal(0);
|
|
155
154
|
part.add(1, "D3");
|
|
@@ -159,8 +158,8 @@ describe("Part", () => {
|
|
|
159
158
|
});
|
|
160
159
|
});
|
|
161
160
|
|
|
162
|
-
it("can add an event as an object", () => {
|
|
163
|
-
|
|
161
|
+
it("can add an event as an object", async () => {
|
|
162
|
+
await Offline(() => {
|
|
164
163
|
const part = new Part();
|
|
165
164
|
expect(part.length).to.equal(0);
|
|
166
165
|
part.add({
|
|
@@ -180,8 +179,8 @@ describe("Part", () => {
|
|
|
180
179
|
});
|
|
181
180
|
});
|
|
182
181
|
|
|
183
|
-
it("can add another part", () => {
|
|
184
|
-
|
|
182
|
+
it("can add another part", async () => {
|
|
183
|
+
await Offline(() => {
|
|
185
184
|
const part = new Part();
|
|
186
185
|
expect(part.length).to.equal(0);
|
|
187
186
|
const subPart = new Part({
|
|
@@ -194,8 +193,8 @@ describe("Part", () => {
|
|
|
194
193
|
});
|
|
195
194
|
});
|
|
196
195
|
|
|
197
|
-
it("can add a sequence", () => {
|
|
198
|
-
|
|
196
|
+
it("can add a sequence", async () => {
|
|
197
|
+
await Offline(() => {
|
|
199
198
|
const part = new Part();
|
|
200
199
|
expect(part.length).to.equal(0);
|
|
201
200
|
const subPart = new Sequence({
|
|
@@ -208,8 +207,8 @@ describe("Part", () => {
|
|
|
208
207
|
});
|
|
209
208
|
});
|
|
210
209
|
|
|
211
|
-
it("can remove an event by time", () => {
|
|
212
|
-
|
|
210
|
+
it("can remove an event by time", async () => {
|
|
211
|
+
await Offline(() => {
|
|
213
212
|
const part = new Part({
|
|
214
213
|
events: [
|
|
215
214
|
[0.2, "C3"],
|
|
@@ -223,8 +222,8 @@ describe("Part", () => {
|
|
|
223
222
|
});
|
|
224
223
|
});
|
|
225
224
|
|
|
226
|
-
it("can remove an event by time and value", () => {
|
|
227
|
-
|
|
225
|
+
it("can remove an event by time and value", async () => {
|
|
226
|
+
await Offline(() => {
|
|
228
227
|
const secondEvent = {
|
|
229
228
|
note: "C4",
|
|
230
229
|
time: 0.2,
|
|
@@ -241,8 +240,8 @@ describe("Part", () => {
|
|
|
241
240
|
});
|
|
242
241
|
});
|
|
243
242
|
|
|
244
|
-
it("added events have the same settings as the parent", () => {
|
|
245
|
-
|
|
243
|
+
it("added events have the same settings as the parent", async () => {
|
|
244
|
+
await Offline(() => {
|
|
246
245
|
const part = new Part({
|
|
247
246
|
events: [
|
|
248
247
|
[0.2, "C3"],
|
|
@@ -270,8 +269,8 @@ describe("Part", () => {
|
|
|
270
269
|
});
|
|
271
270
|
});
|
|
272
271
|
|
|
273
|
-
it("will create an event using at if one wasn't there at that time", () => {
|
|
274
|
-
|
|
272
|
+
it("will create an event using at if one wasn't there at that time", async () => {
|
|
273
|
+
await Offline(() => {
|
|
275
274
|
const part = new Part();
|
|
276
275
|
expect(part.length).to.equal(0);
|
|
277
276
|
expect((part.at(0.1, "C4") as ToneEvent).value).to.equal("C4");
|
|
@@ -280,8 +279,8 @@ describe("Part", () => {
|
|
|
280
279
|
});
|
|
281
280
|
});
|
|
282
281
|
|
|
283
|
-
it("can remove all of the events", () => {
|
|
284
|
-
|
|
282
|
+
it("can remove all of the events", async () => {
|
|
283
|
+
await Offline(() => {
|
|
285
284
|
const part = new Part(noOp, [0, 1, 2, 3, 4, 5]);
|
|
286
285
|
expect(part.length).to.equal(6);
|
|
287
286
|
part.clear();
|
|
@@ -292,8 +291,8 @@ describe("Part", () => {
|
|
|
292
291
|
});
|
|
293
292
|
|
|
294
293
|
context("Part callback", () => {
|
|
295
|
-
it("does not invoke get invoked until started", () => {
|
|
296
|
-
|
|
294
|
+
it("does not invoke get invoked until started", async () => {
|
|
295
|
+
await Offline(({ transport }) => {
|
|
297
296
|
const part = new Part(() => {
|
|
298
297
|
throw new Error("shouldn't call this callback");
|
|
299
298
|
}, [0, 0.4]);
|
|
@@ -301,21 +300,20 @@ describe("Part", () => {
|
|
|
301
300
|
}, 0.5);
|
|
302
301
|
});
|
|
303
302
|
|
|
304
|
-
it("is invoked after it's started", () => {
|
|
303
|
+
it("is invoked after it's started", async () => {
|
|
305
304
|
let invokations = 0;
|
|
306
|
-
|
|
305
|
+
await Offline(({ transport }) => {
|
|
307
306
|
const part = new Part(() => {
|
|
308
307
|
invokations++;
|
|
309
308
|
}, [0, 0.1]).start(0);
|
|
310
309
|
transport.start();
|
|
311
|
-
}, 0.2)
|
|
312
|
-
|
|
313
|
-
});
|
|
310
|
+
}, 0.2);
|
|
311
|
+
expect(invokations).to.equal(2);
|
|
314
312
|
});
|
|
315
313
|
|
|
316
|
-
it("passes in the scheduled time to the callback", () => {
|
|
314
|
+
it("passes in the scheduled time to the callback", async () => {
|
|
317
315
|
let invoked = false;
|
|
318
|
-
|
|
316
|
+
await Offline(({ transport }) => {
|
|
319
317
|
const startTime = 0.1;
|
|
320
318
|
const part = new Part(
|
|
321
319
|
(time) => {
|
|
@@ -327,14 +325,13 @@ describe("Part", () => {
|
|
|
327
325
|
);
|
|
328
326
|
part.start(0.2);
|
|
329
327
|
transport.start(startTime);
|
|
330
|
-
}, 0.62)
|
|
331
|
-
|
|
332
|
-
});
|
|
328
|
+
}, 0.62);
|
|
329
|
+
expect(invoked).to.be.true;
|
|
333
330
|
});
|
|
334
331
|
|
|
335
|
-
it("passes in the value to the callback", () => {
|
|
332
|
+
it("passes in the value to the callback", async () => {
|
|
336
333
|
let invoked = false;
|
|
337
|
-
|
|
334
|
+
await Offline(({ transport }) => {
|
|
338
335
|
const part = new Part(
|
|
339
336
|
(time, thing) => {
|
|
340
337
|
expect(time).to.be.a("number");
|
|
@@ -345,13 +342,12 @@ describe("Part", () => {
|
|
|
345
342
|
[[0, "thing"]]
|
|
346
343
|
).start();
|
|
347
344
|
transport.start();
|
|
348
|
-
}, 0.6)
|
|
349
|
-
|
|
350
|
-
});
|
|
345
|
+
}, 0.6);
|
|
346
|
+
expect(invoked).to.be.true;
|
|
351
347
|
});
|
|
352
348
|
|
|
353
|
-
it("can mute the callback", () => {
|
|
354
|
-
|
|
349
|
+
it("can mute the callback", async () => {
|
|
350
|
+
await Offline(({ transport }) => {
|
|
355
351
|
const part = new Part(() => {
|
|
356
352
|
throw new Error("shouldn't call this callback");
|
|
357
353
|
}, [0, 0.1, 0.2, 0.3]).start();
|
|
@@ -361,8 +357,8 @@ describe("Part", () => {
|
|
|
361
357
|
}, 0.5);
|
|
362
358
|
});
|
|
363
359
|
|
|
364
|
-
it("can trigger with some probability", () => {
|
|
365
|
-
|
|
360
|
+
it("can trigger with some probability", async () => {
|
|
361
|
+
await Offline(({ transport }) => {
|
|
366
362
|
const part = new Part(() => {
|
|
367
363
|
throw new Error("shouldn't call this callback");
|
|
368
364
|
}, [0, 0.1, 0.2, 0.3]).start();
|
|
@@ -372,21 +368,20 @@ describe("Part", () => {
|
|
|
372
368
|
}, 0.4);
|
|
373
369
|
});
|
|
374
370
|
|
|
375
|
-
it("invokes all of the scheduled events", () => {
|
|
371
|
+
it("invokes all of the scheduled events", async () => {
|
|
376
372
|
let count = 0;
|
|
377
|
-
|
|
373
|
+
await Offline(({ transport }) => {
|
|
378
374
|
new Part(() => {
|
|
379
375
|
count++;
|
|
380
376
|
}, [0, 0.1, 0.2, 0.3]).start();
|
|
381
377
|
transport.start();
|
|
382
|
-
}, 0.4)
|
|
383
|
-
|
|
384
|
-
});
|
|
378
|
+
}, 0.4);
|
|
379
|
+
expect(count).to.equal(4);
|
|
385
380
|
});
|
|
386
381
|
|
|
387
|
-
it("invokes all of the scheduled events at the correct times", () => {
|
|
382
|
+
it("invokes all of the scheduled events at the correct times", async () => {
|
|
388
383
|
let count = 0;
|
|
389
|
-
|
|
384
|
+
await Offline(({ transport }) => {
|
|
390
385
|
const now = transport.now() + 0.1;
|
|
391
386
|
new Part(
|
|
392
387
|
(time, value) => {
|
|
@@ -400,14 +395,13 @@ describe("Part", () => {
|
|
|
400
395
|
]
|
|
401
396
|
).start();
|
|
402
397
|
transport.start(now);
|
|
403
|
-
}, 0.4)
|
|
404
|
-
|
|
405
|
-
});
|
|
398
|
+
}, 0.4);
|
|
399
|
+
expect(count).to.equal(3);
|
|
406
400
|
});
|
|
407
401
|
|
|
408
|
-
it("starts an event added after the part was started", () => {
|
|
402
|
+
it("starts an event added after the part was started", async () => {
|
|
409
403
|
let invoked = false;
|
|
410
|
-
|
|
404
|
+
await Offline(({ transport }) => {
|
|
411
405
|
const part = new Part({
|
|
412
406
|
events: [[0, 0]],
|
|
413
407
|
loop: true,
|
|
@@ -422,14 +416,13 @@ describe("Part", () => {
|
|
|
422
416
|
return atTime(0.1, () => {
|
|
423
417
|
part.add(0.1, 1);
|
|
424
418
|
});
|
|
425
|
-
}, 0.6)
|
|
426
|
-
|
|
427
|
-
});
|
|
419
|
+
}, 0.6);
|
|
420
|
+
expect(invoked).to.be.true;
|
|
428
421
|
});
|
|
429
422
|
|
|
430
|
-
it("can schedule a subpart", () => {
|
|
423
|
+
it("can schedule a subpart", async () => {
|
|
431
424
|
let invokations = 0;
|
|
432
|
-
|
|
425
|
+
await Offline(({ transport }) => {
|
|
433
426
|
const startTime = 0.1;
|
|
434
427
|
const subPart = new Part({
|
|
435
428
|
events: [
|
|
@@ -452,14 +445,13 @@ describe("Part", () => {
|
|
|
452
445
|
.add(0, 0)
|
|
453
446
|
.start(0);
|
|
454
447
|
transport.start(startTime);
|
|
455
|
-
}, 0.7)
|
|
456
|
-
|
|
457
|
-
});
|
|
448
|
+
}, 0.7);
|
|
449
|
+
expect(invokations).to.equal(3);
|
|
458
450
|
});
|
|
459
451
|
|
|
460
|
-
it("can start with an offset", () => {
|
|
452
|
+
it("can start with an offset", async () => {
|
|
461
453
|
let invoked = false;
|
|
462
|
-
|
|
454
|
+
await Offline(({ transport }) => {
|
|
463
455
|
const startTime = 0.1;
|
|
464
456
|
const part = new Part(
|
|
465
457
|
(time, number) => {
|
|
@@ -473,16 +465,15 @@ describe("Part", () => {
|
|
|
473
465
|
]
|
|
474
466
|
).start(0, 0.9);
|
|
475
467
|
transport.start(startTime);
|
|
476
|
-
}, 0.3)
|
|
477
|
-
|
|
478
|
-
});
|
|
468
|
+
}, 0.3);
|
|
469
|
+
expect(invoked).to.be.true;
|
|
479
470
|
});
|
|
480
471
|
});
|
|
481
472
|
|
|
482
473
|
context("Looping", () => {
|
|
483
|
-
it("can be set using a boolean as an argument when created", () => {
|
|
474
|
+
it("can be set using a boolean as an argument when created", async () => {
|
|
484
475
|
let callCount = 0;
|
|
485
|
-
|
|
476
|
+
await Offline(({ transport }) => {
|
|
486
477
|
new Part({
|
|
487
478
|
events: [
|
|
488
479
|
[0, 1],
|
|
@@ -495,14 +486,13 @@ describe("Part", () => {
|
|
|
495
486
|
},
|
|
496
487
|
}).start(0);
|
|
497
488
|
transport.start();
|
|
498
|
-
}, 0.55)
|
|
499
|
-
|
|
500
|
-
});
|
|
489
|
+
}, 0.55);
|
|
490
|
+
expect(callCount).to.equal(6);
|
|
501
491
|
});
|
|
502
492
|
|
|
503
|
-
it("can be toggled off using a boolean", () => {
|
|
493
|
+
it("can be toggled off using a boolean", async () => {
|
|
504
494
|
let callCount = 0;
|
|
505
|
-
|
|
495
|
+
await Offline(({ transport }) => {
|
|
506
496
|
const part = new Part({
|
|
507
497
|
events: [
|
|
508
498
|
[0, 1],
|
|
@@ -516,14 +506,13 @@ describe("Part", () => {
|
|
|
516
506
|
}).start(0);
|
|
517
507
|
part.loop = false;
|
|
518
508
|
transport.start();
|
|
519
|
-
}, 0.55)
|
|
520
|
-
|
|
521
|
-
});
|
|
509
|
+
}, 0.55);
|
|
510
|
+
expect(callCount).to.equal(2);
|
|
522
511
|
});
|
|
523
512
|
|
|
524
|
-
it("can be toggled on using a boolean", () => {
|
|
513
|
+
it("can be toggled on using a boolean", async () => {
|
|
525
514
|
let callCount = 0;
|
|
526
|
-
|
|
515
|
+
await Offline(({ transport }) => {
|
|
527
516
|
const part = new Part({
|
|
528
517
|
events: [
|
|
529
518
|
[0, 1],
|
|
@@ -537,14 +526,13 @@ describe("Part", () => {
|
|
|
537
526
|
}).start(0);
|
|
538
527
|
part.loop = true;
|
|
539
528
|
transport.start();
|
|
540
|
-
}, 0.55)
|
|
541
|
-
|
|
542
|
-
});
|
|
529
|
+
}, 0.55);
|
|
530
|
+
expect(callCount).to.equal(6);
|
|
543
531
|
});
|
|
544
532
|
|
|
545
|
-
it("can be set to loop at a specific interval", () => {
|
|
533
|
+
it("can be set to loop at a specific interval", async () => {
|
|
546
534
|
let invoked = false;
|
|
547
|
-
|
|
535
|
+
await Offline(({ transport }) => {
|
|
548
536
|
let lastCall;
|
|
549
537
|
const part = new Part({
|
|
550
538
|
events: [0],
|
|
@@ -559,14 +547,13 @@ describe("Part", () => {
|
|
|
559
547
|
},
|
|
560
548
|
}).start(0);
|
|
561
549
|
transport.start();
|
|
562
|
-
}, 0.7)
|
|
563
|
-
|
|
564
|
-
});
|
|
550
|
+
}, 0.7);
|
|
551
|
+
expect(invoked).to.be.true;
|
|
565
552
|
});
|
|
566
553
|
|
|
567
|
-
it("a started part will be stopped if it is after the loopEnd", () => {
|
|
554
|
+
it("a started part will be stopped if it is after the loopEnd", async () => {
|
|
568
555
|
let invoked = true;
|
|
569
|
-
|
|
556
|
+
await Offline(({ transport }) => {
|
|
570
557
|
let switched = false;
|
|
571
558
|
const part = new Part({
|
|
572
559
|
events: [
|
|
@@ -586,14 +573,13 @@ describe("Part", () => {
|
|
|
586
573
|
},
|
|
587
574
|
}).start(0);
|
|
588
575
|
transport.start();
|
|
589
|
-
}, 0.7)
|
|
590
|
-
|
|
591
|
-
});
|
|
576
|
+
}, 0.7);
|
|
577
|
+
expect(invoked).to.be.true;
|
|
592
578
|
});
|
|
593
579
|
|
|
594
|
-
it("a started part will be stopped if it is before the loopStart", () => {
|
|
580
|
+
it("a started part will be stopped if it is before the loopStart", async () => {
|
|
595
581
|
let invoked = false;
|
|
596
|
-
|
|
582
|
+
await Offline(({ transport }) => {
|
|
597
583
|
let switched = false;
|
|
598
584
|
const part = new Part({
|
|
599
585
|
events: [
|
|
@@ -613,14 +599,13 @@ describe("Part", () => {
|
|
|
613
599
|
},
|
|
614
600
|
}).start(0);
|
|
615
601
|
transport.start();
|
|
616
|
-
}, 0.7)
|
|
617
|
-
|
|
618
|
-
});
|
|
602
|
+
}, 0.7);
|
|
603
|
+
expect(invoked).to.be.true;
|
|
619
604
|
});
|
|
620
605
|
|
|
621
|
-
it("can loop a specific number of times", () => {
|
|
606
|
+
it("can loop a specific number of times", async () => {
|
|
622
607
|
let callCount = 0;
|
|
623
|
-
|
|
608
|
+
await Offline(({ transport }) => {
|
|
624
609
|
new Part({
|
|
625
610
|
events: [0, 0.1],
|
|
626
611
|
loop: 3,
|
|
@@ -630,15 +615,14 @@ describe("Part", () => {
|
|
|
630
615
|
},
|
|
631
616
|
}).start(0.1);
|
|
632
617
|
transport.start();
|
|
633
|
-
}, 0.8)
|
|
634
|
-
|
|
635
|
-
});
|
|
618
|
+
}, 0.8);
|
|
619
|
+
expect(callCount).to.equal(6);
|
|
636
620
|
});
|
|
637
621
|
|
|
638
|
-
it("can loop a specific number of times (different set order)", () => {
|
|
622
|
+
it("can loop a specific number of times (different set order)", async () => {
|
|
639
623
|
let callCount = 0;
|
|
640
624
|
const times = [0.1, 0.2, 0.4, 0.5];
|
|
641
|
-
|
|
625
|
+
await Offline(({ transport }) => {
|
|
642
626
|
const part = new Part({
|
|
643
627
|
events: [0, 0.1],
|
|
644
628
|
callback(time): void {
|
|
@@ -649,14 +633,13 @@ describe("Part", () => {
|
|
|
649
633
|
part.loop = 2;
|
|
650
634
|
part.loopEnd = 0.3;
|
|
651
635
|
transport.start();
|
|
652
|
-
}, 0.8)
|
|
653
|
-
|
|
654
|
-
});
|
|
636
|
+
}, 0.8);
|
|
637
|
+
expect(callCount).to.equal(4);
|
|
655
638
|
});
|
|
656
639
|
|
|
657
|
-
it("plays once when loop is 1", () => {
|
|
640
|
+
it("plays once when loop is 1", async () => {
|
|
658
641
|
let callCount = 0;
|
|
659
|
-
|
|
642
|
+
await Offline(({ transport }) => {
|
|
660
643
|
new Part({
|
|
661
644
|
events: [0, 0.1],
|
|
662
645
|
loop: 1,
|
|
@@ -666,14 +649,13 @@ describe("Part", () => {
|
|
|
666
649
|
},
|
|
667
650
|
}).start(0.1);
|
|
668
651
|
transport.start();
|
|
669
|
-
}, 0.8)
|
|
670
|
-
|
|
671
|
-
});
|
|
652
|
+
}, 0.8);
|
|
653
|
+
expect(callCount).to.equal(2);
|
|
672
654
|
});
|
|
673
655
|
|
|
674
|
-
it("plays once when loop is 0", () => {
|
|
656
|
+
it("plays once when loop is 0", async () => {
|
|
675
657
|
let callCount = 0;
|
|
676
|
-
|
|
658
|
+
await Offline(({ transport }) => {
|
|
677
659
|
new Part({
|
|
678
660
|
events: [0, 0.1],
|
|
679
661
|
loop: 0,
|
|
@@ -683,14 +665,13 @@ describe("Part", () => {
|
|
|
683
665
|
},
|
|
684
666
|
}).start(0.1);
|
|
685
667
|
transport.start();
|
|
686
|
-
}, 0.8)
|
|
687
|
-
|
|
688
|
-
});
|
|
668
|
+
}, 0.8);
|
|
669
|
+
expect(callCount).to.equal(2);
|
|
689
670
|
});
|
|
690
671
|
|
|
691
|
-
it("plays once when loop is false", () => {
|
|
672
|
+
it("plays once when loop is false", async () => {
|
|
692
673
|
let callCount = 0;
|
|
693
|
-
|
|
674
|
+
await Offline(({ transport }) => {
|
|
694
675
|
new Part({
|
|
695
676
|
events: [0, 0.1],
|
|
696
677
|
loop: false,
|
|
@@ -700,14 +681,13 @@ describe("Part", () => {
|
|
|
700
681
|
},
|
|
701
682
|
}).start(0.1);
|
|
702
683
|
transport.start();
|
|
703
|
-
}, 0.8)
|
|
704
|
-
|
|
705
|
-
});
|
|
684
|
+
}, 0.8);
|
|
685
|
+
expect(callCount).to.equal(2);
|
|
706
686
|
});
|
|
707
687
|
|
|
708
|
-
it("can loop between loopStart and loopEnd", () => {
|
|
688
|
+
it("can loop between loopStart and loopEnd", async () => {
|
|
709
689
|
let invoked = false;
|
|
710
|
-
|
|
690
|
+
await Offline(({ transport }) => {
|
|
711
691
|
new Part({
|
|
712
692
|
events: [
|
|
713
693
|
[0, 0],
|
|
@@ -725,14 +705,13 @@ describe("Part", () => {
|
|
|
725
705
|
},
|
|
726
706
|
}).start(0);
|
|
727
707
|
transport.start();
|
|
728
|
-
}, 0.8)
|
|
729
|
-
|
|
730
|
-
});
|
|
708
|
+
}, 0.8);
|
|
709
|
+
expect(invoked).to.be.true;
|
|
731
710
|
});
|
|
732
711
|
|
|
733
|
-
it("can be started and stopped multiple times", () => {
|
|
712
|
+
it("can be started and stopped multiple times", async () => {
|
|
734
713
|
let eventTimeIndex = 0;
|
|
735
|
-
|
|
714
|
+
await Offline(({ transport }) => {
|
|
736
715
|
const eventTimes = [
|
|
737
716
|
[0.5, 0],
|
|
738
717
|
[0.6, 1],
|
|
@@ -765,14 +744,13 @@ describe("Part", () => {
|
|
|
765
744
|
.start(0.3)
|
|
766
745
|
.stop(0.81);
|
|
767
746
|
transport.start(0.2).stop(0.61).start(0.8);
|
|
768
|
-
}, 2)
|
|
769
|
-
|
|
770
|
-
});
|
|
747
|
+
}, 2);
|
|
748
|
+
expect(eventTimeIndex).to.equal(8);
|
|
771
749
|
});
|
|
772
750
|
|
|
773
|
-
it("can adjust the loopEnd times", () => {
|
|
751
|
+
it("can adjust the loopEnd times", async () => {
|
|
774
752
|
let eventTimeIndex = 0;
|
|
775
|
-
|
|
753
|
+
await Offline(({ transport }) => {
|
|
776
754
|
const eventTimes = [
|
|
777
755
|
[0.5, 0],
|
|
778
756
|
[0.6, 1],
|
|
@@ -807,14 +785,13 @@ describe("Part", () => {
|
|
|
807
785
|
part.loopEnd = 0.4;
|
|
808
786
|
part.loopEnd = 0.3;
|
|
809
787
|
transport.start(0.2).stop(0.61).start(0.8);
|
|
810
|
-
}, 2)
|
|
811
|
-
|
|
812
|
-
});
|
|
788
|
+
}, 2);
|
|
789
|
+
expect(eventTimeIndex).to.equal(8);
|
|
813
790
|
});
|
|
814
791
|
|
|
815
|
-
it("reports the progress of the loop", () => {
|
|
792
|
+
it("reports the progress of the loop", async () => {
|
|
816
793
|
let callCount = 0;
|
|
817
|
-
|
|
794
|
+
await Offline(({ transport }) => {
|
|
818
795
|
const part = new Part({
|
|
819
796
|
events: [0],
|
|
820
797
|
loop: true,
|
|
@@ -828,14 +805,13 @@ describe("Part", () => {
|
|
|
828
805
|
return (time) => {
|
|
829
806
|
expect(part.progress).to.be.closeTo(time, 0.01);
|
|
830
807
|
};
|
|
831
|
-
}, 0.8)
|
|
832
|
-
|
|
833
|
-
});
|
|
808
|
+
}, 0.8);
|
|
809
|
+
expect(callCount).to.equal(1);
|
|
834
810
|
});
|
|
835
811
|
|
|
836
|
-
it("can start a loop with an offset", () => {
|
|
812
|
+
it("can start a loop with an offset", async () => {
|
|
837
813
|
let iteration = 0;
|
|
838
|
-
|
|
814
|
+
await Offline(({ transport }) => {
|
|
839
815
|
const now = transport.now();
|
|
840
816
|
const part = new Part(
|
|
841
817
|
(time, number) => {
|
|
@@ -856,14 +832,13 @@ describe("Part", () => {
|
|
|
856
832
|
part.loopEnd = 0.5;
|
|
857
833
|
part.start(0, 1.05);
|
|
858
834
|
transport.start(0);
|
|
859
|
-
}, 0.6)
|
|
860
|
-
|
|
861
|
-
});
|
|
835
|
+
}, 0.6);
|
|
836
|
+
expect(iteration).to.equal(2);
|
|
862
837
|
});
|
|
863
838
|
|
|
864
|
-
it("can start a loop with an offset before loop start", () => {
|
|
839
|
+
it("can start a loop with an offset before loop start", async () => {
|
|
865
840
|
let iteration = 0;
|
|
866
|
-
|
|
841
|
+
await Offline(({ transport }) => {
|
|
867
842
|
const part = new Part(
|
|
868
843
|
(time, number) => {
|
|
869
844
|
if (iteration === 0) {
|
|
@@ -890,16 +865,15 @@ describe("Part", () => {
|
|
|
890
865
|
part.loopEnd = 0.5;
|
|
891
866
|
part.start(0, 0);
|
|
892
867
|
transport.start(part.now());
|
|
893
|
-
}, 0.7)
|
|
894
|
-
|
|
895
|
-
});
|
|
868
|
+
}, 0.7);
|
|
869
|
+
expect(iteration).to.equal(5);
|
|
896
870
|
});
|
|
897
871
|
});
|
|
898
872
|
|
|
899
873
|
context("playbackRate", () => {
|
|
900
|
-
it("can adjust the playbackRate", () => {
|
|
874
|
+
it("can adjust the playbackRate", async () => {
|
|
901
875
|
let invoked = false;
|
|
902
|
-
|
|
876
|
+
await Offline(({ transport }) => {
|
|
903
877
|
let lastCall;
|
|
904
878
|
new Part({
|
|
905
879
|
events: [0, 0.5],
|
|
@@ -915,14 +889,13 @@ describe("Part", () => {
|
|
|
915
889
|
},
|
|
916
890
|
}).start(0);
|
|
917
891
|
transport.start(0);
|
|
918
|
-
}, 0.7)
|
|
919
|
-
|
|
920
|
-
});
|
|
892
|
+
}, 0.7);
|
|
893
|
+
expect(invoked).to.be.true;
|
|
921
894
|
});
|
|
922
895
|
|
|
923
|
-
it("can adjust the playbackRate after starting", () => {
|
|
896
|
+
it("can adjust the playbackRate after starting", async () => {
|
|
924
897
|
let invoked = false;
|
|
925
|
-
|
|
898
|
+
await Offline(({ transport }) => {
|
|
926
899
|
let lastCall;
|
|
927
900
|
const part = new Part({
|
|
928
901
|
events: [0, 0.25],
|
|
@@ -940,9 +913,8 @@ describe("Part", () => {
|
|
|
940
913
|
},
|
|
941
914
|
}).start(0);
|
|
942
915
|
transport.start(0);
|
|
943
|
-
}, 0.8)
|
|
944
|
-
|
|
945
|
-
});
|
|
916
|
+
}, 0.8);
|
|
917
|
+
expect(invoked).to.be.true;
|
|
946
918
|
});
|
|
947
919
|
});
|
|
948
920
|
|