38 lines
1.3 KiB
JSON
38 lines
1.3 KiB
JSON
{
|
|
"source": "JSON",
|
|
"data": "BLOCK",
|
|
"version": "0.0.1",
|
|
"type": "distortion",
|
|
"language": "javascript",
|
|
"extension": "webaudio",
|
|
"help": "Distortion",
|
|
"label": "Distortion",
|
|
"color": "50:150:250:150",
|
|
"group": "Sound",
|
|
"codes": {
|
|
"declaration": "\nvar block_$id$ = context.createWaveShaper();\nblock_$id$.curve = makeDistortionCurve($prop[curve]$);\nblock_$id$.oversample = '4x';\nvar $port[input]$ = block_$id$;\nvar $port[output]$ = block_$id$;\n",
|
|
"function": "\nfunction makeDistortionCurve(amount) {\n var k = typeof amount === 'number' ? amount : 50,\n n_samples = 44100,\n curve = new Float32Array(n_samples),\n deg = Math.PI / 180,\n i = 0,\n x;\n for ( ; i < n_samples; ++i ) {\n x = i * 2 / n_samples - 1;\n curve[i] = ( 3 + k ) * x * 20 * deg / ( Math.PI + k * Math.abs(x) );\n }\n return curve;\n};\n"
|
|
},
|
|
"properties": [
|
|
{
|
|
"name": "curve",
|
|
"label": "Curve",
|
|
"type": "Float",
|
|
"value": 800
|
|
}
|
|
],
|
|
"ports": [
|
|
{
|
|
"type": "mosaicode_lib_javascript_webaudio.extensions.ports.sound",
|
|
"label": "Input",
|
|
"conn_type": "Input",
|
|
"name": "input"
|
|
},
|
|
{
|
|
"type": "mosaicode_lib_javascript_webaudio.extensions.ports.sound",
|
|
"label": "Output",
|
|
"conn_type": "Output",
|
|
"name": "output"
|
|
}
|
|
]
|
|
} |