Merge pull request from ericrosenbaum/sound

Add new sound blocks
This commit is contained in:
Eric Rosenbaum 2017-01-06 16:17:56 -05:00 committed by GitHub
commit 6e6fb61aaa
4 changed files with 102 additions and 213 deletions

View file

@ -246,21 +246,19 @@ Blockly.Blocks.defaultToolbox = '<xml id="toolbox-categories" style="display: no
'<category name="Sound" colour="#D65CD6" secondaryColour="#BD42BD">'+
'<block type="sound_play">'+
'<value name="SOUND_MENU">'+
'<shadow type="sound_sounds_option"></shadow>'+
'<shadow type="sound_sounds_menu"></shadow>'+
'</value>'+
'</block>'+
'<block type="sound_playuntildone">'+
'<value name="SOUND_MENU">'+
'<shadow type="sound_sounds_option"></shadow>'+
'<shadow type="sound_sounds_menu"></shadow>'+
'</value>'+
'</block>'+
'<block type="sound_stopallsounds"></block>'+
'<block type="sound_playdrumforbeats">'+
'<value name="DRUMTYPE">'+
'<shadow type="math_number">'+
'<field name="NUM">1</field>'+
'</shadow>'+
'</value>'+
'<value name="DRUM">' +
'<shadow type="sound_drums_menu"></shadow>' +
'</value>' +
'<value name="BEATS">'+
'<shadow type="math_number">'+
'<field name="NUM">0.25</field>'+
@ -277,7 +275,7 @@ Blockly.Blocks.defaultToolbox = '<xml id="toolbox-categories" style="display: no
'<block type="sound_playnoteforbeats">'+
'<value name="NOTE">'+
'<shadow type="math_number">'+
'<field name="NUM">1</field>'+
'<field name="NUM">60</field>'+
'</shadow>'+
'</value>'+
'<value name="BEATS">'+
@ -287,11 +285,9 @@ Blockly.Blocks.defaultToolbox = '<xml id="toolbox-categories" style="display: no
'</value>'+
'</block>'+
'<block type="sound_setinstrumentto">'+
'<value name="INSTRUMENT">'+
'<shadow type="math_number">'+
'<field name="NUM">1</field>'+
'</shadow>'+
'</value>'+
'<value name="INSTRUMENT">' +
'<shadow type="sound_instruments_menu"></shadow>' +
'</value>' +
'</block>'+
'<block type="sound_seteffectto">' +
'<value name="EFFECT">' +
@ -299,7 +295,7 @@ Blockly.Blocks.defaultToolbox = '<xml id="toolbox-categories" style="display: no
'</value>' +
'<value name="VALUE">' +
'<shadow type="math_number">'+
'<field name="NUM">10</field>'+
'<field name="NUM">100</field>'+
'</shadow>'+
'</value>' +
'</block>' +

View file

