target manages instrument setting

This commit is contained in:
Eric Rosenbaum 2017-01-30 10:54:24 -05:00
parent 4e4b0b86e1
commit 5966a46bbd
2 changed files with 6 additions and 1 deletions

View file

@ -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) {

View file

@ -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