mirror of
https://github.com/scratchfoundation/scratch-audio.git
synced 2025-01-03 11:35:49 -05:00
Make a copy before using audio buffer
This commit is contained in:
parent
19e1136e3b
commit
5c4a88b739
1 changed files with 5 additions and 2 deletions
|
@ -232,12 +232,15 @@ class AudioEngine {
|
||||||
|
|
||||||
let loaderPromise = null;
|
let loaderPromise = null;
|
||||||
|
|
||||||
|
// Make a copy of the buffer because decoding detaches the original buffer
|
||||||
|
var bufferCopy = sound.data.buffer.slice(0);
|
||||||
|
|
||||||
switch (sound.format) {
|
switch (sound.format) {
|
||||||
case '':
|
case '':
|
||||||
loaderPromise = Tone.context.decodeAudioData(sound.data.buffer);
|
loaderPromise = Tone.context.decodeAudioData(bufferCopy);
|
||||||
break;
|
break;
|
||||||
case 'adpcm':
|
case 'adpcm':
|
||||||
loaderPromise = (new ADPCMSoundDecoder()).decode(sound.data.buffer);
|
loaderPromise = (new ADPCMSoundDecoder()).decode(bufferCopy);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return log.warn('unknown sound format', sound.format);
|
return log.warn('unknown sound format', sound.format);
|
||||||
|
|
Loading…
Reference in a new issue