mosaicode-javascript-webaudio/blocks/sound/addsound.json

37 lines
1.5 KiB
JSON

{
"source": "JSON",
"data": "BLOCK",
"version": "0.0.1",
"type": "addsound",
"language": "javascript",
"extension": "webaudio",
"help": "Add Sound",
"label": "Add Sound",
"color": "50:150:250:150",
"group": "Sound",
"codes": {
"function": "\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",
"declaration": "\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": [
{
"type": "mosaicode_lib_javascript_webaudio.extensions.ports.sound",
"name": "sound_input0",
"conn_type": "Input",
"label": "Sound"
},
{
"type": "mosaicode_lib_javascript_webaudio.extensions.ports.sound",
"name": "sound_input1",
"conn_type": "Input",
"label": "Input"
},
{
"type": "mosaicode_lib_javascript_webaudio.extensions.ports.sound",
"label": "Sound",
"conn_type": "Output",
"name": "output"
}
]
}