From 9cc1c316d65f697f23baab1a505f6a5880ce0f2a Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Wed, 11 Jan 2017 11:41:21 -0500 Subject: [PATCH] wrapclamp drum and instrument to num available --- src/blocks/scratch3_sound.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/blocks/scratch3_sound.js b/src/blocks/scratch3_sound.js index 20b4e27a0..87fbb0aaf 100644 --- a/src/blocks/scratch3_sound.js +++ b/src/blocks/scratch3_sound.js @@ -79,6 +79,7 @@ Scratch3SoundBlocks.prototype.playNoteForBeats = function (args, util) { Scratch3SoundBlocks.prototype.playDrumForBeats = function (args, util) { var drum = Cast.toNumber(args.DRUM); drum -= 1; // drums are one-indexed + drum = MathUtil.wrapClamp(drum, 0, this.runtime.audioEngine.numDrums); var beats = Cast.toNumber(args.BEATS); return util.target.audioPlayer.playDrumForBeats(drum, beats); }; @@ -91,6 +92,7 @@ Scratch3SoundBlocks.prototype.restForBeats = function (args, util) { 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); };