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
|
@@ -16,8 +16,8 @@ describe("SyncedSignal", () => {
|
|
|
16
16
|
sched.dispose();
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("can schedule setValueAtTime relative to the Transport", () => {
|
|
20
|
-
|
|
19
|
+
it("can schedule setValueAtTime relative to the Transport", async () => {
|
|
20
|
+
const buffer = await Offline(
|
|
21
21
|
({ transport }) => {
|
|
22
22
|
const sched = new SyncedSignal(1).toDestination();
|
|
23
23
|
sched.setValueAtTime(2, 0.1);
|
|
@@ -26,16 +26,15 @@ describe("SyncedSignal", () => {
|
|
|
26
26
|
},
|
|
27
27
|
0.4,
|
|
28
28
|
1
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
29
|
+
);
|
|
30
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.07);
|
|
31
|
+
expect(buffer.getValueAtTime(0.1)).to.be.closeTo(1, 0.07);
|
|
32
|
+
expect(buffer.getValueAtTime(0.201)).to.be.closeTo(2, 0.07);
|
|
33
|
+
expect(buffer.getValueAtTime(0.301)).to.be.closeTo(3, 0.07);
|
|
35
34
|
});
|
|
36
35
|
|
|
37
|
-
it("can schedule linearRampToValueAtTime relative to the Transport", () => {
|
|
38
|
-
|
|
36
|
+
it("can schedule linearRampToValueAtTime relative to the Transport", async () => {
|
|
37
|
+
const buffer = await Offline(
|
|
39
38
|
({ transport }) => {
|
|
40
39
|
const sched = new SyncedSignal(1).toDestination();
|
|
41
40
|
sched.setValueAtTime(1, 0.1);
|
|
@@ -44,17 +43,16 @@ describe("SyncedSignal", () => {
|
|
|
44
43
|
},
|
|
45
44
|
0.4,
|
|
46
45
|
1
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
46
|
+
);
|
|
47
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.07);
|
|
48
|
+
expect(buffer.getValueAtTime(0.1)).to.be.closeTo(1, 0.07);
|
|
49
|
+
expect(buffer.getValueAtTime(0.2)).to.be.closeTo(1, 0.07);
|
|
50
|
+
expect(buffer.getValueAtTime(0.25)).to.be.closeTo(1.5, 0.07);
|
|
51
|
+
expect(buffer.getValueAtTime(0.301)).to.be.closeTo(2, 0.07);
|
|
54
52
|
});
|
|
55
53
|
|
|
56
|
-
it("can schedule exponentialRampToValueAtTime relative to the Transport", () => {
|
|
57
|
-
|
|
54
|
+
it("can schedule exponentialRampToValueAtTime relative to the Transport", async () => {
|
|
55
|
+
const buffer = await Offline(
|
|
58
56
|
({ transport }) => {
|
|
59
57
|
const sched = new SyncedSignal(1).toDestination();
|
|
60
58
|
sched.setValueAtTime(1, 0.1);
|
|
@@ -63,180 +61,169 @@ describe("SyncedSignal", () => {
|
|
|
63
61
|
},
|
|
64
62
|
0.4,
|
|
65
63
|
1
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
64
|
+
);
|
|
65
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.07);
|
|
66
|
+
expect(buffer.getValueAtTime(0.1)).to.be.closeTo(1, 0.07);
|
|
67
|
+
expect(buffer.getValueAtTime(0.2)).to.be.closeTo(1, 0.07);
|
|
68
|
+
expect(buffer.getValueAtTime(0.25)).to.be.closeTo(1.4, 0.07);
|
|
69
|
+
expect(buffer.getValueAtTime(0.301)).to.be.closeTo(2, 0.07);
|
|
73
70
|
});
|
|
74
71
|
|
|
75
|
-
it("can get exponential ramp value in the future", () => {
|
|
72
|
+
it("can get exponential ramp value in the future", async () => {
|
|
76
73
|
let sched;
|
|
77
|
-
|
|
74
|
+
const buffer = await Offline(({ transport }) => {
|
|
78
75
|
sched = new SyncedSignal(0.5).toDestination();
|
|
79
76
|
sched.setValueAtTime(0.5, 0);
|
|
80
77
|
sched.exponentialRampToValueAtTime(1, 0.2);
|
|
81
78
|
sched.exponentialRampToValueAtTime(0.5, 0.4);
|
|
82
79
|
transport.start(0.1);
|
|
83
|
-
}, 0.6)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
});
|
|
80
|
+
}, 0.6);
|
|
81
|
+
buffer.forEach((sample, time) => {
|
|
82
|
+
expect(sample).to.be.closeTo(
|
|
83
|
+
sched.getValueAtTime(time - 0.1),
|
|
84
|
+
0.07
|
|
85
|
+
);
|
|
90
86
|
});
|
|
91
87
|
});
|
|
92
88
|
|
|
93
|
-
it("can get exponential approach in the future", () => {
|
|
89
|
+
it("can get exponential approach in the future", async () => {
|
|
94
90
|
let sched;
|
|
95
|
-
|
|
91
|
+
const buffer = await Offline(({ transport }) => {
|
|
96
92
|
sched = new SyncedSignal(0.5).toDestination();
|
|
97
93
|
sched.setValueAtTime(0.5, 0);
|
|
98
94
|
sched.setTargetAtTime(1, 0.2, 0.2);
|
|
99
95
|
transport.start(0.1);
|
|
100
|
-
}, 0.6)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
96
|
+
}, 0.6);
|
|
97
|
+
buffer.forEach((sample, time) => {
|
|
98
|
+
expect(sample).to.be.closeTo(
|
|
99
|
+
sched.getValueAtTime(time - 0.1),
|
|
100
|
+
0.07
|
|
101
|
+
);
|
|
107
102
|
});
|
|
108
103
|
});
|
|
109
104
|
|
|
110
|
-
it("can loop the signal when the Transport loops", () => {
|
|
105
|
+
it("can loop the signal when the Transport loops", async () => {
|
|
111
106
|
let sched;
|
|
112
|
-
|
|
107
|
+
const buffer = await Offline(({ transport }) => {
|
|
113
108
|
sched = new SyncedSignal(1).toDestination();
|
|
114
109
|
transport.setLoopPoints(0, 1);
|
|
115
110
|
transport.loop = true;
|
|
116
111
|
sched.setValueAtTime(1, 0);
|
|
117
112
|
sched.setValueAtTime(2, 0.5);
|
|
118
113
|
transport.start(0);
|
|
119
|
-
}, 2)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
});
|
|
114
|
+
}, 2);
|
|
115
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.01);
|
|
116
|
+
expect(buffer.getValueAtTime(0.5)).to.be.closeTo(2, 0.01);
|
|
117
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(1, 0.01);
|
|
118
|
+
expect(buffer.getValueAtTime(1.5)).to.be.closeTo(2, 0.01);
|
|
125
119
|
});
|
|
126
120
|
|
|
127
|
-
it("can get set a curve in the future", () => {
|
|
121
|
+
it("can get set a curve in the future", async () => {
|
|
128
122
|
let sched;
|
|
129
|
-
|
|
123
|
+
const buffer = await Offline(({ transport }) => {
|
|
130
124
|
sched = new SyncedSignal(0).toDestination();
|
|
131
125
|
sched.setValueCurveAtTime([0, 1, 0.2, 0.8, 0], 0, 1);
|
|
132
126
|
transport.start(0.2);
|
|
133
|
-
}, 1)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
127
|
+
}, 1);
|
|
128
|
+
buffer.forEach((sample, time) => {
|
|
129
|
+
expect(sample).to.be.closeTo(
|
|
130
|
+
sched.getValueAtTime(time - 0.2),
|
|
131
|
+
0.07
|
|
132
|
+
);
|
|
140
133
|
});
|
|
141
134
|
});
|
|
142
135
|
|
|
143
|
-
it("can scale a curve value", () => {
|
|
136
|
+
it("can scale a curve value", async () => {
|
|
144
137
|
let sched;
|
|
145
|
-
|
|
138
|
+
const buffer = await Offline(({ transport }) => {
|
|
146
139
|
sched = new SyncedSignal(1).toDestination();
|
|
147
140
|
sched.setValueCurveAtTime([0, 1, 0], 0, 1, 0.5);
|
|
148
141
|
transport.start(0);
|
|
149
|
-
}, 1)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
142
|
+
}, 1);
|
|
143
|
+
buffer.forEach((sample) => {
|
|
144
|
+
expect(sample).to.be.at.most(0.51);
|
|
153
145
|
});
|
|
154
146
|
});
|
|
155
147
|
|
|
156
|
-
it("can schedule a linear ramp between two times", () => {
|
|
148
|
+
it("can schedule a linear ramp between two times", async () => {
|
|
157
149
|
let sched;
|
|
158
|
-
|
|
150
|
+
const buffer = await Offline(({ transport }) => {
|
|
159
151
|
sched = new SyncedSignal(0).toDestination();
|
|
160
152
|
sched.linearRampTo(1, 1, 1);
|
|
161
153
|
transport.start(0);
|
|
162
|
-
}, 3)
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
});
|
|
154
|
+
}, 3);
|
|
155
|
+
expect(buffer.getValueAtTime(0)).to.closeTo(0, 0.1);
|
|
156
|
+
expect(buffer.getValueAtTime(0.5)).to.closeTo(0, 0.1);
|
|
157
|
+
expect(buffer.getValueAtTime(1)).to.closeTo(0, 0.1);
|
|
158
|
+
expect(buffer.getValueAtTime(1.5)).to.closeTo(0.5, 0.1);
|
|
159
|
+
expect(buffer.getValueAtTime(2)).to.closeTo(1, 0.1);
|
|
169
160
|
});
|
|
170
161
|
|
|
171
|
-
it("can get exponential ramp value between two times", () => {
|
|
162
|
+
it("can get exponential ramp value between two times", async () => {
|
|
172
163
|
let sched;
|
|
173
|
-
|
|
164
|
+
const buffer = await Offline(({ transport }) => {
|
|
174
165
|
sched = new SyncedSignal(1).toDestination();
|
|
175
166
|
sched.exponentialRampTo(3, 1, 1);
|
|
176
167
|
transport.start(0);
|
|
177
|
-
}, 3)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
});
|
|
168
|
+
}, 3);
|
|
169
|
+
expect(buffer.getValueAtTime(0)).to.closeTo(1, 0.1);
|
|
170
|
+
expect(buffer.getValueAtTime(0.5)).to.closeTo(1, 0.1);
|
|
171
|
+
expect(buffer.getValueAtTime(1)).to.closeTo(1, 0.1);
|
|
172
|
+
expect(buffer.getValueAtTime(1.5)).to.closeTo(1.75, 0.1);
|
|
173
|
+
expect(buffer.getValueAtTime(2)).to.closeTo(3, 0.1);
|
|
184
174
|
});
|
|
185
175
|
|
|
186
|
-
it("can cancel and hold a scheduled value", () => {
|
|
176
|
+
it("can cancel and hold a scheduled value", async () => {
|
|
187
177
|
let sched;
|
|
188
|
-
|
|
178
|
+
const buffer = await Offline(({ transport }) => {
|
|
189
179
|
sched = new SyncedSignal(0).toDestination();
|
|
190
180
|
sched.setValueAtTime(0, 0);
|
|
191
181
|
sched.linearRampToValueAtTime(1, 1);
|
|
192
182
|
sched.cancelAndHoldAtTime(0.5);
|
|
193
183
|
transport.start(0);
|
|
194
|
-
}, 1)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
});
|
|
184
|
+
}, 1);
|
|
185
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.1);
|
|
186
|
+
expect(buffer.getValueAtTime(0.25)).to.be.closeTo(0.25, 0.1);
|
|
187
|
+
expect(buffer.getValueAtTime(0.5)).to.be.closeTo(0.5, 0.1);
|
|
188
|
+
expect(buffer.getValueAtTime(0.75)).to.be.closeTo(0.5, 0.1);
|
|
200
189
|
});
|
|
201
190
|
|
|
202
|
-
it("can cancel a scheduled value", () => {
|
|
191
|
+
it("can cancel a scheduled value", async () => {
|
|
203
192
|
let sched;
|
|
204
|
-
|
|
193
|
+
const buffer = await Offline(({ transport }) => {
|
|
205
194
|
sched = new SyncedSignal(0).toDestination();
|
|
206
195
|
sched.setValueAtTime(0, 0);
|
|
207
196
|
sched.linearRampToValueAtTime(1, 0.5);
|
|
208
197
|
sched.linearRampToValueAtTime(0, 1);
|
|
209
198
|
sched.cancelScheduledValues(0.6);
|
|
210
199
|
transport.start(0);
|
|
211
|
-
}, 1)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
});
|
|
200
|
+
}, 1);
|
|
201
|
+
expect(buffer.getValueAtTime(0)).to.be.closeTo(0, 0.1);
|
|
202
|
+
expect(buffer.getValueAtTime(0.25)).to.be.closeTo(0.5, 0.1);
|
|
203
|
+
expect(buffer.getValueAtTime(0.5)).to.be.closeTo(1, 0.1);
|
|
204
|
+
expect(buffer.getValueAtTime(0.75)).to.be.closeTo(1, 0.1);
|
|
217
205
|
});
|
|
218
206
|
|
|
219
|
-
it("can automate values with different units", () => {
|
|
207
|
+
it("can automate values with different units", async () => {
|
|
220
208
|
let sched;
|
|
221
|
-
|
|
209
|
+
const buffer = await Offline(({ transport }) => {
|
|
222
210
|
sched = new SyncedSignal(-10, "decibels").toDestination();
|
|
223
211
|
sched.setValueAtTime(-5, 0);
|
|
224
212
|
sched.linearRampToValueAtTime(-12, 0.5);
|
|
225
213
|
sched.exponentialRampTo(-6, 0.1, 1);
|
|
226
214
|
transport.start(0);
|
|
227
|
-
}, 1.2)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
});
|
|
215
|
+
}, 1.2);
|
|
216
|
+
buffer.forEach((sample, time) => {
|
|
217
|
+
if (time < 0.5) {
|
|
218
|
+
expect(sample).to.be.within(
|
|
219
|
+
dbToGain(-12.01),
|
|
220
|
+
dbToGain(-4.99)
|
|
221
|
+
);
|
|
222
|
+
} else if (time < 1) {
|
|
223
|
+
expect(sample).to.be.closeTo(dbToGain(-12), 0.1);
|
|
224
|
+
} else if (time > 1.1) {
|
|
225
|
+
expect(sample).to.be.closeTo(dbToGain(-6), 0.1);
|
|
226
|
+
}
|
|
240
227
|
});
|
|
241
228
|
});
|
|
242
229
|
|
|
@@ -254,15 +241,14 @@ describe("SyncedSignal", () => {
|
|
|
254
241
|
expect(buffer.getValueAtTime(1)).to.be.closeTo(0, 0.1);
|
|
255
242
|
});
|
|
256
243
|
|
|
257
|
-
it("can set a exponential approach ramp from the current time", () => {
|
|
258
|
-
|
|
244
|
+
it("can set a exponential approach ramp from the current time", async () => {
|
|
245
|
+
const buffer = await Offline(({ transport }) => {
|
|
259
246
|
const sig = new SyncedSignal(0).toDestination();
|
|
260
247
|
sig.targetRampTo(1, 0.3);
|
|
261
248
|
transport.start(0);
|
|
262
|
-
}, 0.5)
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
});
|
|
249
|
+
}, 0.5);
|
|
250
|
+
expect(buffer.getValueAtTime(0)).to.be.below(0.07);
|
|
251
|
+
expect(buffer.getValueAtTime(0.3)).to.be.closeTo(1, 0.1);
|
|
266
252
|
});
|
|
267
253
|
});
|
|
268
254
|
});
|
|
@@ -56,9 +56,9 @@ describe("ToneConstantSource", () => {
|
|
|
56
56
|
};
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
it("invokes the onended callback in the offline context", () => {
|
|
59
|
+
it("invokes the onended callback in the offline context", async () => {
|
|
60
60
|
let wasInvoked = false;
|
|
61
|
-
|
|
61
|
+
await Offline(() => {
|
|
62
62
|
const source = new ToneConstantSource();
|
|
63
63
|
source.start(0);
|
|
64
64
|
source.stop(0.2);
|
|
@@ -67,14 +67,13 @@ describe("ToneConstantSource", () => {
|
|
|
67
67
|
source.dispose();
|
|
68
68
|
wasInvoked = true;
|
|
69
69
|
};
|
|
70
|
-
}, 0.3)
|
|
71
|
-
|
|
72
|
-
});
|
|
70
|
+
}, 0.3);
|
|
71
|
+
expect(wasInvoked).to.equal(true);
|
|
73
72
|
});
|
|
74
73
|
|
|
75
|
-
it("invokes the onended callback only once in offline context", () => {
|
|
74
|
+
it("invokes the onended callback only once in offline context", async () => {
|
|
76
75
|
let wasInvoked = false;
|
|
77
|
-
|
|
76
|
+
await Offline(() => {
|
|
78
77
|
const source = new ToneConstantSource();
|
|
79
78
|
source.start(0);
|
|
80
79
|
source.stop(0.1);
|
|
@@ -86,9 +85,8 @@ describe("ToneConstantSource", () => {
|
|
|
86
85
|
expect(wasInvoked).to.equal(false);
|
|
87
86
|
wasInvoked = true;
|
|
88
87
|
};
|
|
89
|
-
}, 0.4)
|
|
90
|
-
|
|
91
|
-
});
|
|
88
|
+
}, 0.4);
|
|
89
|
+
expect(wasInvoked).to.equal(true);
|
|
92
90
|
});
|
|
93
91
|
});
|
|
94
92
|
|
|
@@ -102,27 +100,25 @@ describe("ToneConstantSource", () => {
|
|
|
102
100
|
source.dispose();
|
|
103
101
|
});
|
|
104
102
|
|
|
105
|
-
it("can play for a specific duration", () => {
|
|
106
|
-
|
|
103
|
+
it("can play for a specific duration", async () => {
|
|
104
|
+
const buffer = await Offline(() => {
|
|
107
105
|
const source = new ToneConstantSource().toDestination();
|
|
108
106
|
source.start(0).stop(0.1);
|
|
109
|
-
}, 0.4)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
});
|
|
107
|
+
}, 0.4);
|
|
108
|
+
expect(buffer.getValueAtTime(0)).to.be.above(0);
|
|
109
|
+
expect(buffer.getValueAtTime(0.09)).to.be.above(0);
|
|
110
|
+
expect(buffer.getValueAtTime(0.1)).to.equal(0);
|
|
114
111
|
});
|
|
115
112
|
|
|
116
|
-
it("can call stop multiple times and takes the last value", () => {
|
|
117
|
-
|
|
113
|
+
it("can call stop multiple times and takes the last value", async () => {
|
|
114
|
+
const buffer = await Offline(() => {
|
|
118
115
|
const source = new ToneConstantSource().toDestination();
|
|
119
116
|
source.start(0).stop(0.1).stop(0.2);
|
|
120
|
-
}, 0.4)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
117
|
+
}, 0.4);
|
|
118
|
+
expect(buffer.getValueAtTime(0)).to.be.above(0);
|
|
119
|
+
expect(buffer.getValueAtTime(0.1)).to.be.above(0);
|
|
120
|
+
expect(buffer.getValueAtTime(0.19)).to.be.above(0);
|
|
121
|
+
expect(buffer.getValueAtTime(0.2)).to.equal(0);
|
|
126
122
|
});
|
|
127
123
|
|
|
128
124
|
it("clamps start time to the currentTime", () => {
|
|
@@ -70,8 +70,8 @@ describe("WaveShaper", () => {
|
|
|
70
70
|
}, -20);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
it("maps the input through the waveshaping curve", () => {
|
|
74
|
-
|
|
73
|
+
it("maps the input through the waveshaping curve", async () => {
|
|
74
|
+
const buffer = await Offline(() => {
|
|
75
75
|
const signal = new Signal(-1);
|
|
76
76
|
const waveshaper = new WaveShaper((input) => {
|
|
77
77
|
return input * 2;
|
|
@@ -80,10 +80,9 @@ describe("WaveShaper", () => {
|
|
|
80
80
|
waveshaper.toDestination();
|
|
81
81
|
signal.setValueAtTime(-1, 0);
|
|
82
82
|
signal.linearRampToValueAtTime(1, 1);
|
|
83
|
-
}, 1)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
83
|
+
}, 1);
|
|
84
|
+
buffer.forEach((sample, time) => {
|
|
85
|
+
expect(sample).to.be.closeTo(2 * (time * 2 - 1), 0.005);
|
|
87
86
|
});
|
|
88
87
|
});
|
|
89
88
|
});
|
|
@@ -318,71 +318,66 @@ describe("Source", () => {
|
|
|
318
318
|
}, 0.1);
|
|
319
319
|
});
|
|
320
320
|
|
|
321
|
-
it("gives the correct offset on time on start/stop events", () => {
|
|
322
|
-
|
|
321
|
+
it("gives the correct offset on time on start/stop events", async () => {
|
|
322
|
+
const output = await Offline(({ transport }) => {
|
|
323
323
|
const source = new Player(rampBuffer).toDestination();
|
|
324
324
|
source.sync().start(0.2, 0.1).stop(0.3);
|
|
325
325
|
transport.start(0.2);
|
|
326
|
-
}, 0.7)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
});
|
|
326
|
+
}, 0.7);
|
|
327
|
+
expect(output.getValueAtTime(0.41)).to.be.closeTo(0.1, 0.01);
|
|
328
|
+
expect(output.getValueAtTime(0.45)).to.be.closeTo(0.15, 0.001);
|
|
329
|
+
expect(output.getValueAtTime(0.5)).to.be.equal(0);
|
|
331
330
|
});
|
|
332
331
|
|
|
333
|
-
it("gives the correct offset on time on start/stop events when started with an offset", () => {
|
|
334
|
-
|
|
332
|
+
it("gives the correct offset on time on start/stop events when started with an offset", async () => {
|
|
333
|
+
const output = await Offline(({ transport }) => {
|
|
335
334
|
const source = new Player(rampBuffer).toDestination();
|
|
336
335
|
source.sync().start(0.2, 0.1).stop(0.4);
|
|
337
336
|
transport.start(0.2, 0.1);
|
|
338
|
-
}, 0.7)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
});
|
|
337
|
+
}, 0.7);
|
|
338
|
+
expect(output.getValueAtTime(0.21)).to.be.closeTo(0.0, 0.01);
|
|
339
|
+
expect(output.getValueAtTime(0.31)).to.be.closeTo(0.1, 0.01);
|
|
340
|
+
expect(output.getValueAtTime(0.41)).to.be.closeTo(0.2, 0.01);
|
|
341
|
+
expect(output.getValueAtTime(0.45)).to.be.closeTo(0.25, 0.01);
|
|
342
|
+
expect(output.getValueAtTime(0.51)).to.be.equal(0);
|
|
345
343
|
});
|
|
346
344
|
|
|
347
|
-
it("gives the correct offset on time on start/stop events invoked with
|
|
348
|
-
|
|
345
|
+
it("gives the correct offset on time on start/stop events invoked with a transport offset that's in the middle of the event", async () => {
|
|
346
|
+
const output = await Offline(({ transport }) => {
|
|
349
347
|
const source = new Player(rampBuffer).toDestination();
|
|
350
348
|
source.sync().start(0.2, 0.1).stop(0.4);
|
|
351
349
|
transport.start(0, 0.3);
|
|
352
|
-
}, 0.7)
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
});
|
|
350
|
+
}, 0.7);
|
|
351
|
+
expect(output.getValueAtTime(0.01)).to.be.closeTo(0.2, 0.01);
|
|
352
|
+
expect(output.getValueAtTime(0.05)).to.be.closeTo(0.25, 0.01);
|
|
353
|
+
expect(output.getValueAtTime(0.11)).to.be.equal(0);
|
|
357
354
|
});
|
|
358
355
|
|
|
359
|
-
it("gives the correct duration when invoked with
|
|
360
|
-
|
|
356
|
+
it("gives the correct duration when invoked with a transport offset that's in the middle of the event", async () => {
|
|
357
|
+
const output = await Offline(({ transport }) => {
|
|
361
358
|
const source = new Player(rampBuffer).toDestination();
|
|
362
359
|
source.sync().start(0.2, 0.1, 0.3);
|
|
363
360
|
transport.start(0, 0.3);
|
|
364
|
-
}, 0.7)
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
});
|
|
361
|
+
}, 0.7);
|
|
362
|
+
expect(output.getValueAtTime(0.01)).to.be.closeTo(0.2, 0.01);
|
|
363
|
+
expect(output.getValueAtTime(0.1)).to.be.closeTo(0.3, 0.01);
|
|
364
|
+
expect(output.getValueAtTime(0.199)).to.be.closeTo(0.4, 0.01);
|
|
365
|
+
expect(output.getValueAtTime(0.31)).to.be.equal(0);
|
|
370
366
|
});
|
|
371
367
|
|
|
372
|
-
it("stops at the right time when transport.stop is invoked before the scheduled stop", () => {
|
|
373
|
-
|
|
368
|
+
it("stops at the right time when transport.stop is invoked before the scheduled stop", async () => {
|
|
369
|
+
const output = await Offline(({ transport }) => {
|
|
374
370
|
const source = new Player(rampBuffer).toDestination();
|
|
375
371
|
source.sync().start(0.2).stop(0.4);
|
|
376
372
|
transport.start(0).stop(0.3);
|
|
377
|
-
}, 0.7)
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
});
|
|
373
|
+
}, 0.7);
|
|
374
|
+
expect(output.getValueAtTime(0.2)).to.be.closeTo(0.0, 0.01);
|
|
375
|
+
expect(output.getValueAtTime(0.25)).to.be.closeTo(0.05, 0.01);
|
|
376
|
+
expect(output.getValueAtTime(0.31)).to.be.equal(0);
|
|
382
377
|
});
|
|
383
378
|
|
|
384
|
-
it("invokes the right methods and offsets when the transport is seeked", () => {
|
|
385
|
-
|
|
379
|
+
it("invokes the right methods and offsets when the transport is seeked", async () => {
|
|
380
|
+
const output = await Offline(({ transport }) => {
|
|
386
381
|
const source = new Player(rampBuffer).toDestination();
|
|
387
382
|
source.sync().start(0.2);
|
|
388
383
|
transport.start(0, 0.3);
|
|
@@ -391,14 +386,13 @@ describe("Source", () => {
|
|
|
391
386
|
// seek forward in time
|
|
392
387
|
transport.seconds = 0.1;
|
|
393
388
|
});
|
|
394
|
-
}, 0.7)
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
});
|
|
389
|
+
}, 0.7);
|
|
390
|
+
expect(output.getValueAtTime(0.01)).to.be.closeTo(0.1, 0.01);
|
|
391
|
+
expect(output.getValueAtTime(0.05)).to.be.closeTo(0.15, 0.01);
|
|
392
|
+
expect(output.getValueAtTime(0.11)).to.be.closeTo(0.0, 0.01);
|
|
393
|
+
expect(output.getValueAtTime(0.21)).to.be.closeTo(0.0, 0.01);
|
|
394
|
+
expect(output.getValueAtTime(0.25)).to.be.closeTo(0.05, 0.01);
|
|
395
|
+
expect(output.getValueAtTime(0.3)).to.be.closeTo(0.1, 0.01);
|
|
402
396
|
});
|
|
403
397
|
});
|
|
404
398
|
});
|