@hkdigital/lib-sveltekit 0.1.55 → 0.1.56
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.
@@ -81,9 +81,6 @@ export default class AudioScene {
|
|
81
81
|
|
82
82
|
/**
|
83
83
|
* Construct AudioScene
|
84
|
-
*
|
85
|
-
* @param {object} _
|
86
|
-
* @param {AudioContext} _.audioContext
|
87
84
|
*/
|
88
85
|
constructor() {
|
89
86
|
const state = this.#state;
|
@@ -175,9 +172,13 @@ export default class AudioScene {
|
|
175
172
|
*
|
176
173
|
* @param {AudioContext} audioContext
|
177
174
|
*/
|
178
|
-
load(audioContext) {
|
179
|
-
|
180
|
-
|
175
|
+
load( audioContext ) {
|
176
|
+
|
177
|
+
if( audioContext && !this.#audioContext )
|
178
|
+
{
|
179
|
+
this.#audioContext = audioContext;
|
180
|
+
}
|
181
|
+
|
181
182
|
this.#state.send(LOAD);
|
182
183
|
|
183
184
|
// FIXME: in unit test when moved to startloading it hangs!
|
@@ -187,6 +188,8 @@ export default class AudioScene {
|
|
187
188
|
}
|
188
189
|
}
|
189
190
|
|
191
|
+
// setAudioContext
|
192
|
+
|
190
193
|
async #startLoading() {
|
191
194
|
console.log('#startLoading');
|
192
195
|
|
@@ -212,12 +215,11 @@ export default class AudioScene {
|
|
212
215
|
}
|
213
216
|
|
214
217
|
const sourceNode = await audioLoader.getAudioBufferSourceNode(
|
215
|
-
|
216
|
-
this.#audioContext
|
218
|
+
this.#getAudioContext()
|
217
219
|
);
|
218
220
|
|
219
221
|
// @ts-ignore
|
220
|
-
sourceNode.connect(this.#
|
222
|
+
sourceNode.connect(this.#getAudioContext().destination);
|
221
223
|
|
222
224
|
// Clean up
|
223
225
|
sourceNode.onended = () => {
|
@@ -228,6 +230,16 @@ export default class AudioScene {
|
|
228
230
|
return sourceNode;
|
229
231
|
}
|
230
232
|
|
233
|
+
#getAudioContext()
|
234
|
+
{
|
235
|
+
if( !this.#audioContext )
|
236
|
+
{
|
237
|
+
this.#audioContext = new AudioContext();
|
238
|
+
}
|
239
|
+
|
240
|
+
return this.#audioContext;
|
241
|
+
}
|
242
|
+
|
231
243
|
/**
|
232
244
|
* Get memory source
|
233
245
|
*
|