OLD | NEW |
(Empty) | |
| 1 'use strict' |
| 2 |
| 3 registerProcessor('bypass', class Bypass extends AudioWorkletProcessor { |
| 4 constructor () { |
| 5 super(); |
| 6 } |
| 7 |
| 8 process (input, output) { |
| 9 let inputChannelData = input.getChannelData(0); |
| 10 let outputChannelData = output.getChannelData(0); |
| 11 outputChannelData.set(inputChannelData); |
| 12 } |
| 13 }); |
| 14 |
| 15 registerProcessor('noise', class Noise extends AudioWorkletProcessor { |
| 16 static get parameterDescriptors () { |
| 17 return [{ |
| 18 name: 'gain', |
| 19 defaultValue: 0.25, |
| 20 minValue: 0, |
| 21 maxValue: 1 |
| 22 }]; |
| 23 } |
| 24 |
| 25 constructor () { |
| 26 super(); |
| 27 } |
| 28 |
| 29 process (input, output) { |
| 30 let inputChannelData = input.getChannelData(0); |
| 31 let outputChannelData = output.getChannelData(0); |
| 32 for (let i = 0; i < 128; ++i) { |
| 33 outputChannelData[i] = |
| 34 (inputChannelData[i] * 0.05) + (Math.random() * 0.95); |
| 35 } |
| 36 } |
| 37 }); |
| 38 |
| 39 registerProcessor('onepole', class OnePole extends AudioWorkletProcessor { |
| 40 constructor () { |
| 41 super(); |
| 42 let cutoffFrequency = 500; |
| 43 this.b1 = Math.exp(-2 * Math.PI * cutoffFrequency / 48000); |
| 44 this.a0 = 1.0 - this.b1; |
| 45 this.z1 = 0; |
| 46 } |
| 47 |
| 48 process (input, output) { |
| 49 let inputChannelData = input.getChannelData(0); |
| 50 let outputChannelData = output.getChannelData(0); |
| 51 for (let i = 0; i < 128; ++i) { |
| 52 this.z1 = inputChannelData[i] * this.a0 + this.z1 * this.b1; |
| 53 outputChannelData[i] = this.z1; |
| 54 } |
| 55 } |
| 56 }); |
OLD | NEW |