tone 15.5.61 → 15.5.62
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/core/context/ToneAudioBuffer.test.ts +23 -0
- package/Tone/core/context/ToneAudioBuffer.ts +4 -1
- package/Tone/instrument/Sampler.test.ts +19 -0
- package/Tone/version.ts +1 -1
- package/build/Tone.js +1 -1
- package/build/Tone.js.map +1 -1
- package/build/esm/core/context/ToneAudioBuffer.js +4 -1
- package/build/esm/core/context/ToneAudioBuffer.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
|
@@ -103,6 +103,29 @@ describe("ToneAudioBuffer", () => {
|
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
+
it("preserves the onload of an unloaded buffer it wraps", async () => {
|
|
107
|
+
let originalCalled = false;
|
|
108
|
+
const inner = new ToneAudioBuffer({
|
|
109
|
+
onload(): void {
|
|
110
|
+
originalCalled = true;
|
|
111
|
+
},
|
|
112
|
+
url: testFile,
|
|
113
|
+
});
|
|
114
|
+
let outerCalled = false;
|
|
115
|
+
const outer = new ToneAudioBuffer({
|
|
116
|
+
onload(): void {
|
|
117
|
+
outerCalled = true;
|
|
118
|
+
},
|
|
119
|
+
url: inner,
|
|
120
|
+
});
|
|
121
|
+
await ToneAudioBuffer.loaded();
|
|
122
|
+
expect(originalCalled).to.equal(true);
|
|
123
|
+
expect(outerCalled).to.equal(true);
|
|
124
|
+
expect(outer.get()).to.equal(inner.get());
|
|
125
|
+
inner.dispose();
|
|
126
|
+
outer.dispose();
|
|
127
|
+
});
|
|
128
|
+
|
|
106
129
|
it("takes Tone.ToneAudioBuffer in the set method", (done) => {
|
|
107
130
|
const buffer = new ToneAudioBuffer({
|
|
108
131
|
url: testFile,
|
|
@@ -99,8 +99,11 @@ export class ToneAudioBuffer extends Tone {
|
|
|
99
99
|
if (buffer.loaded) {
|
|
100
100
|
this._buffer = buffer.get();
|
|
101
101
|
} else {
|
|
102
|
-
//
|
|
102
|
+
// Chain so a wrapper does not replace the buffer's own onload.
|
|
103
|
+
// An early note constructs that wrapper before the fetch finishes.
|
|
104
|
+
const previousOnload = buffer.onload;
|
|
103
105
|
buffer.onload = () => {
|
|
106
|
+
previousOnload.call(buffer, buffer);
|
|
104
107
|
this.set(buffer);
|
|
105
108
|
this.onload(this);
|
|
106
109
|
};
|
|
@@ -160,6 +160,25 @@ describe("Sampler", () => {
|
|
|
160
160
|
);
|
|
161
161
|
});
|
|
162
162
|
|
|
163
|
+
it("invokes onload when triggerAttack runs before the buffer loads", async () => {
|
|
164
|
+
let loaded = false;
|
|
165
|
+
const sampler = new Sampler({
|
|
166
|
+
onload(): void {
|
|
167
|
+
loaded = true;
|
|
168
|
+
},
|
|
169
|
+
urls: {
|
|
170
|
+
A4: "./test/audio/sine.wav",
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
expect(() => {
|
|
174
|
+
sampler.triggerAttack("A4");
|
|
175
|
+
}).throws(Error, /not loaded/);
|
|
176
|
+
await ToneAudioBuffer.loaded();
|
|
177
|
+
expect(loaded).to.be.true;
|
|
178
|
+
expect(sampler.loaded).to.be.true;
|
|
179
|
+
sampler.dispose();
|
|
180
|
+
});
|
|
181
|
+
|
|
163
182
|
it("can pass in a callback and baseUrl", (done) => {
|
|
164
183
|
const sampler = new Sampler(
|
|
165
184
|
{
|
package/Tone/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version: string = "15.5.
|
|
1
|
+
export const version: string = "15.5.62";
|