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
|
@@ -4,8 +4,8 @@ import { TransportClass } from "./Transport.js";
|
|
|
4
4
|
import { TransportRepeatEvent } from "./TransportRepeatEvent.js";
|
|
5
5
|
|
|
6
6
|
describe("TransportRepeatEvent", () => {
|
|
7
|
-
it("can be created and disposed", () => {
|
|
8
|
-
|
|
7
|
+
it("can be created and disposed", async () => {
|
|
8
|
+
await Offline((context) => {
|
|
9
9
|
const transport = new TransportClass({ context });
|
|
10
10
|
const event = new TransportRepeatEvent(transport, {
|
|
11
11
|
duration: 100,
|
|
@@ -16,8 +16,8 @@ describe("TransportRepeatEvent", () => {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("generates a unique event ID", () => {
|
|
20
|
-
|
|
19
|
+
it("generates a unique event ID", async () => {
|
|
20
|
+
await Offline((context) => {
|
|
21
21
|
const transport = new TransportClass({ context });
|
|
22
22
|
const event = new TransportRepeatEvent(transport, {
|
|
23
23
|
time: 0,
|
|
@@ -27,8 +27,8 @@ describe("TransportRepeatEvent", () => {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it("is removed from the Transport when disposed", () => {
|
|
31
|
-
|
|
30
|
+
it("is removed from the Transport when disposed", async () => {
|
|
31
|
+
await Offline((context) => {
|
|
32
32
|
const transport = new TransportClass({ context });
|
|
33
33
|
const event = new TransportRepeatEvent(transport, {
|
|
34
34
|
time: 0,
|
|
@@ -279,20 +279,19 @@ describe("Context", () => {
|
|
|
279
279
|
}, 0.01);
|
|
280
280
|
});
|
|
281
281
|
|
|
282
|
-
it("is invoked in the offline context", () => {
|
|
282
|
+
it("is invoked in the offline context", async () => {
|
|
283
283
|
let invocationCount = 0;
|
|
284
|
-
|
|
284
|
+
await Offline((context) => {
|
|
285
285
|
context.setInterval(() => {
|
|
286
286
|
invocationCount++;
|
|
287
287
|
}, 0.01);
|
|
288
|
-
}, 0.051)
|
|
289
|
-
|
|
290
|
-
});
|
|
288
|
+
}, 0.051);
|
|
289
|
+
expect(invocationCount).to.equal(4);
|
|
291
290
|
});
|
|
292
291
|
|
|
293
|
-
it("is invoked
|
|
292
|
+
it("is invoked with the right interval", async () => {
|
|
294
293
|
let numberOfInvocations = 0;
|
|
295
|
-
|
|
294
|
+
await Offline((context) => {
|
|
296
295
|
let intervalTime = context.now();
|
|
297
296
|
context.setInterval(() => {
|
|
298
297
|
expect(context.now() - intervalTime).to.be.closeTo(
|
|
@@ -302,9 +301,8 @@ describe("Context", () => {
|
|
|
302
301
|
intervalTime = context.now();
|
|
303
302
|
numberOfInvocations++;
|
|
304
303
|
}, 0.01);
|
|
305
|
-
}, 0.051)
|
|
306
|
-
|
|
307
|
-
});
|
|
304
|
+
}, 0.051);
|
|
305
|
+
expect(numberOfInvocations).to.equal(4);
|
|
308
306
|
});
|
|
309
307
|
});
|
|
310
308
|
|
|
@@ -373,7 +373,9 @@ export class Context extends BaseContext {
|
|
|
373
373
|
const workletPromise = this.rawContext.audioWorklet.addModule(url);
|
|
374
374
|
|
|
375
375
|
this._workletPromises.add(workletPromise);
|
|
376
|
-
workletPromise.finally(() =>
|
|
376
|
+
workletPromise.finally(() =>
|
|
377
|
+
this._workletPromises.delete(workletPromise)
|
|
378
|
+
);
|
|
377
379
|
|
|
378
380
|
return workletPromise;
|
|
379
381
|
}
|
|
@@ -561,9 +563,11 @@ export class Context extends BaseContext {
|
|
|
561
563
|
private _timeoutLoop(): void {
|
|
562
564
|
const now = this.now();
|
|
563
565
|
this._timeouts.forEachBefore(now, (event) => {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
566
|
+
try {
|
|
567
|
+
event.callback();
|
|
568
|
+
} finally {
|
|
569
|
+
this._timeouts.remove(event);
|
|
570
|
+
}
|
|
567
571
|
});
|
|
568
572
|
}
|
|
569
573
|
|
|
@@ -26,13 +26,12 @@ describe("Destination", () => {
|
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
it("passes no audio when muted", () => {
|
|
30
|
-
|
|
29
|
+
it("passes no audio when muted", async () => {
|
|
30
|
+
const buffer = await Offline((context) => {
|
|
31
31
|
new Oscillator().toDestination().start(0);
|
|
32
32
|
context.destination.mute = true;
|
|
33
|
-
}).then((buffer) => {
|
|
34
|
-
expect(buffer.isSilent()).to.equal(true);
|
|
35
33
|
});
|
|
34
|
+
expect(buffer.isSilent()).to.equal(true);
|
|
36
35
|
});
|
|
37
36
|
|
|
38
37
|
it("has a master volume control", () => {
|
|
@@ -16,63 +16,45 @@ describe("Offline", () => {
|
|
|
16
16
|
return ret;
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("generates a buffer", () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
19
|
+
it("generates a buffer", async () => {
|
|
20
|
+
const buffer = await Offline(noOp, 0.01);
|
|
21
|
+
expect(buffer).to.be.instanceOf(ToneAudioBuffer);
|
|
23
22
|
});
|
|
24
23
|
|
|
25
|
-
it("silent by default", () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
24
|
+
it("silent by default", async () => {
|
|
25
|
+
const buffer = await Offline(noOp, 0.01, 1);
|
|
26
|
+
const isSilent = buffer.toArray().every((sample) => sample === 0);
|
|
27
|
+
expect(isSilent).to.equal(true);
|
|
30
28
|
});
|
|
31
29
|
|
|
32
|
-
it("records the master output", () => {
|
|
33
|
-
|
|
30
|
+
it("records the master output", async () => {
|
|
31
|
+
const buffer = await Offline(() => {
|
|
34
32
|
new ToneOscillatorNode().toDestination().start();
|
|
35
|
-
}, 0.01)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
33
|
+
}, 0.01);
|
|
34
|
+
const testBuff = new TestAudioBuffer(buffer.get() as AudioBuffer);
|
|
35
|
+
expect(testBuff.isSilent()).is.equal(false);
|
|
39
36
|
});
|
|
40
37
|
|
|
41
|
-
it("returning a promise defers the rendering till the promise resolves", () => {
|
|
38
|
+
it("returning a promise defers the rendering till the promise resolves", async () => {
|
|
42
39
|
let wasInvoked = false;
|
|
43
|
-
|
|
40
|
+
const buffer = await Offline(() => {
|
|
44
41
|
new ToneOscillatorNode().toDestination().start();
|
|
45
42
|
return new Promise((done) => {
|
|
46
43
|
setTimeout(done, 100);
|
|
47
44
|
}).then(() => {
|
|
48
45
|
wasInvoked = true;
|
|
49
46
|
});
|
|
50
|
-
}, 0.01)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
47
|
+
}, 0.01);
|
|
48
|
+
const testBuff = new TestAudioBuffer(buffer.get() as AudioBuffer);
|
|
49
|
+
expect(wasInvoked).is.equal(true);
|
|
50
|
+
expect(testBuff.isSilent()).to.equal(false);
|
|
55
51
|
});
|
|
56
52
|
|
|
57
|
-
it("can schedule specific timing outputs", () => {
|
|
58
|
-
|
|
53
|
+
it("can schedule specific timing outputs", async () => {
|
|
54
|
+
const buffer = await Offline(() => {
|
|
59
55
|
new ToneOscillatorNode().toDestination().start(0.05);
|
|
60
|
-
}, 0.1)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
56
|
+
}, 0.1);
|
|
57
|
+
const testBuff = new TestAudioBuffer(buffer.get() as AudioBuffer);
|
|
58
|
+
expect(testBuff.getTimeOfFirstSound()).to.be.closeTo(0.05, 0.0001);
|
|
64
59
|
});
|
|
65
|
-
|
|
66
|
-
// it("can schedule Transport events", () => {
|
|
67
|
-
// return Offline(function (Transport) {
|
|
68
|
-
// var osc = new Oscillator().toDestination();
|
|
69
|
-
// Transport.schedule(function (time) {
|
|
70
|
-
// osc.start(time);
|
|
71
|
-
// }, 0.05);
|
|
72
|
-
// Transport.start(0);
|
|
73
|
-
// }, 0.1).then((buffer) => {
|
|
74
|
-
// BufferTest(buffer);
|
|
75
|
-
// expect(buffer.getFirstSoundTime()).to.be.closeTo(0.05, 0.001);
|
|
76
|
-
// });
|
|
77
|
-
// });
|
|
78
60
|
});
|
|
@@ -25,39 +25,37 @@ context("OfflineContext", () => {
|
|
|
25
25
|
return ctx.close();
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
it("can render audio", () => {
|
|
28
|
+
it("can render audio", async () => {
|
|
29
29
|
const ctx = new OfflineContext(1, 0.2, 44100);
|
|
30
30
|
const osc = ctx.createOscillator();
|
|
31
31
|
osc.connect(ctx.rawContext.destination);
|
|
32
32
|
osc.start(0.1);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
33
|
+
const buffer = await ctx.render();
|
|
34
|
+
expect(buffer).to.have.property("length");
|
|
35
|
+
expect(buffer).to.have.property("sampleRate");
|
|
36
|
+
const array = buffer.getChannelData(0);
|
|
37
|
+
for (let i = 0; i < array.length; i++) {
|
|
38
|
+
if (array[i] !== 0) {
|
|
39
|
+
expect(i / array.length).to.be.closeTo(0.5, 0.01);
|
|
40
|
+
break;
|
|
42
41
|
}
|
|
43
|
-
}
|
|
42
|
+
}
|
|
44
43
|
});
|
|
45
44
|
|
|
46
|
-
it("can render audio not async", () => {
|
|
45
|
+
it("can render audio not async", async () => {
|
|
47
46
|
const ctx = new OfflineContext(1, 0.2, 44100);
|
|
48
47
|
const osc = ctx.createOscillator();
|
|
49
48
|
osc.connect(ctx.rawContext.destination);
|
|
50
49
|
osc.start(0.1);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
50
|
+
const buffer = await ctx.render(false);
|
|
51
|
+
expect(buffer).to.have.property("length");
|
|
52
|
+
expect(buffer).to.have.property("sampleRate");
|
|
53
|
+
const array = buffer.getChannelData(0);
|
|
54
|
+
for (let i = 0; i < array.length; i++) {
|
|
55
|
+
if (array[i] !== 0) {
|
|
56
|
+
expect(i / array.length).to.be.closeTo(0.5, 0.01);
|
|
57
|
+
break;
|
|
60
58
|
}
|
|
61
|
-
}
|
|
59
|
+
}
|
|
62
60
|
});
|
|
63
61
|
});
|
|
@@ -308,9 +308,9 @@ describe("Param", () => {
|
|
|
308
308
|
});
|
|
309
309
|
|
|
310
310
|
context("apply", () => {
|
|
311
|
-
it("can apply a scheduled curve", () => {
|
|
311
|
+
it("can apply a scheduled curve", async () => {
|
|
312
312
|
let sig;
|
|
313
|
-
|
|
313
|
+
const buffer = await Offline((context) => {
|
|
314
314
|
const signal = new Signal();
|
|
315
315
|
sig = signal;
|
|
316
316
|
signal.setValueAtTime(0, 0);
|
|
@@ -325,20 +325,18 @@ describe("Param", () => {
|
|
|
325
325
|
return atTime(0.4, () => {
|
|
326
326
|
signal.apply(source.offset);
|
|
327
327
|
});
|
|
328
|
-
}, 2)
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
document.body.appendChild(await Plot.signal(buffer));
|
|
336
|
-
});
|
|
328
|
+
}, 2);
|
|
329
|
+
for (let time = 0.41; time < 2; time += 0.1) {
|
|
330
|
+
expect(buffer.getValueAtTime(time)).to.be.closeTo(
|
|
331
|
+
sig.getValueAtTime(time),
|
|
332
|
+
0.01
|
|
333
|
+
);
|
|
334
|
+
}
|
|
337
335
|
});
|
|
338
336
|
|
|
339
|
-
it("can apply a scheduled curve that starts with a setTargetAtTime", () => {
|
|
337
|
+
it("can apply a scheduled curve that starts with a setTargetAtTime", async () => {
|
|
340
338
|
let sig;
|
|
341
|
-
|
|
339
|
+
const buffer = await Offline((context) => {
|
|
342
340
|
const signal = new Signal();
|
|
343
341
|
sig = signal;
|
|
344
342
|
signal.setTargetAtTime(2, 0, 0.2);
|
|
@@ -348,20 +346,18 @@ describe("Param", () => {
|
|
|
348
346
|
return atTime(0.4, () => {
|
|
349
347
|
signal.apply(source.offset);
|
|
350
348
|
});
|
|
351
|
-
}, 2)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
// document.body.appendChild(await Plot.signal(buffer));
|
|
359
|
-
});
|
|
349
|
+
}, 2);
|
|
350
|
+
for (let time = 0.41; time < 2; time += 0.1) {
|
|
351
|
+
expect(buffer.getValueAtTime(time)).to.be.closeTo(
|
|
352
|
+
sig.getValueAtTime(time),
|
|
353
|
+
0.05
|
|
354
|
+
);
|
|
355
|
+
}
|
|
360
356
|
});
|
|
361
357
|
|
|
362
|
-
it("can apply a scheduled curve that starts with a setTargetAtTime and then schedules other things", () => {
|
|
358
|
+
it("can apply a scheduled curve that starts with a setTargetAtTime and then schedules other things", async () => {
|
|
363
359
|
let sig;
|
|
364
|
-
|
|
360
|
+
const buffer = await Offline((context) => {
|
|
365
361
|
const signal = new Signal();
|
|
366
362
|
sig = signal;
|
|
367
363
|
signal.setTargetAtTime(2, 0, 0.2);
|
|
@@ -373,19 +369,17 @@ describe("Param", () => {
|
|
|
373
369
|
return atTime(0.4, () => {
|
|
374
370
|
signal.apply(source.offset);
|
|
375
371
|
});
|
|
376
|
-
}, 2)
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
// document.body.appendChild(await Plot.signal(buffer));
|
|
384
|
-
});
|
|
372
|
+
}, 2);
|
|
373
|
+
for (let time = 0.41; time < 2; time += 0.1) {
|
|
374
|
+
expect(buffer.getValueAtTime(time)).to.be.closeTo(
|
|
375
|
+
sig.getValueAtTime(time),
|
|
376
|
+
0.05
|
|
377
|
+
);
|
|
378
|
+
}
|
|
385
379
|
});
|
|
386
380
|
|
|
387
|
-
it("can set the param if the Param is marked as swappable", () => {
|
|
388
|
-
|
|
381
|
+
it("can set the param if the Param is marked as swappable", async () => {
|
|
382
|
+
const buffer = await Offline((context) => {
|
|
389
383
|
const constSource = context.createConstantSource();
|
|
390
384
|
const param = new Param({
|
|
391
385
|
swappable: true,
|
|
@@ -398,11 +392,10 @@ describe("Param", () => {
|
|
|
398
392
|
constSource2.start(0);
|
|
399
393
|
param.setParam(constSource2.offset);
|
|
400
394
|
connect(constSource2, context.destination);
|
|
401
|
-
}, 0.5)
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
});
|
|
395
|
+
}, 0.5);
|
|
396
|
+
expect(buffer.getValueAtTime(0.1)).to.be.closeTo(0.1, 0.001);
|
|
397
|
+
expect(buffer.getValueAtTime(0.2)).to.be.closeTo(0.2, 0.001);
|
|
398
|
+
expect(buffer.getValueAtTime(0.3)).to.be.closeTo(0.3, 0.001);
|
|
406
399
|
});
|
|
407
400
|
|
|
408
401
|
it("throws an error if the param is not set to swappable", () => {
|
|
@@ -192,16 +192,9 @@ describe("ToneAudioBuffer", () => {
|
|
|
192
192
|
expect(hadError).to.equal(true);
|
|
193
193
|
});
|
|
194
194
|
|
|
195
|
-
it("instance .load method returns Promise", (
|
|
196
|
-
const
|
|
197
|
-
expect(
|
|
198
|
-
promise.then((buff) => {
|
|
199
|
-
expect(buff).to.be.instanceOf(ToneAudioBuffer);
|
|
200
|
-
done();
|
|
201
|
-
});
|
|
202
|
-
promise.catch(() => {
|
|
203
|
-
throw new Error("shouldn't invoke this function");
|
|
204
|
-
});
|
|
195
|
+
it("instance .load method returns Promise", async () => {
|
|
196
|
+
const buffer = await new ToneAudioBuffer().load(testFile);
|
|
197
|
+
expect(buffer).to.be.instanceOf(ToneAudioBuffer);
|
|
205
198
|
});
|
|
206
199
|
|
|
207
200
|
it("invokes the error callback if the file is corrupt", (done) => {
|
|
@@ -110,18 +110,16 @@ describe("ToneAudioBuffers", () => {
|
|
|
110
110
|
expect(buffer.loaded).to.be.false;
|
|
111
111
|
});
|
|
112
112
|
|
|
113
|
-
it("can load from a base url", (
|
|
113
|
+
it("can load from a base url", async () => {
|
|
114
114
|
const buffer = new ToneAudioBuffers(
|
|
115
115
|
{
|
|
116
116
|
hat: "hh.wav",
|
|
117
117
|
},
|
|
118
|
-
() => {
|
|
119
|
-
expect(buffer.get("hat")).to.be.instanceof(ToneAudioBuffer);
|
|
120
|
-
buffer.dispose();
|
|
121
|
-
done();
|
|
122
|
-
},
|
|
118
|
+
() => {},
|
|
123
119
|
"./test/audio/"
|
|
124
120
|
);
|
|
121
|
+
await ToneAudioBuffer.loaded();
|
|
122
|
+
expect(buffer.get("hat")).to.be.instanceof(ToneAudioBuffer);
|
|
125
123
|
});
|
|
126
124
|
|
|
127
125
|
it("can add a buffer", (done) => {
|
|
@@ -157,13 +155,11 @@ describe("ToneAudioBuffers", () => {
|
|
|
157
155
|
expect(buffer.get("name").get()).to.equal(buff.get());
|
|
158
156
|
});
|
|
159
157
|
|
|
160
|
-
it("can add an AudioBuffer", (
|
|
161
|
-
ToneAudioBuffer.load(testFile)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
done();
|
|
166
|
-
});
|
|
158
|
+
it("can add an AudioBuffer", async () => {
|
|
159
|
+
const audioBuffer = await ToneAudioBuffer.load(testFile);
|
|
160
|
+
const buffer = new ToneAudioBuffers();
|
|
161
|
+
buffer.add("name", audioBuffer);
|
|
162
|
+
expect(buffer.get("name").get()).to.equal(audioBuffer);
|
|
167
163
|
});
|
|
168
164
|
|
|
169
165
|
it("can be constructed with ToneAudioBuffers", () => {
|
|
@@ -59,7 +59,9 @@ export abstract class ToneAudioWorklet<
|
|
|
59
59
|
this._dummyParam = this._dummyGain.gain;
|
|
60
60
|
|
|
61
61
|
// Register the processor
|
|
62
|
-
let workletPromise = ToneAudioWorklet._workletPromises.get(
|
|
62
|
+
let workletPromise = ToneAudioWorklet._workletPromises.get(
|
|
63
|
+
this.context
|
|
64
|
+
);
|
|
63
65
|
|
|
64
66
|
if (workletPromise === undefined) {
|
|
65
67
|
workletPromise = this.context.addAudioWorkletModule(blobUrl);
|
|
@@ -86,30 +86,28 @@ describe("AutoFilter", () => {
|
|
|
86
86
|
autoFilter.dispose();
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
-
it("can sync the frequency to the transport", () => {
|
|
90
|
-
|
|
89
|
+
it("can sync the frequency to the transport", async () => {
|
|
90
|
+
const buffer = await Offline(({ transport }) => {
|
|
91
91
|
const autoFilter = new AutoFilter(2);
|
|
92
92
|
autoFilter.sync();
|
|
93
93
|
autoFilter.frequency.toDestination();
|
|
94
94
|
transport.bpm.setValueAtTime(transport.bpm.value * 2, 0.05);
|
|
95
95
|
// transport.start(0)
|
|
96
|
-
}, 0.1)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
});
|
|
96
|
+
}, 0.1);
|
|
97
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(2, 0.1);
|
|
98
|
+
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(4, 0.1);
|
|
100
99
|
});
|
|
101
100
|
|
|
102
|
-
it("can unsync the frequency to the transport", () => {
|
|
103
|
-
|
|
101
|
+
it("can unsync the frequency to the transport", async () => {
|
|
102
|
+
const buffer = await Offline(({ transport }) => {
|
|
104
103
|
const autoFilter = new AutoFilter(2);
|
|
105
104
|
autoFilter.sync();
|
|
106
105
|
autoFilter.frequency.toDestination();
|
|
107
106
|
transport.bpm.setValueAtTime(transport.bpm.value * 2, 0.05);
|
|
108
107
|
autoFilter.unsync();
|
|
109
|
-
}, 0.1)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
});
|
|
108
|
+
}, 0.1);
|
|
109
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(2, 0.1);
|
|
110
|
+
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(2, 0.1);
|
|
113
111
|
});
|
|
114
112
|
});
|
|
115
113
|
});
|
|
@@ -62,31 +62,29 @@ describe("AutoPanner", () => {
|
|
|
62
62
|
autoPanner.dispose();
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
it("can sync the frequency to the transport", () => {
|
|
66
|
-
|
|
65
|
+
it("can sync the frequency to the transport", async () => {
|
|
66
|
+
const buffer = await Offline(({ transport }) => {
|
|
67
67
|
const panner = new AutoPanner(2);
|
|
68
68
|
panner.sync();
|
|
69
69
|
panner.frequency.toDestination();
|
|
70
70
|
transport.bpm.setValueAtTime(transport.bpm.value * 2, 0.05);
|
|
71
71
|
// transport.start(0)
|
|
72
|
-
}, 0.1)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
72
|
+
}, 0.1);
|
|
73
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(2, 0.1);
|
|
74
|
+
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(4, 0.1);
|
|
76
75
|
});
|
|
77
76
|
|
|
78
|
-
it("can unsync the frequency to the transport", () => {
|
|
79
|
-
|
|
77
|
+
it("can unsync the frequency to the transport", async () => {
|
|
78
|
+
const buffer = await Offline(({ transport }) => {
|
|
80
79
|
const panner = new AutoPanner(2);
|
|
81
80
|
panner.sync();
|
|
82
81
|
panner.frequency.toDestination();
|
|
83
82
|
transport.bpm.setValueAtTime(transport.bpm.value * 2, 0.05);
|
|
84
83
|
panner.unsync();
|
|
85
84
|
// transport.start(0)
|
|
86
|
-
}, 0.1)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
85
|
+
}, 0.1);
|
|
86
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(2, 0.1);
|
|
87
|
+
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(2, 0.1);
|
|
90
88
|
});
|
|
91
89
|
});
|
|
92
90
|
});
|
|
@@ -60,31 +60,27 @@ describe("Chorus", () => {
|
|
|
60
60
|
chorus.dispose();
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
it("can sync the frequency to the transport", () => {
|
|
64
|
-
|
|
63
|
+
it("can sync the frequency to the transport", async () => {
|
|
64
|
+
const buffer = await Offline(({ transport }) => {
|
|
65
65
|
const chorus = new Chorus(2);
|
|
66
66
|
chorus.sync();
|
|
67
67
|
chorus.frequency.toDestination();
|
|
68
68
|
transport.bpm.setValueAtTime(transport.bpm.value * 2, 0.05);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(4, 0.1);
|
|
73
|
-
});
|
|
69
|
+
}, 0.1);
|
|
70
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(2, 0.1);
|
|
71
|
+
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(4, 0.1);
|
|
74
72
|
});
|
|
75
73
|
|
|
76
|
-
it("can unsync the frequency to the transport", () => {
|
|
77
|
-
|
|
74
|
+
it("can unsync the frequency to the transport", async () => {
|
|
75
|
+
const buffer = await Offline(({ transport }) => {
|
|
78
76
|
const chorus = new Chorus(2);
|
|
79
77
|
chorus.sync();
|
|
80
78
|
chorus.frequency.toDestination();
|
|
81
79
|
transport.bpm.setValueAtTime(transport.bpm.value * 2, 0.05);
|
|
82
80
|
chorus.unsync();
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(2, 0.1);
|
|
87
|
-
});
|
|
81
|
+
}, 0.1);
|
|
82
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(2, 0.1);
|
|
83
|
+
expect(buffer.getValueAtTime(0.05)).to.be.closeTo(2, 0.1);
|
|
88
84
|
});
|
|
89
85
|
});
|
|
90
86
|
});
|
|
@@ -41,17 +41,16 @@ describe("FrequencyShifter", () => {
|
|
|
41
41
|
shifter.dispose();
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
it("passes audio from input to output", () => {
|
|
45
|
-
|
|
44
|
+
it("passes audio from input to output", async () => {
|
|
45
|
+
const buffer = await Offline(() => {
|
|
46
46
|
const osc = new Oscillator();
|
|
47
47
|
osc.start(0).stop(0.1);
|
|
48
48
|
const shifter = new FrequencyShifter(0.2).toDestination();
|
|
49
49
|
osc.connect(shifter);
|
|
50
|
-
}, 0.3)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
50
|
+
}, 0.3);
|
|
51
|
+
expect(buffer.getRmsAtTime(0.05)).to.be.greaterThan(0);
|
|
52
|
+
expect(buffer.getRmsAtTime(0.1)).to.be.greaterThan(0);
|
|
53
|
+
expect(buffer.getRmsAtTime(0.2)).to.be.greaterThan(0);
|
|
55
54
|
});
|
|
56
55
|
});
|
|
57
56
|
});
|
|
@@ -36,38 +36,35 @@ describe("Reverb", () => {
|
|
|
36
36
|
reverb.dispose();
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
it("can generate an IR", () => {
|
|
39
|
+
it("can generate an IR", async () => {
|
|
40
40
|
const reverb = new Reverb();
|
|
41
41
|
const promise = reverb.generate();
|
|
42
42
|
expect(promise).to.have.property("then");
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
43
|
+
await promise;
|
|
44
|
+
reverb.dispose();
|
|
46
45
|
});
|
|
47
46
|
|
|
48
|
-
it.skip("is silent before the reverb is generated", () => {
|
|
49
|
-
|
|
47
|
+
it.skip("is silent before the reverb is generated", async () => {
|
|
48
|
+
const buffer = await Offline(() => {
|
|
50
49
|
const osc = new Oscillator();
|
|
51
50
|
osc.start(0).stop(0.1);
|
|
52
51
|
const reverb = new Reverb(0.2).toDestination();
|
|
53
52
|
osc.connect(reverb);
|
|
54
|
-
}).then((buffer) => {
|
|
55
|
-
expect(buffer.isSilent()).to.be.true;
|
|
56
53
|
});
|
|
54
|
+
expect(buffer.isSilent()).to.be.true;
|
|
57
55
|
});
|
|
58
56
|
|
|
59
|
-
it("passes audio from input to output", () => {
|
|
60
|
-
|
|
57
|
+
it("passes audio from input to output", async () => {
|
|
58
|
+
const buffer = await Offline(async () => {
|
|
61
59
|
const osc = new Oscillator();
|
|
62
60
|
osc.start(0).stop(0.1);
|
|
63
61
|
const reverb = new Reverb(0.2).toDestination();
|
|
64
62
|
osc.connect(reverb);
|
|
65
63
|
await reverb.ready;
|
|
66
|
-
}, 0.3)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
64
|
+
}, 0.3);
|
|
65
|
+
expect(buffer.getRmsAtTime(0.05)).to.be.greaterThan(0);
|
|
66
|
+
expect(buffer.getRmsAtTime(0.1)).to.be.greaterThan(0);
|
|
67
|
+
expect(buffer.getRmsAtTime(0.2)).to.be.greaterThan(0);
|
|
71
68
|
});
|
|
72
69
|
|
|
73
70
|
it("parses number from string in input", () => {
|