mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Clamp range for “play note” input
Clamp to 36-96, which is C2-C7. This is a temporary fix to prevent errors, until we have a new instrument player implementation, which may have a different range.
This commit is contained in:
parent
b03768cad6
commit
1ba7ad0218
1 changed files with 7 additions and 0 deletions
|
@ -33,6 +33,12 @@ Scratch3SoundBlocks.DEFAULT_SOUND_STATE = {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The minimum and maximum MIDI note numbers, for clamping the input to play note.
|
||||
* @type {{min: number, max: number}}
|
||||
*/
|
||||
Scratch3SoundBlocks.MIDI_NOTE_RANGE = {min: 36, max: 96}; // C2 to C7
|
||||
|
||||
/**
|
||||
* @param {Target} target - collect sound state for this target.
|
||||
* @returns {SoundState} the mutable sound state associated with that target. This will be created if necessary.
|
||||
|
@ -132,6 +138,7 @@ Scratch3SoundBlocks.prototype.stopAllSounds = function (args, util) {
|
|||
|
||||
Scratch3SoundBlocks.prototype.playNoteForBeats = function (args, util) {
|
||||
var note = Cast.toNumber(args.NOTE);
|
||||
note = MathUtil.clamp(note, Scratch3SoundBlocks.MIDI_NOTE_RANGE.min, Scratch3SoundBlocks.MIDI_NOTE_RANGE.max);
|
||||
var beats = Cast.toNumber(args.BEATS);
|
||||
var soundState = this._getSoundState(util.target);
|
||||
var inst = soundState.currentInstrument;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue