123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- /**
- * @license Licensed under the Apache License, Version 2.0 (the "License"):
- * http://www.apache.org/licenses/LICENSE-2.0
- */
- /**
- * @fileoverview Ardublockly JavaScript for the Blockly resources and bindings.
- */
- 'use strict';
- goog.provide('Blockly.Blocks.music');
- goog.require('Blockly.Blocks');
- // goog.require('Blockly.Types');
- Blockly.Blocks.music.HUE = 340;
- Blockly.Blocks['MusicMidiSetup'] = {
- init: function() {
- this.appendDummyInput()
- .appendField(new Blockly.FieldImage("./../blockly/media/main-music.png", 50, 40, "15"));
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_INSTRUMENT)
- .appendField(new Blockly.FieldDropdown([
- [Blockly.Msg.MUSIC_INSTRUMENT_GPIANO, "1"],
- [Blockly.Msg.MUSIC_INSTRUMENT_EPIANO, "5"],
- [Blockly.Msg.MUSIC_INSTRUMENT_MUSICBOX, "11"],
- [Blockly.Msg.MUSIC_INSTRUMENT_XYLOPHONE, "14"],
- [Blockly.Msg.MUSIC_INSTRUMENT_DRAWBARORGAN, "17"],
- [Blockly.Msg.MUSIC_INSTRUMENT_ACCORION, "22"],
- [Blockly.Msg.MUSIC_INSTRUMENT_GUITAR, "25"],
- [Blockly.Msg.MUSIC_INSTRUMENT_EGUITAR, "28"],
- [Blockly.Msg.MUSIC_INSTRUMENT_BASS, "33"],
- [Blockly.Msg.MUSIC_INSTRUMENT_VIOLIN, "41"],
- [Blockly.Msg.MUSIC_INSTRUMENT_VIOLA, "42"],
- [Blockly.Msg.MUSIC_INSTRUMENT_CELLO, "43"],
- [Blockly.Msg.MUSIC_INSTRUMENT_TRUMPET, "57"],
- [Blockly.Msg.MUSIC_INSTRUMENT_SAX, "67"],
- [Blockly.Msg.MUSIC_INSTRUMENT_PICCOLO, "73"],
- [Blockly.Msg.MUSIC_INSTRUMENT_FLUTE, "74"],
- [Blockly.Msg.MUSIC_INSTRUMENT_WHISTLE, "79"],
- [Blockly.Msg.MUSIC_INSTRUMENT_SITAR, "105"],
- [Blockly.Msg.MUSIC_INSTRUMENT_WOODBLOCK, "116"],
- [Blockly.Msg.MUSIC_INSTRUMENT_DRUM, "117"]
- ]), "INSTRUMENT");
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_VOLUME)
- .appendField(new Blockly.FieldDropdown([
- [Blockly.Msg.MUSIC_VOL_MIN, "120"],
- ["1", "100"],
- ["2", "80"],
- ["3", "60"],
- ["4", "40"],
- ["5", "20"],
- [Blockly.Msg.MUSIC_VOL_MAX, "0"]
- ]), "VOLUME");
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['MusicSetVolume'] = {
- init: function() {
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_VOLUME)
- .appendField(new Blockly.FieldDropdown([
- [Blockly.Msg.MUSIC_VOL_MIN, "120"],
- ["1", "100"],
- ["2", "80"],
- ["3", "60"],
- ["4", "40"],
- ["5", "20"],
- [Blockly.Msg.MUSIC_VOL_MAX, "0"]
- ]), "VOLUME");
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip(Blockly.Msg.MUSIC_PLAY_NOTE_TOOLTIP);
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['MusicSetInstrument'] = {
- init: function() {
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_INSTRUMENT)
- .appendField(new Blockly.FieldDropdown([
- [Blockly.Msg.MUSIC_INSTRUMENT_GPIANO, "1"],
- [Blockly.Msg.MUSIC_INSTRUMENT_EPIANO, "5"],
- [Blockly.Msg.MUSIC_INSTRUMENT_MUSICBOX, "11"],
- [Blockly.Msg.MUSIC_INSTRUMENT_XYLOPHONE, "14"],
- [Blockly.Msg.MUSIC_INSTRUMENT_DRAWBARORGAN, "17"],
- [Blockly.Msg.MUSIC_INSTRUMENT_ACCORION, "22"],
- [Blockly.Msg.MUSIC_INSTRUMENT_GUITAR, "25"],
- [Blockly.Msg.MUSIC_INSTRUMENT_EGUITAR, "28"],
- [Blockly.Msg.MUSIC_INSTRUMENT_BASS, "33"],
- [Blockly.Msg.MUSIC_INSTRUMENT_VIOLIN, "41"],
- [Blockly.Msg.MUSIC_INSTRUMENT_VIOLA, "42"],
- [Blockly.Msg.MUSIC_INSTRUMENT_CELLO, "43"],
- [Blockly.Msg.MUSIC_INSTRUMENT_TRUMPET, "57"],
- [Blockly.Msg.MUSIC_INSTRUMENT_SAX, "67"],
- [Blockly.Msg.MUSIC_INSTRUMENT_PICCOLO, "73"],
- [Blockly.Msg.MUSIC_INSTRUMENT_FLUTE, "74"],
- [Blockly.Msg.MUSIC_INSTRUMENT_WHISTLE, "79"],
- [Blockly.Msg.MUSIC_INSTRUMENT_SITAR, "105"],
- [Blockly.Msg.MUSIC_INSTRUMENT_WOODBLOCK, "116"],
- [Blockly.Msg.MUSIC_INSTRUMENT_DRUM, "117"]
- ]), "INSTRUMENT");
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip(Blockly.Msg.MUSIC_PLAY_NOTE_TOOLTIP);
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['MusicNote'] = {
- init: function() {
- this.appendDummyInput()
- .appendField("♪")
- .appendField(Blockly.Msg.MUSIC_NOTE)
- .appendField(new Blockly.FieldNumber(60, 0, 100), "NOTE");
- this.setOutput(true, Blockly.Types.NUMBER.output);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("http://cocorobo.cn/cocoblockly/dev/reference/notes.jpg");
- },
- getBlockType: function() {
- return Blockly.Types.NUMBER;
- }
- };
- Blockly.Blocks['MusicBeat'] = {
- init: function() {
- this.appendDummyInput()
- .appendField("♪")
- .appendField(new Blockly.FieldDropdown([
- ["1", "1000"],
- ["1/2", "500"],
- ["1/4", "250"],
- ["1/8", "125"],
- ["2", "2000"],
- ["4", "4000"],
- ]), "BEAT")
- .appendField(Blockly.Msg.MUSIC_BEAT);
- this.setOutput(true, "Number");
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- Blockly.Blocks['MusicPlayTone'] = {
- init: function() {
- this.appendValueInput("NOTE")
- .appendField("♩ " + Blockly.Msg.MUSIC_PLAY_NOTE);
- this.appendValueInput("DURATION")
- .appendField(Blockly.Msg.MUSIC_DURATION);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setInputsInline(true);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip(Blockly.Msg.MUSIC_PLAY_NOTE_TOOLTIP);
- this.setHelpUrl("http://cocorobo.cn/cocoblockly/dev/reference/notes.jpg");
- }
- };
- Blockly.Blocks['MusicRest'] = {
- init: function() {
- this.appendValueInput("BEAT")
- .appendField("♩ " + Blockly.Msg.MUSIC_REST);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setInputsInline(true);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- /*
- *MP3 player Setup
- */
- Blockly.Blocks['Music_mp3_setup'] = {
- init: function() {
- this.appendDummyInput()
- .appendField(new Blockly.FieldImage("./../blockly/media/main-music.png", 50, 40, "15"));
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_MP3_SETUP);
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_MP3_SETUP_SETVOLUME)
- .appendField(new Blockly.FieldDropdown([
- [Blockly.Msg.MUSIC_MP3_SETUP_SETVOLUME_LOW, "90"],
- [Blockly.Msg.MUSIC_MP3_SETUP_SETVOLUME_MID, "50"],
- [Blockly.Msg.MUSIC_MP3_SETUP_SETVOLUME_HIGH, "10"]
- ]), "SETVOL")
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- /*
- *MP3 player
- * play one music
- */
- Blockly.Blocks['Music_mp3_playOneWithName'] = {
- init: function() {
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_MP3_PLAYONE)
- .appendField(new Blockly.FieldTextInput("record.mp3"), "MUSIC_NAME")
- // .appendField(new Blockly.FieldDropdown([
- // [Blockly.Msg.MUSIC_MP3_PLAYONE_NORMAL, "PM_NORMAL_PLAY"],
- // [Blockly.Msg.MUSIC_MP3_PLAYONE_REPEAT, "PM_REPEAT_ONE"]
- // ]), "TYPE")
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- }
- };
- /*
- *MP3 player
- * play all Music
- */
- Blockly.Blocks['Music_mp3_playAllMusic'] = {
- init: function() {
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_MP3_PLAYALL)
- // .appendField(new Blockly.FieldDropdown([
- // [Blockly.Msg.MUSIC_MP3_PLAY_NORMAL, "PM_NORMAL_PLAY"],
- // [Blockly.Msg.MUSIC_MP3_PLAY_REPEAT, "PM_REPEAT_LIST"]
- // ]), "TYPE")
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- },
- };
- /**
- *MP3 player
- * Player Setting
- * {pause, resume, nextSong, preSong, volUp, volDown, playAll}
- */
- Blockly.Blocks['Music_mp3_playSetting'] = {
- init: function() {
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_MP3_PLAYSETTING)
- .appendField(new Blockly.FieldDropdown([
- [Blockly.Msg.MUSIC_MP3_PLAYSETTING_RESUME, "0"],
- [Blockly.Msg.MUSIC_MP3_PLAYSETTING_PAUSE, "1"],
- [Blockly.Msg.MUSIC_MP3_PLAYSETTING_PRESONG, "2"],
- [Blockly.Msg.MUSIC_MP3_PLAYSETTING_NEXTSONG, "3"],
- [Blockly.Msg.MUSIC_MP3_PLAYSETTING_VOLUP, "4"],
- [Blockly.Msg.MUSIC_MP3_PLAYSETTING_VOLDOWN, "5"],
- [Blockly.Msg.MUSIC_MP3_PLAYSETTING_PLAYALL, "6"],
- ]), "SETTING")
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- },
- };
- /**
- * MP3 player
- * get current volume
- */
- Blockly.Blocks['Music_mp3_getCurrentVolume'] = {
- init: function() {
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_MP3_CURRENTVOLUME)
- this.setOutput(true, Blockly.Types.NUMBER.output);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- },
- getBlockType: function() {
- return Blockly.Types.NUMBER;
- }
- }
- /**
- * MP3 player
- * set volume to
- */
- Blockly.Blocks['Music_mp3_setCurrentVolume'] = {
- init: function() {
- this.appendDummyInput()
- .appendField(Blockly.Msg.MUSIC_MP3_SETVOLUME)
- .appendField(new Blockly.FieldDropdown([
- ["0","0"],
- ["1","1"],
- ["2","2"],
- ["3","3"],
- ["4","4"],
- ["5","5"],
- ["6","6"],
- ["7","7"],
- ["8","8"],
- ["9","9"],
- ["10","10"]
- ]),"VOLLEVEL")
- this.setInputsInline(true);
- this.setPreviousStatement(true, null);
- this.setNextStatement(true, null);
- this.setColour(Blockly.Blocks.music.HUE);
- this.setTooltip("");
- this.setHelpUrl("");
- },
- }
|