tone 15.2.1 → 15.2.3
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/Analyser.ts +11 -11
- package/Tone/component/analysis/Follower.test.ts +38 -42
- package/Tone/component/analysis/MeterBase.ts +1 -1
- 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/envelope/Envelope.ts +1 -1
- 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/component/filter/LowpassCombFilter.ts +1 -1
- package/Tone/core/clock/Clock.test.ts +18 -21
- package/Tone/core/clock/TickParam.ts +1 -1
- package/Tone/core/clock/TickSignal.test.ts +24 -27
- package/Tone/core/clock/TickSource.test.ts +1 -1
- 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 +1 -1
- 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 +4 -11
- package/Tone/core/context/ToneAudioBuffers.test.ts +10 -14
- package/Tone/core/context/ToneAudioBuffers.ts +2 -2
- package/Tone/core/type/Frequency.test.ts +6 -6
- package/Tone/core/type/Ticks.test.ts +1 -1
- package/Tone/core/type/Time.test.ts +2 -2
- package/Tone/core/type/TransportTime.test.ts +1 -1
- package/Tone/core/util/IntervalTimeline.test.ts +1 -1
- package/Tone/core/util/IntervalTimeline.ts +1 -1
- package/Tone/core/util/StateTimeline.test.ts +2 -2
- package/Tone/core/util/Timeline.test.ts +1 -1
- package/Tone/core/util/Timeline.ts +1 -1
- 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/AutoWah.ts +1 -1
- package/Tone/effect/Chorus.test.ts +10 -14
- package/Tone/effect/FrequencyShifter.test.ts +6 -7
- package/Tone/effect/FrequencyShifter.ts +1 -1
- package/Tone/effect/MidSideEffect.ts +1 -1
- package/Tone/effect/Reverb.test.ts +12 -15
- package/Tone/effect/StereoWidener.ts +1 -1
- package/Tone/effect/Tremolo.test.ts +10 -12
- package/Tone/effect/Vibrato.ts +1 -1
- package/Tone/event/Loop.test.ts +29 -36
- package/Tone/event/Part.test.ts +156 -184
- package/Tone/event/Part.ts +5 -5
- package/Tone/event/Pattern.test.ts +16 -20
- package/Tone/event/Sequence.test.ts +88 -103
- package/Tone/event/Sequence.ts +1 -1
- package/Tone/event/ToneEvent.test.ts +60 -70
- package/Tone/instrument/Instrument.ts +1 -1
- package/Tone/instrument/MonoSynth.test.ts +3 -4
- package/Tone/instrument/PolySynth.test.ts +62 -74
- package/Tone/instrument/PolySynth.ts +1 -1
- package/Tone/instrument/Sampler.test.ts +39 -48
- package/Tone/instrument/Synth.test.ts +41 -48
- package/Tone/signal/AudioToGain.test.ts +4 -5
- package/Tone/signal/Multiply.test.ts +1 -1
- package/Tone/signal/Negate.test.ts +2 -2
- package/Tone/signal/Signal.test.ts +120 -143
- package/Tone/signal/Signal.ts +1 -1
- 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 +43 -49
- package/Tone/source/UserMedia.test.ts +1 -2
- 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/Players.ts +1 -1
- package/Tone/source/buffer/ToneBufferSource.test.ts +176 -211
- package/Tone/source/oscillator/LFO.test.ts +49 -61
- package/Tone/source/oscillator/OmniOscillator.ts +0 -1
- 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/analysis/Analyser.d.ts +1 -1
- package/build/esm/component/analysis/Analyser.js +11 -11
- package/build/esm/component/analysis/MeterBase.d.ts +1 -1
- package/build/esm/component/channel/Recorder.js.map +1 -1
- package/build/esm/component/envelope/Envelope.d.ts +1 -1
- package/build/esm/component/filter/LowpassCombFilter.d.ts +1 -1
- package/build/esm/core/clock/TickParam.js +1 -1
- package/build/esm/core/clock/TickParam.js.map +1 -1
- package/build/esm/core/context/Context.d.ts +1 -1
- package/build/esm/core/context/Context.js +1 -1
- package/build/esm/core/context/ToneAudioBuffers.d.ts +2 -2
- package/build/esm/core/context/ToneAudioBuffers.js +2 -2
- package/build/esm/core/util/IntervalTimeline.d.ts +1 -1
- package/build/esm/core/util/IntervalTimeline.js +1 -1
- package/build/esm/core/util/Timeline.d.ts +1 -1
- package/build/esm/core/util/Timeline.js +1 -1
- package/build/esm/core/worklet/ToneAudioWorklet.js.map +1 -1
- package/build/esm/effect/AutoWah.d.ts +1 -1
- package/build/esm/effect/FrequencyShifter.d.ts +1 -1
- package/build/esm/effect/FrequencyShifter.js +1 -1
- package/build/esm/effect/MidSideEffect.d.ts +1 -1
- package/build/esm/effect/MidSideEffect.js +1 -1
- package/build/esm/effect/StereoWidener.d.ts +1 -1
- package/build/esm/effect/StereoWidener.js +1 -1
- package/build/esm/effect/Vibrato.js +1 -1
- package/build/esm/effect/Vibrato.js.map +1 -1
- package/build/esm/event/Part.d.ts +2 -2
- package/build/esm/event/Part.js +5 -5
- package/build/esm/event/Part.js.map +1 -1
- package/build/esm/event/Sequence.d.ts +1 -1
- package/build/esm/instrument/Instrument.d.ts +1 -1
- package/build/esm/instrument/PolySynth.d.ts +1 -1
- package/build/esm/instrument/PolySynth.js +1 -1
- package/build/esm/signal/Signal.d.ts +1 -1
- package/build/esm/signal/Signal.js +1 -1
- package/build/esm/source/buffer/Players.d.ts +1 -1
- package/build/esm/source/buffer/Players.js +1 -1
- package/build/esm/source/oscillator/OmniOscillator.js +0 -1
- package/build/esm/source/oscillator/OmniOscillator.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +3 -1
|
@@ -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
|
});
|
package/Tone/effect/AutoWah.ts
CHANGED
|
@@ -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
|
});
|
|
@@ -20,7 +20,7 @@ export interface FrequencyShifterOptions extends EffectOptions {
|
|
|
20
20
|
* Note: Contrary to pitch shifting, all frequencies are shifted by the same amount,
|
|
21
21
|
* destroying the harmonic relationship between them. This leads to the classic ring modulator timbre distortion.
|
|
22
22
|
* The algorithm will produces some aliasing towards the high end, especially if your source material
|
|
23
|
-
* contains a lot of high frequencies.
|
|
23
|
+
* contains a lot of high frequencies. Unfortunately the Web Audio API does not support resampling
|
|
24
24
|
* buffers in real time, so it is not possible to fix it properly. Depending on the use case it might
|
|
25
25
|
* be an option to low pass filter your input before frequency shifting it to get ride of the aliasing.
|
|
26
26
|
* You can find a very detailed description of the algorithm here: https://larzeitlin.github.io/RMFS/
|
|
@@ -10,7 +10,7 @@ export type MidSideEffectOptions = EffectOptions;
|
|
|
10
10
|
* (which comes out of both the left and the right channel)
|
|
11
11
|
* and the 'side' (which only comes out of the the side channels)
|
|
12
12
|
* and effects them separately before being recombined.
|
|
13
|
-
* Applies a Mid/Side
|
|
13
|
+
* Applies a Mid/Side separation and recombination.
|
|
14
14
|
* Algorithm found in [kvraudio forums](http://www.kvraudio.com/forum/viewtopic.php?t=212587).
|
|
15
15
|
* This is a base-class for Mid/Side Effects.
|
|
16
16
|
* @category Effect
|
|
@@ -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", () => {
|
|
@@ -15,7 +15,7 @@ export interface StereoWidenerOptions extends MidSideEffectOptions {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Applies a width factor to the mid/side
|
|
18
|
+
* Applies a width factor to the mid/side separation.
|
|
19
19
|
* 0 is all mid and 1 is all side.
|
|
20
20
|
* Algorithm found in [kvraudio forums](http://www.kvraudio.com/forum/viewtopic.php?t=212587).
|
|
21
21
|
* ```
|
|
@@ -60,29 +60,27 @@ describe("Tremolo", () => {
|
|
|
60
60
|
tremolo.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 tremolo = new Tremolo(2);
|
|
66
66
|
tremolo.sync();
|
|
67
67
|
tremolo.frequency.toDestination();
|
|
68
68
|
transport.bpm.setValueAtTime(transport.bpm.value * 2, 0.05);
|
|
69
|
-
}, 0.1)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
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);
|
|
73
72
|
});
|
|
74
73
|
|
|
75
|
-
it("can unsync the frequency to the transport", () => {
|
|
76
|
-
|
|
74
|
+
it("can unsync the frequency to the transport", async () => {
|
|
75
|
+
const buffer = await Offline(({ transport }) => {
|
|
77
76
|
const tremolo = new Tremolo(2);
|
|
78
77
|
tremolo.sync();
|
|
79
78
|
tremolo.frequency.toDestination();
|
|
80
79
|
transport.bpm.setValueAtTime(transport.bpm.value * 2, 0.05);
|
|
81
80
|
tremolo.unsync();
|
|
82
|
-
}, 0.1)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
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);
|
|
86
84
|
});
|
|
87
85
|
});
|
|
88
86
|
});
|
package/Tone/effect/Vibrato.ts
CHANGED
|
@@ -65,7 +65,7 @@ export class Vibrato extends Effect<VibratoOptions> {
|
|
|
65
65
|
min: 0,
|
|
66
66
|
max: options.maxDelay,
|
|
67
67
|
frequency: options.frequency,
|
|
68
|
-
phase: -90, //
|
|
68
|
+
phase: -90, // offset the phase so the resting position is in the center
|
|
69
69
|
})
|
|
70
70
|
.start()
|
|
71
71
|
.connect(this._delayNode.delayTime);
|
package/Tone/event/Loop.test.ts
CHANGED
|
@@ -97,22 +97,21 @@ describe("Loop", () => {
|
|
|
97
97
|
}, 0.3);
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
it("is invoked after it's started", () => {
|
|
100
|
+
it("is invoked after it's started", async () => {
|
|
101
101
|
let invoked = false;
|
|
102
|
-
|
|
102
|
+
await Offline(({ transport }) => {
|
|
103
103
|
const loop = new Loop(() => {
|
|
104
104
|
invoked = true;
|
|
105
105
|
loop.dispose();
|
|
106
106
|
}, 0.05).start(0);
|
|
107
107
|
transport.start();
|
|
108
|
-
}).then(() => {
|
|
109
|
-
expect(invoked).to.be.true;
|
|
110
108
|
});
|
|
109
|
+
expect(invoked).to.be.true;
|
|
111
110
|
});
|
|
112
111
|
|
|
113
|
-
it("passes in the scheduled time to the callback", () => {
|
|
112
|
+
it("passes in the scheduled time to the callback", async () => {
|
|
114
113
|
let invoked = false;
|
|
115
|
-
|
|
114
|
+
await Offline(({ transport }) => {
|
|
116
115
|
const now = transport.now() + 0.1;
|
|
117
116
|
const loop = new Loop((time) => {
|
|
118
117
|
expect(time).to.be.a("number");
|
|
@@ -122,9 +121,8 @@ describe("Loop", () => {
|
|
|
122
121
|
});
|
|
123
122
|
transport.start(now);
|
|
124
123
|
loop.start(0.3);
|
|
125
|
-
}, 0.5)
|
|
126
|
-
|
|
127
|
-
});
|
|
124
|
+
}, 0.5);
|
|
125
|
+
expect(invoked).to.be.true;
|
|
128
126
|
});
|
|
129
127
|
|
|
130
128
|
it("can mute the callback", () => {
|
|
@@ -218,9 +216,9 @@ describe("Loop", () => {
|
|
|
218
216
|
});
|
|
219
217
|
|
|
220
218
|
context("Looping", () => {
|
|
221
|
-
it("loops", () => {
|
|
219
|
+
it("loops", async () => {
|
|
222
220
|
let callCount = 0;
|
|
223
|
-
|
|
221
|
+
await Offline(({ transport }) => {
|
|
224
222
|
new Loop({
|
|
225
223
|
interval: 0.1,
|
|
226
224
|
callback: () => {
|
|
@@ -228,14 +226,13 @@ describe("Loop", () => {
|
|
|
228
226
|
},
|
|
229
227
|
}).start(0);
|
|
230
228
|
transport.start();
|
|
231
|
-
}, 0.81)
|
|
232
|
-
|
|
233
|
-
});
|
|
229
|
+
}, 0.81);
|
|
230
|
+
expect(callCount).to.equal(9);
|
|
234
231
|
});
|
|
235
232
|
|
|
236
|
-
it("loops for the specified interval", () => {
|
|
233
|
+
it("loops for the specified interval", async () => {
|
|
237
234
|
let invoked = false;
|
|
238
|
-
|
|
235
|
+
await Offline(({ transport }) => {
|
|
239
236
|
let lastCall;
|
|
240
237
|
new Loop({
|
|
241
238
|
interval: "8n",
|
|
@@ -248,14 +245,13 @@ describe("Loop", () => {
|
|
|
248
245
|
},
|
|
249
246
|
}).start(0);
|
|
250
247
|
transport.start();
|
|
251
|
-
}, 1)
|
|
252
|
-
|
|
253
|
-
});
|
|
248
|
+
}, 1);
|
|
249
|
+
expect(invoked).to.be.true;
|
|
254
250
|
});
|
|
255
251
|
|
|
256
|
-
it("can loop a specific number of iterations", () => {
|
|
252
|
+
it("can loop a specific number of iterations", async () => {
|
|
257
253
|
let callCount = 0;
|
|
258
|
-
|
|
254
|
+
await Offline(({ transport }) => {
|
|
259
255
|
new Loop({
|
|
260
256
|
interval: 0.1,
|
|
261
257
|
iterations: 2,
|
|
@@ -264,13 +260,12 @@ describe("Loop", () => {
|
|
|
264
260
|
},
|
|
265
261
|
}).start(0);
|
|
266
262
|
transport.start();
|
|
267
|
-
}, 0.4)
|
|
268
|
-
|
|
269
|
-
});
|
|
263
|
+
}, 0.4);
|
|
264
|
+
expect(callCount).to.equal(2);
|
|
270
265
|
});
|
|
271
266
|
|
|
272
|
-
it("reports the progress of the loop", () => {
|
|
273
|
-
|
|
267
|
+
it("reports the progress of the loop", async () => {
|
|
268
|
+
await Offline(({ transport }) => {
|
|
274
269
|
const loop = new Loop({
|
|
275
270
|
interval: 1,
|
|
276
271
|
}).start(0);
|
|
@@ -283,9 +278,9 @@ describe("Loop", () => {
|
|
|
283
278
|
});
|
|
284
279
|
|
|
285
280
|
context("playbackRate", () => {
|
|
286
|
-
it("can adjust the playbackRate", () => {
|
|
281
|
+
it("can adjust the playbackRate", async () => {
|
|
287
282
|
let invoked = false;
|
|
288
|
-
|
|
283
|
+
await Offline(({ transport }) => {
|
|
289
284
|
let lastCall;
|
|
290
285
|
const loop = new Loop({
|
|
291
286
|
playbackRate: 2,
|
|
@@ -300,14 +295,13 @@ describe("Loop", () => {
|
|
|
300
295
|
}).start(0);
|
|
301
296
|
expect(loop.playbackRate).to.equal(2);
|
|
302
297
|
transport.start();
|
|
303
|
-
}, 0.7)
|
|
304
|
-
|
|
305
|
-
});
|
|
298
|
+
}, 0.7);
|
|
299
|
+
expect(invoked).to.be.true;
|
|
306
300
|
});
|
|
307
301
|
|
|
308
|
-
it("can playback at a faster rate", () => {
|
|
302
|
+
it("can playback at a faster rate", async () => {
|
|
309
303
|
let callCount = 0;
|
|
310
|
-
|
|
304
|
+
await Offline(({ transport }) => {
|
|
311
305
|
const loop = new Loop({
|
|
312
306
|
interval: 0.1,
|
|
313
307
|
callback: () => {
|
|
@@ -317,9 +311,8 @@ describe("Loop", () => {
|
|
|
317
311
|
loop.playbackRate = 1.5;
|
|
318
312
|
expect(loop.playbackRate).to.equal(1.5);
|
|
319
313
|
transport.start();
|
|
320
|
-
}, 0.81)
|
|
321
|
-
|
|
322
|
-
});
|
|
314
|
+
}, 0.81);
|
|
315
|
+
expect(callCount).to.equal(13);
|
|
323
316
|
});
|
|
324
317
|
});
|
|
325
318
|
});
|