43 lines
1.6 KiB
JSON
43 lines
1.6 KiB
JSON
{
|
|
"source": "JSON",
|
|
"data": "BLOCK",
|
|
"version": "0.0.1",
|
|
"type": "javascript.addsound",
|
|
"language": "javascript",
|
|
"extension": "webaudio",
|
|
"help": "Add Sound",
|
|
"label": "Add Sound",
|
|
"color": "#D3C124",
|
|
"group": "Sound",
|
|
"codes": [
|
|
{
|
|
"name": "function",
|
|
"code": "\nMerger = function(context) {\n var that = this;\n this.x = 0; // Initial sample number\n this.context = context;\n this.node = context.createScriptProcessor(1024, 1, 1);\n this.node.onaudioprocess = function(e) { that.process(e) };\n}\n\nMerger.prototype.process = function(e) {\n var in0 = e.inputBuffer.getChannelData(0);\n var out = e.outputBuffer.getChannelData(0);\n for (var i = 0; i < in0.length; ++i) {\n out[i] = in0[i];\n }\n}\n"
|
|
},
|
|
{
|
|
"name": "declaration",
|
|
"code": "\n// block_$id$ = $label$\nvar block_$id$_obj = new Merger(context);\nvar $port[sound_input0]$ = block_$id$_obj.node;\nvar $port[sound_input1]$ = block_$id$_obj.node;\nvar $port[output]$ = block_$id$_obj.node;\n"
|
|
}
|
|
],
|
|
"properties": [],
|
|
"ports": [
|
|
{
|
|
"conn_type": "input",
|
|
"name": "sound_input0",
|
|
"label": "Sound",
|
|
"type": "javascript.sound"
|
|
},
|
|
{
|
|
"conn_type": "input",
|
|
"name": "sound_input1",
|
|
"label": "Input",
|
|
"type": "javascript.sound"
|
|
},
|
|
{
|
|
"conn_type": "output",
|
|
"name": "output",
|
|
"label": "Sound",
|
|
"type": "javascript.sound"
|
|
}
|
|
]
|
|
} |