Round the drum num arg

This commit is contained in:
Eric Rosenbaum 2017-11-14 14:35:26 -05:00
parent c26198d050
commit 14e2ca8d99

View file

@ -423,6 +423,7 @@ class Scratch3MusicBlocks {
playDrumForBeats (args, util) { playDrumForBeats (args, util) {
if (this._stackTimerNeedsInit(util)) { if (this._stackTimerNeedsInit(util)) {
let drum = Cast.toNumber(args.DRUM); let drum = Cast.toNumber(args.DRUM);
drum = Math.round(drum);
drum -= 1; // drums are one-indexed drum -= 1; // drums are one-indexed
if (typeof this.runtime.audioEngine === 'undefined') return; if (typeof this.runtime.audioEngine === 'undefined') return;
drum = MathUtil.wrapClamp(drum, 0, this.runtime.audioEngine.numDrums - 1); drum = MathUtil.wrapClamp(drum, 0, this.runtime.audioEngine.numDrums - 1);