Use the new note picker field in music and EV3 extensions (#1720)

* Add note field type

* Note picker in music extension plays notes

* Use note picker in EV3 beep block
This commit is contained in:
Eric Rosenbaum 2018-11-07 11:50:15 -05:00 committed by GitHub
parent eef1885fad
commit 2cff4159bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 4 deletions

View file

@ -910,6 +910,9 @@ class Scratch3Ev3Blocks {
// Create a new EV3 peripheral instance
this._peripheral = new EV3(this.runtime, Scratch3Ev3Blocks.EXTENSION_ID);
this._playNoteForPicker = this._playNoteForPicker.bind(this);
this.runtime.on('PLAY_NOTE', this._playNoteForPicker);
}
/**
@ -1089,7 +1092,7 @@ class Scratch3Ev3Blocks {
blockType: BlockType.COMMAND,
arguments: {
NOTE: {
type: ArgumentType.NUMBER,
type: ArgumentType.NOTE,
defaultValue: 60
},
TIME: {
@ -1212,6 +1215,14 @@ class Scratch3Ev3Blocks {
return this._peripheral.brightness;
}
_playNoteForPicker (note, category) {
if (category !== this.getInfo().name) return;
this.beep({
NOTE: note,
TIME: 0.25
});
}
beep (args) {
const note = MathUtil.clamp(Cast.toNumber(args.NOTE), 47, 99); // valid EV3 sounds
let time = Cast.toNumber(args.TIME) * 1000;