scratch-audio
Advanced tools
Comparing version 0.1.0-prerelease.20190108181031 to 0.1.0-prerelease.20190114210212
{ | ||
"name": "scratch-audio", | ||
"version": "0.1.0-prerelease.20190108181031", | ||
"version": "0.1.0-prerelease.20190114210212", | ||
"description": "audio engine for scratch 3.0", | ||
@@ -5,0 +5,0 @@ "main": "dist.js", |
@@ -159,3 +159,3 @@ const StartAudioContext = require('./StartAudioContext'); | ||
if (sound.data.length === 0) { | ||
return Promise.resolve(this.audioContext.createBuffer(1, 1, this.audioContext.sampleRate)); | ||
return this._emptySound(); | ||
} | ||
@@ -169,3 +169,4 @@ | ||
// Try decoding as adpcm | ||
return new ADPCMSoundDecoder(this.audioContext).decode(bufferCopy2); | ||
return new ADPCMSoundDecoder(this.audioContext).decode(bufferCopy2) | ||
.catch(() => this._emptySound()); | ||
}) | ||
@@ -183,2 +184,10 @@ .then( | ||
/** | ||
* An empty sound buffer, for use when we are unable to decode a sound file. | ||
* @returns {AudioBuffer} - an empty audio buffer. | ||
*/ | ||
_emptySound () { | ||
return this.audioContext.createBuffer(1, 1, this.audioContext.sampleRate); | ||
} | ||
/** | ||
* Decode a sound, decompressing it into audio samples. | ||
@@ -185,0 +194,0 @@ * |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
590235
4597