From 5966a46bbd4f9008e2c99ae2d97ea900abb1437a Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Mon, 30 Jan 2017 10:54:24 -0500 Subject: [PATCH] target manages instrument setting --- src/blocks/scratch3_sound.js | 3 ++- src/sprites/rendered-target.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/blocks/scratch3_sound.js b/src/blocks/scratch3_sound.js index 4c1350ee..e47a688a 100644 --- a/src/blocks/scratch3_sound.js +++ b/src/blocks/scratch3_sound.js @@ -93,7 +93,8 @@ Scratch3SoundBlocks.prototype.setInstrument = function (args, util) { var instNum = Cast.toNumber(args.INSTRUMENT); instNum -= 1; // instruments are one-indexed instNum = MathUtil.wrapClamp(instNum, 0, this.runtime.audioEngine.numInstruments); - return util.target.audioPlayer.setInstrument(instNum); + util.target.setInstrument(instNum); + return this.runtime.audioEngine.instrumentPlayer.loadInstrument(instNum); }; Scratch3SoundBlocks.prototype.setEffect = function (args, util) { diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index e31616e4..714d11dc 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -484,6 +484,10 @@ RenderedTarget.prototype.updateAllDrawableProperties = function () { RenderedTarget.prototype.playSound = function (index) { return this.audioPlayer.playSound(this.sprite.sounds[index].md5); }; + +RenderedTarget.prototype.setInstrument = function (num) { + this.currentInstrument = num; +}; /** * Return the human-readable name for this rendered target, e.g., the sprite's name. * @override