mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 23:12:24 -05:00
wrapclamp drum and instrument to num available
This commit is contained in:
parent
5110360e3e
commit
9cc1c316d6
1 changed files with 2 additions and 0 deletions
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue