31 lines
1.3 KiB
JSON
31 lines
1.3 KiB
JSON
{
|
|
"source": "JSON",
|
|
"data": "BLOCK",
|
|
"version": "0.0.1",
|
|
"type": "javascript.whitenoise",
|
|
"language": "javascript",
|
|
"extension": "webaudio",
|
|
"help": "White Noise",
|
|
"label": "White Noise",
|
|
"color": "#D3C124",
|
|
"group": "Sound",
|
|
"codes": [
|
|
{
|
|
"name": "function",
|
|
"code": "\nWhiteNoise = function(context) {\n var that = this;\n this.x = 0; // Initial sample number\n this.context = context;\n this.node = context.createScriptProcessor(1024, 0, 2);\n this.node.onaudioprocess = function(e) { that.process(e) };\n}\n\nWhiteNoise.prototype.process = function(e) {\n var data_l = e.outputBuffer.getChannelData(0);\n var data_r = e.outputBuffer.getChannelData(1);\n for (var i = 0; i < data_l.length; ++i) {\n// data[i] = Math.sin(this.x++);\n data_l[i] = (Math.random() * 2) - 1;\n data_r[i] = (Math.random() * 2) - 1;\n }\n}\n"
|
|
},
|
|
{
|
|
"name": "declaration",
|
|
"code": "\n// block_$id$ = $label$\nvar block_$id$ = new WhiteNoise(context);\n$port[sound]$ = block_$id$.node;\n\n"
|
|
}
|
|
],
|
|
"properties": [],
|
|
"ports": [
|
|
{
|
|
"conn_type": "output",
|
|
"name": "sound",
|
|
"label": "Sound",
|
|
"type": "javascript.sound"
|
|
}
|
|
]
|
|
} |