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
|
@@ -75,15 +75,14 @@ describe("Sampler", () => {
|
|
|
75
75
|
sampler.dispose();
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
it("urls can be described as either midi or notes", () => {
|
|
79
|
-
|
|
78
|
+
it("urls can be described as either midi or notes", async () => {
|
|
79
|
+
const buffer = await Offline(() => {
|
|
80
80
|
const sampler = new Sampler({
|
|
81
81
|
A4: A4_buffer,
|
|
82
82
|
}).toDestination();
|
|
83
83
|
sampler.triggerAttack("A4");
|
|
84
|
-
}).then((buffer) => {
|
|
85
|
-
expect(buffer.isSilent()).to.be.false;
|
|
86
84
|
});
|
|
85
|
+
expect(buffer.isSilent()).to.be.false;
|
|
87
86
|
});
|
|
88
87
|
|
|
89
88
|
it("throws an error if there are no available notes to play", () => {
|
|
@@ -103,7 +102,7 @@ describe("Sampler", () => {
|
|
|
103
102
|
}).throws(Error);
|
|
104
103
|
});
|
|
105
104
|
|
|
106
|
-
it("invokes onerror if the ", (
|
|
105
|
+
it("invokes onerror if the ", async () => {
|
|
107
106
|
const sampler = new Sampler({
|
|
108
107
|
urls: {
|
|
109
108
|
40: "./nosuchfile.wav",
|
|
@@ -111,9 +110,9 @@ describe("Sampler", () => {
|
|
|
111
110
|
onerror(e) {
|
|
112
111
|
expect(e).to.be.instanceOf(Error);
|
|
113
112
|
sampler.dispose();
|
|
114
|
-
done();
|
|
115
113
|
},
|
|
116
114
|
});
|
|
115
|
+
await Offline(() => {});
|
|
117
116
|
});
|
|
118
117
|
|
|
119
118
|
it("can get and set envelope attributes", () => {
|
|
@@ -168,19 +167,18 @@ describe("Sampler", () => {
|
|
|
168
167
|
});
|
|
169
168
|
|
|
170
169
|
context("Makes sound", () => {
|
|
171
|
-
it("repitches the note", () => {
|
|
172
|
-
|
|
170
|
+
it("repitches the note", async () => {
|
|
171
|
+
const buffer = await Offline(() => {
|
|
173
172
|
const sampler = new Sampler({
|
|
174
173
|
A4: A4_buffer,
|
|
175
174
|
}).toDestination();
|
|
176
175
|
sampler.triggerAttack("G4");
|
|
177
|
-
}).then((buffer) => {
|
|
178
|
-
expect(buffer.isSilent()).to.be.false;
|
|
179
176
|
});
|
|
177
|
+
expect(buffer.isSilent()).to.be.false;
|
|
180
178
|
});
|
|
181
179
|
|
|
182
|
-
it("is silent after the release", () => {
|
|
183
|
-
|
|
180
|
+
it("is silent after the release", async () => {
|
|
181
|
+
const buffer = await Offline(() => {
|
|
184
182
|
const sampler = new Sampler(
|
|
185
183
|
{
|
|
186
184
|
A4: A4_buffer,
|
|
@@ -191,13 +189,12 @@ describe("Sampler", () => {
|
|
|
191
189
|
).toDestination();
|
|
192
190
|
sampler.triggerAttack("A4", 0);
|
|
193
191
|
sampler.triggerRelease("A4", 0.2);
|
|
194
|
-
}, 0.3)
|
|
195
|
-
|
|
196
|
-
});
|
|
192
|
+
}, 0.3);
|
|
193
|
+
expect(buffer.getTimeOfLastSound()).to.be.closeTo(0.2, 0.01);
|
|
197
194
|
});
|
|
198
195
|
|
|
199
|
-
it("can triggerRelease after the buffer has already stopped", () => {
|
|
200
|
-
|
|
196
|
+
it("can triggerRelease after the buffer has already stopped", async () => {
|
|
197
|
+
const buffer = await Offline(() => {
|
|
201
198
|
const sampler = new Sampler(
|
|
202
199
|
{
|
|
203
200
|
A4: A4_buffer,
|
|
@@ -210,16 +207,15 @@ describe("Sampler", () => {
|
|
|
210
207
|
return atTime(A4_buffer.duration + 0.01, () => {
|
|
211
208
|
sampler.triggerRelease("A4");
|
|
212
209
|
});
|
|
213
|
-
}, A4_buffer.duration + 0.1)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
210
|
+
}, A4_buffer.duration + 0.1);
|
|
211
|
+
expect(buffer.getTimeOfLastSound()).to.be.closeTo(
|
|
212
|
+
A4_buffer.duration,
|
|
213
|
+
0.01
|
|
214
|
+
);
|
|
219
215
|
});
|
|
220
216
|
|
|
221
|
-
it("can release multiple notes", () => {
|
|
222
|
-
|
|
217
|
+
it("can release multiple notes", async () => {
|
|
218
|
+
const buffer = await Offline(() => {
|
|
223
219
|
const sampler = new Sampler(
|
|
224
220
|
{
|
|
225
221
|
A4: A4_buffer,
|
|
@@ -233,13 +229,12 @@ describe("Sampler", () => {
|
|
|
233
229
|
sampler.triggerAttack("A4", 0.1);
|
|
234
230
|
sampler.triggerAttack("G4", 0.1);
|
|
235
231
|
sampler.releaseAll(0.2);
|
|
236
|
-
}, 0.3)
|
|
237
|
-
|
|
238
|
-
});
|
|
232
|
+
}, 0.3);
|
|
233
|
+
expect(buffer.getTimeOfLastSound()).to.be.closeTo(0.2, 0.01);
|
|
239
234
|
});
|
|
240
235
|
|
|
241
|
-
it("can trigger the attack and release", () => {
|
|
242
|
-
|
|
236
|
+
it("can trigger the attack and release", async () => {
|
|
237
|
+
const buffer = await Offline(() => {
|
|
243
238
|
const sampler = new Sampler(
|
|
244
239
|
{
|
|
245
240
|
A4: A4_buffer,
|
|
@@ -249,14 +244,13 @@ describe("Sampler", () => {
|
|
|
249
244
|
}
|
|
250
245
|
).toDestination();
|
|
251
246
|
sampler.triggerAttackRelease("A4", 0.2, 0.1);
|
|
252
|
-
}, 0.4)
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
247
|
+
}, 0.4);
|
|
248
|
+
expect(buffer.getTimeOfFirstSound()).to.be.closeTo(0.1, 0.01);
|
|
249
|
+
expect(buffer.getTimeOfLastSound()).to.be.closeTo(0.3, 0.01);
|
|
256
250
|
});
|
|
257
251
|
|
|
258
|
-
it("can trigger polyphonic attack release", () => {
|
|
259
|
-
|
|
252
|
+
it("can trigger polyphonic attack release", async () => {
|
|
253
|
+
const buffer = await Offline(() => {
|
|
260
254
|
const sampler = new Sampler(
|
|
261
255
|
{
|
|
262
256
|
A4: A4_buffer,
|
|
@@ -266,32 +260,29 @@ describe("Sampler", () => {
|
|
|
266
260
|
}
|
|
267
261
|
).toDestination();
|
|
268
262
|
sampler.triggerAttackRelease(["A4", "C4"], [0.2, 0.3], 0.1);
|
|
269
|
-
}, 0.5)
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
});
|
|
263
|
+
}, 0.5);
|
|
264
|
+
expect(buffer.getTimeOfFirstSound()).to.be.closeTo(0.1, 0.01);
|
|
265
|
+
expect(buffer.getTimeOfLastSound()).to.be.closeTo(0.4, 0.01);
|
|
273
266
|
});
|
|
274
267
|
});
|
|
275
268
|
|
|
276
269
|
context("add samples", () => {
|
|
277
|
-
it("can add a note with it's midi value", () => {
|
|
278
|
-
|
|
270
|
+
it("can add a note with it's midi value", async () => {
|
|
271
|
+
const buffer = await Offline(() => {
|
|
279
272
|
const sampler = new Sampler().toDestination();
|
|
280
273
|
sampler.add(69, A4_buffer);
|
|
281
274
|
sampler.triggerAttack("B4");
|
|
282
|
-
}).then((buffer) => {
|
|
283
|
-
expect(buffer.isSilent()).to.be.false;
|
|
284
275
|
});
|
|
276
|
+
expect(buffer.isSilent()).to.be.false;
|
|
285
277
|
});
|
|
286
278
|
|
|
287
|
-
it("can add a note with it's note name", () => {
|
|
288
|
-
|
|
279
|
+
it("can add a note with it's note name", async () => {
|
|
280
|
+
const buffer = await Offline(() => {
|
|
289
281
|
const sampler = new Sampler().toDestination();
|
|
290
282
|
sampler.add("A4", A4_buffer);
|
|
291
283
|
sampler.triggerAttack("G4");
|
|
292
|
-
}).then((buffer) => {
|
|
293
|
-
expect(buffer.isSilent()).to.be.false;
|
|
294
284
|
});
|
|
285
|
+
expect(buffer.isSilent()).to.be.false;
|
|
295
286
|
});
|
|
296
287
|
|
|
297
288
|
it("can pass in a url and invokes the callback", (done) => {
|
|
@@ -87,17 +87,16 @@ describe("Synth", () => {
|
|
|
87
87
|
simple.dispose();
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
it("can be trigged with a Tone.Frequency", () => {
|
|
91
|
-
|
|
90
|
+
it("can be trigged with a Tone.Frequency", async () => {
|
|
91
|
+
const buffer = await Offline(() => {
|
|
92
92
|
const synth = new Synth().toDestination();
|
|
93
93
|
synth.triggerAttack(Frequency("C4"), 0);
|
|
94
|
-
}).then((buffer) => {
|
|
95
|
-
expect(buffer.isSilent()).to.be.false;
|
|
96
94
|
});
|
|
95
|
+
expect(buffer.isSilent()).to.be.false;
|
|
97
96
|
});
|
|
98
97
|
|
|
99
|
-
it("is silent after triggerAttack if sustain is 0", () => {
|
|
100
|
-
|
|
98
|
+
it("is silent after triggerAttack if sustain is 0", async () => {
|
|
99
|
+
const buffer = await Offline(() => {
|
|
101
100
|
const synth = new Synth({
|
|
102
101
|
envelope: {
|
|
103
102
|
attack: 0.1,
|
|
@@ -106,25 +105,23 @@ describe("Synth", () => {
|
|
|
106
105
|
},
|
|
107
106
|
}).toDestination();
|
|
108
107
|
synth.triggerAttack("C4", 0);
|
|
109
|
-
}, 0.5)
|
|
110
|
-
|
|
111
|
-
});
|
|
108
|
+
}, 0.5);
|
|
109
|
+
expect(buffer.getTimeOfLastSound()).to.be.closeTo(0.2, 0.01);
|
|
112
110
|
});
|
|
113
111
|
});
|
|
114
112
|
|
|
115
113
|
context("Transport sync", () => {
|
|
116
|
-
it("is silent until the transport is started", () => {
|
|
117
|
-
|
|
114
|
+
it("is silent until the transport is started", async () => {
|
|
115
|
+
const buffer = await Offline(({ transport }) => {
|
|
118
116
|
const synth = new Synth().sync().toDestination();
|
|
119
117
|
synth.triggerAttackRelease("C4", 0.5);
|
|
120
118
|
transport.start(0.5);
|
|
121
|
-
}, 1)
|
|
122
|
-
|
|
123
|
-
});
|
|
119
|
+
}, 1);
|
|
120
|
+
expect(buffer.getTimeOfFirstSound()).is.closeTo(0.5, 0.1);
|
|
124
121
|
});
|
|
125
122
|
|
|
126
|
-
it("stops when the transport is stopped", () => {
|
|
127
|
-
|
|
123
|
+
it("stops when the transport is stopped", async () => {
|
|
124
|
+
const buffer = await Offline(({ transport }) => {
|
|
128
125
|
const synth = new Synth({
|
|
129
126
|
envelope: {
|
|
130
127
|
release: 0,
|
|
@@ -134,13 +131,12 @@ describe("Synth", () => {
|
|
|
134
131
|
.toDestination();
|
|
135
132
|
synth.triggerAttackRelease("C4", 0.5);
|
|
136
133
|
transport.start(0.5).stop(1);
|
|
137
|
-
}, 1.5)
|
|
138
|
-
|
|
139
|
-
});
|
|
134
|
+
}, 1.5);
|
|
135
|
+
expect(buffer.getTimeOfLastSound()).is.closeTo(1, 0.1);
|
|
140
136
|
});
|
|
141
137
|
|
|
142
|
-
it("goes silent at the loop boundary", () => {
|
|
143
|
-
|
|
138
|
+
it("goes silent at the loop boundary", async () => {
|
|
139
|
+
const buffer = await Offline(({ transport }) => {
|
|
144
140
|
const synth = new Synth({
|
|
145
141
|
envelope: {
|
|
146
142
|
release: 0,
|
|
@@ -152,16 +148,15 @@ describe("Synth", () => {
|
|
|
152
148
|
transport.loopEnd = 1;
|
|
153
149
|
transport.loop = true;
|
|
154
150
|
transport.start();
|
|
155
|
-
}, 2)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
151
|
+
}, 2);
|
|
152
|
+
expect(buffer.getRmsAtTime(0)).to.be.closeTo(0, 0.05);
|
|
153
|
+
expect(buffer.getRmsAtTime(0.6)).to.be.closeTo(0.2, 0.05);
|
|
154
|
+
expect(buffer.getRmsAtTime(1.1)).to.be.closeTo(0, 0.05);
|
|
155
|
+
expect(buffer.getRmsAtTime(1.6)).to.be.closeTo(0.2, 0.05);
|
|
161
156
|
});
|
|
162
157
|
|
|
163
|
-
it("can unsync", () => {
|
|
164
|
-
|
|
158
|
+
it("can unsync", async () => {
|
|
159
|
+
const buffer = await Offline(({ transport }) => {
|
|
165
160
|
const synth = new Synth({
|
|
166
161
|
envelope: {
|
|
167
162
|
sustain: 1,
|
|
@@ -173,18 +168,17 @@ describe("Synth", () => {
|
|
|
173
168
|
.unsync();
|
|
174
169
|
synth.triggerAttackRelease("C4", 1, 0.5);
|
|
175
170
|
transport.start().stop(1);
|
|
176
|
-
}, 2)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
});
|
|
171
|
+
}, 2);
|
|
172
|
+
expect(buffer.getRmsAtTime(0)).to.be.closeTo(0, 0.05);
|
|
173
|
+
expect(buffer.getRmsAtTime(0.6)).to.be.closeTo(0.6, 0.05);
|
|
174
|
+
expect(buffer.getRmsAtTime(1.4)).to.be.closeTo(0.6, 0.05);
|
|
175
|
+
expect(buffer.getRmsAtTime(1.6)).to.be.closeTo(0, 0.05);
|
|
182
176
|
});
|
|
183
177
|
});
|
|
184
178
|
|
|
185
179
|
context("Portamento", () => {
|
|
186
|
-
it("can play notes with a portamento", () => {
|
|
187
|
-
|
|
180
|
+
it("can play notes with a portamento", async () => {
|
|
181
|
+
const buffer = await Offline(() => {
|
|
188
182
|
const synth = new Synth({
|
|
189
183
|
portamento: 0.1,
|
|
190
184
|
});
|
|
@@ -192,16 +186,15 @@ describe("Synth", () => {
|
|
|
192
186
|
synth.frequency.toDestination();
|
|
193
187
|
synth.triggerAttack(440, 0);
|
|
194
188
|
synth.triggerAttack(880, 0.1);
|
|
195
|
-
}, 0.2)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
});
|
|
189
|
+
}, 0.2);
|
|
190
|
+
buffer.forEach((val, time) => {
|
|
191
|
+
if (time < 0.1) {
|
|
192
|
+
expect(val).to.be.closeTo(440, 1);
|
|
193
|
+
} else if (time < 0.2) {
|
|
194
|
+
expect(val).to.within(440, 880);
|
|
195
|
+
} else {
|
|
196
|
+
expect(val).to.be.closeTo(880, 1);
|
|
197
|
+
}
|
|
205
198
|
});
|
|
206
199
|
});
|
|
207
200
|
});
|
|
@@ -11,16 +11,15 @@ import { Zero } from "./Zero.js";
|
|
|
11
11
|
describe("AudioToGain", () => {
|
|
12
12
|
BasicTests(AudioToGain);
|
|
13
13
|
|
|
14
|
-
it("normalizes an oscillator to 0,1", () => {
|
|
15
|
-
|
|
14
|
+
it("normalizes an oscillator to 0,1", async () => {
|
|
15
|
+
const buffer = await Offline(() => {
|
|
16
16
|
const osc = new Oscillator(1000).start();
|
|
17
17
|
const a2g = new AudioToGain();
|
|
18
18
|
osc.connect(a2g);
|
|
19
19
|
a2g.toDestination();
|
|
20
|
-
}).then((buffer) => {
|
|
21
|
-
expect(buffer.min()).to.be.closeTo(0, 0.01);
|
|
22
|
-
expect(buffer.max()).to.be.closeTo(1, 0.01);
|
|
23
20
|
});
|
|
21
|
+
expect(buffer.min()).to.be.closeTo(0, 0.01);
|
|
22
|
+
expect(buffer.max()).to.be.closeTo(1, 0.01);
|
|
24
23
|
});
|
|
25
24
|
|
|
26
25
|
it("outputs 0.5 for an input value of 0", () => {
|