mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
Check for instrument sample before playing
This commit is contained in:
parent
421a92cad1
commit
773c167987
1 changed files with 4 additions and 0 deletions
|
@ -602,6 +602,10 @@ class Scratch3MusicBlocks {
|
||||||
const sampleArray = instrumentInfo.samples;
|
const sampleArray = instrumentInfo.samples;
|
||||||
const sampleIndex = this._selectSampleIndexForNote(note, sampleArray);
|
const sampleIndex = this._selectSampleIndexForNote(note, sampleArray);
|
||||||
|
|
||||||
|
// If the audio sample has not loaded yet, bail out
|
||||||
|
if (typeof this._instrumentBufferArrays[inst] === 'undefined') return;
|
||||||
|
if (typeof this._instrumentBufferArrays[inst][sampleIndex] === 'undefined') return;
|
||||||
|
|
||||||
// Create the audio buffer to play the note, and set its pitch
|
// Create the audio buffer to play the note, and set its pitch
|
||||||
const context = util.runtime.audioEngine.audioContext;
|
const context = util.runtime.audioEngine.audioContext;
|
||||||
const bufferSource = context.createBufferSource();
|
const bufferSource = context.createBufferSource();
|
||||||
|
|
Loading…
Reference in a new issue