@ -27,7 +27,7 @@ goog.require('Blockly.Colours');
goog.require('Blockly.constants');
Blockly.Blocks['sound_sounds_option'] = {
Blockly.Blocks['sound_sounds_menu'] = {
/**
* Sound effects drop-down menu.
* @this Blockly.Block
@ -41,13 +41,16 @@ Blockly.Blocks['sound_sounds_option'] = {
"type": "field_dropdown",
"name": "SOUND_MENU",
"options": [
['meow', '0'],
['boing', '1'],
['cave', '2'],
['drip drop', '3'],
['drum machine', '4'],
['eggs', '5'],
['zoop', '6']
['1', '0'],
['2', '1'],
['3', '2'],
['4', '3'],
['5', '4'],
['6', '5'],
['7', '6'],
['8', '7'],
['9', '8'],
['10', '9']
]
}
],
@ -110,35 +113,6 @@ Blockly.Blocks['sound_playuntildone'] = {
}
};
Blockly.Blocks['sound_playwithpitch'] = {
/**
* Block to play sound with pitch shift.
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"message0": "play sound %1 with pitch %2",
"args0": [
{
"type": "input_value",
"name": "SOUND_NUM"
},
{
"type": "input_value",
"name": "PITCH"
}
],
"inputsInline": true,
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.sound,
"colour": Blockly.Colours.sounds.primary,
"colourSecondary": Blockly.Colours.sounds.secondary,
"colourTertiary": Blockly.Colours.sounds.tertiary
});
}
};
Blockly.Blocks['sound_stopallsounds'] = {
/**
* Block to stop all sounds
@ -157,9 +131,9 @@ Blockly.Blocks['sound_stopallsounds'] = {
}
};
Blockly.Blocks['sound_beats_menu'] = {
Blockly.Blocks['sound_drums_menu'] = {
/**
* Sound beats drop-down menu.
* Drums drop-down menu.
* @this Blockly.Block
*/
init: function() {
@ -169,14 +143,26 @@ Blockly.Blocks['sound_beats_menu'] = {
"args0": [
{
"type": "field_dropdown",
"name": "BEATS",
"name": "DRUM",
"options": [
['1/8', '0.125'],
['1/4', '0.25'],
['1/2', '0.5'],
['1', '1'],
['2', '2'],
['4', '4']
['(1) Snare Drum', '1'],
['(2) Bass Drum', '2'],
['(3) Side Stick', '3'],
['(4) Crash Cymbal', '4'],
['(5) Open Hi-Hat', '5'],
['(6) Closed Hi-Hat', '6'],
['(7) Tambourine', '7'],
['(8) Hand Clap', '8'],
['(9) Claves', '9'],
['(10) Wood Block', '10'],
['(11) Cowbell', '11'],
['(12) Triangle', '12'],
['(13) Bongo', '13'],
['(14) Conga', '14'],
['(15) Cabasa', '15'],
['(16) Guiro', '16'],
['(17) Vibraslap', '17'],
['(18) Open Cuica', '18']
]
}
],
@ -190,33 +176,9 @@ Blockly.Blocks['sound_beats_menu'] = {
}
};
Blockly.Blocks['sound_playdrum'] = {
/**
* Block to play a certain drum
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"message0": "play drum %1",
"args0": [
{
"type": "input_value",
"name": "DRUMTYPE"
}
],
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.sounds.primary,
"colourSecondary": Blockly.Colours.sounds.secondary,
"colourTertiary": Blockly.Colours.sounds.tertiary
});
}
};
Blockly.Blocks['sound_playdrumforbeats'] = {
/**
* Block to play a certain drum for certain beats
* Block to play a drum for some number of beats
* @this Blockly.Block
*/
init: function() {
@ -225,7 +187,7 @@ Blockly.Blocks['sound_playdrumforbeats'] = {
"args0": [
{
"type": "input_value",
"name": "DRUMTYPE"
"name": "DRUM"
},
{
"type": "input_value",
@ -244,7 +206,7 @@ Blockly.Blocks['sound_playdrumforbeats'] = {
Blockly.Blocks['sound_restforbeats'] = {
/**
* Block to rest for certain beats
* Block to rest for some number of beats
* @this Blockly.Block
*/
init: function() {
@ -266,33 +228,9 @@ Blockly.Blocks['sound_restforbeats'] = {
}
};
Blockly.Blocks['sound_playnote'] = {
/**
* Block to play a certain note for certain beats
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"message0": "play note %1",
"args0": [
{
"type": "input_value",
"name": "NOTE"
}
],
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.sounds.primary,
"colourSecondary": Blockly.Colours.sounds.secondary,
"colourTertiary": Blockly.Colours.sounds.tertiary
});
}
};
Blockly.Blocks['sound_playnoteforbeats'] = {
/**
* Block to play a certain note for certain beats
* Block to play a certain note for some number of beats
* @this Blockly.Block
*/
init: function() {
@ -318,103 +256,6 @@ Blockly.Blocks['sound_playnoteforbeats'] = {
}
};
Blockly.Blocks['sound_scales_menu'] = {
/**
* Sound scales drop-down menu.
* @this Blockly.Block
*/
init: function() {
this.jsonInit(
{
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "SCALE",
"options": [
['major', 'MAJOR'],
['minor', 'MINOR'],
['pentatonic', 'PENTATONIC'],
['chromatic', 'CHROMATIC']
]
}
],
"inputsInline": true,
"output": "String",
"colour": Blockly.Colours.sounds.secondary,
"colourSecondary": Blockly.Colours.sounds.secondary,
"colourTertiary": Blockly.Colours.sounds.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
Blockly.Blocks['sound_roots_menu'] = {
/**
* Sound roots drop-down menu.
* @this Blockly.Block
*/
init: function() {
this.jsonInit(
{
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "ROOT",
"options": [
['C', '0'],
['C#', '1'],
['D', '2'],
['D#', '3'],
['E', '4'],
['F', '5'],
['F#', '6'],
['G', '7'],
['G#', '8'],
['A', '9'],
['A#', '10'],
['B', '11']
]
}
],
"inputsInline": true,
"output": "String",
"colour": Blockly.Colours.sounds.secondary,
"colourSecondary": Blockly.Colours.sounds.secondary,
"colourTertiary": Blockly.Colours.sounds.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
Blockly.Blocks['sound_setkey'] = {
/**
* Block to set the musical key and scale for the play note block
* @this Blockly.Block
*/
init: function() {
this.jsonInit({
"message0": "set key %1 %2",
"args0": [
{
"type": "input_value",
"name": "ROOT"
},
{
"type": "input_value",
"name": "SCALE"
}
],
"previousStatement": null,
"nextStatement": null,
"colour": Blockly.Colours.sounds.primary,
"colourSecondary": Blockly.Colours.sounds.secondary,
"colourTertiary": Blockly.Colours.sounds.tertiary
});
}
};
Blockly.Blocks['sound_effects_menu'] = {
/**
* Sound effects drop-down menu.
@ -429,10 +270,12 @@ Blockly.Blocks['sound_effects_menu'] = {
"type": "field_dropdown",
"name": "EFFECT",
"options": [
['echo', 'ECHO'],
['pitch', 'PITCH'],
['pan left/right', 'PAN'],
['echo', 'ECHO'],
['reverb', 'REVERB'],
['pitch', 'PITCH']
['fuzz', 'DISTORTION'],
['robot', 'ROBOTIC']
]
}
],
@ -518,9 +361,57 @@ Blockly.Blocks['sound_cleareffects'] = {
}
};
Blockly.Blocks['sound_instruments_menu'] = {
/**
* Instruments drop-down menu.
* @this Blockly.Block
*/
init: function() {
this.jsonInit(
{
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "INSTRUMENT",
"options": [
['(1) Piano', '1'],
['(2) Electric Piano', '2'],
['(3) Organ', '3'],
['(4) Guitar', '4'],
['(5) Electric Guitar', '5'],
['(6) Bass', '6'],
['(7) Pizzicato', '7'],
['(8) Cello', '8'],
['(9) Trombone', '9'],
['(10) Clarinet', '10'],
['(11) Saxophone', '11'],
['(12) Flute', '12'],
['(13) Wooden Flute', '13'],
['(14) Bassoon', '14'],
['(15) Choir', '15'],
['(16) Vibraphone', '16'],
['(17) Music Box', '17'],
['(18) Steel Drum', '18'],
['(19) Marimba', '19'],
['(20) Synth Lead', '20'],
['(21) Synth Pad', '21']
]
}
],
"inputsInline": true,
"output": "String",
"colour": Blockly.Colours.sounds.secondary,
"colourSecondary": Blockly.Colours.sounds.secondary,
"colourTertiary": Blockly.Colours.sounds.tertiary,
"outputShape": Blockly.OUTPUT_SHAPE_ROUND
});
}
};
Blockly.Blocks['sound_setinstrumentto'] = {
/**
* Block to set the sprite's instrument to a certain value
* Block to set the sprite's instrument
* @this Blockly.Block
*/
init: function() {

View file

@ -40,6 +40,7 @@ Blockly.Msg.CONTROLS_FOREACH_TOOLTIP = "For each item in a list, set the variabl
Blockly.Msg.CONTROLS_FOR_HELPURL = "https://github.com/google/blockly/wiki/Loops#count-with";
Blockly.Msg.CONTROLS_FOR_TITLE = "count with %1 from %2 to %3 by %4";
Blockly.Msg.CONTROLS_FOR_TOOLTIP = "Have the variable '%1' take on the values from the start number to the end number, counting by the specified interval, and do the specified blocks.";
Blockly.Msg.CONTROLS_IFELSE_TITLE = "if %1 do %2 else %3";
Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP = "Add a condition to the if block.";
Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP = "Add a final, catch-all condition to the if block.";
Blockly.Msg.CONTROLS_IF_HELPURL = "https://github.com/google/blockly/wiki/IfElse";

View file

@ -1,7 +1,7 @@
{
"@metadata": {
"author": "Ellen Spertus <ellen.spertus@gmail.com>",
"lastupdated": "2016-10-17 14:41:57.945422",
"lastupdated": "2017-01-02 12:17:41.695529",
"locale": "en",
"messagedocumentation" : "qqq"
},
@ -82,6 +82,7 @@
"CONTROLS_IF_IF_TOOLTIP": "Add, remove, or reorder sections to reconfigure this if block.",
"CONTROLS_IF_ELSEIF_TOOLTIP": "Add a condition to the if block.",
"CONTROLS_IF_ELSE_TOOLTIP": "Add a final, catch-all condition to the if block.",
"CONTROLS_IFELSE_TITLE": "if %1 do %2 else %3",
"LOGIC_COMPARE_HELPURL": "https://en.wikipedia.org/wiki/Inequality_(mathematics)",
"LOGIC_COMPARE_TOOLTIP_EQ": "Return true if both inputs equal each other.",
"LOGIC_COMPARE_TOOLTIP_NEQ": "Return true if both inputs are not equal to each other.",