Index: third_party/WebKit/LayoutTests/webaudio/audioworklet/processors.js |
diff --git a/third_party/WebKit/LayoutTests/webaudio/audioworklet/processors.js b/third_party/WebKit/LayoutTests/webaudio/audioworklet/processors.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..79128d3857b896b8ea9ed83613327b0ab924a957 |
--- /dev/null |
+++ b/third_party/WebKit/LayoutTests/webaudio/audioworklet/processors.js |
@@ -0,0 +1,58 @@ |
+'use strict' |
+ |
+registerProcessor('bypass', class Bypass extends AudioWorkletProcessor { |
+ constructor () { |
+ super(); |
+ } |
+ |
+ process (input, output) { |
+ let inputChannelData = input.getChannelData(0); |
+ let outputChannelData = output.getChannelData(0); |
+ outputChannelData.set(inputChannelData); |
+ } |
+}); |
+ |
+registerProcessor('noise', class Noise extends AudioWorkletProcessor { |
+ static get parameterDescriptors () { |
+ return [{ |
+ name: 'gain', |
+ defaultValue: 0.25, |
+ minValue: 0, |
+ maxValue: 1 |
+ }]; |
+ } |
+ |
+ constructor () { |
+ super(); |
+ } |
+ |
+ process (input, output, parameters) { |
+ let outputChannelData = output.getChannelData(0); |
+ let gain = parameters.gain; |
+ for (let i = 0; i < 128; ++i) { |
+ outputChannelData[i] = Math.random() * gain[i]; |
+ } |
+ } |
+}); |
+ |
+registerProcessor('onepole', class OnePole extends AudioWorkletProcessor { |
+ constructor () { |
+ super(); |
+ this.updateCoefficients_(5000); |
+ } |
+ |
+ updateCoefficients_ (cutoffFrequency) { |
+ this.b1 = Math.exp(-2 * Math.PI * cutoffFrequency / 48000); |
+ this.a0 = 1.0 - this.b1; |
+ this.z1 = 0; |
+ } |
+ |
+ process (input, output) { |
+ let inputChannelData = input.getChannelData(0); |
+ let outputChannelData = output.getChannelData(0); |
+ for (let i = 0; i < 128; ++i) { |
+ this.z1 = inputChannelData[i] * this.a0 + this.z1 * this.b1; |
+ outputChannelData[i] = this.z1; |
+ } |
+ } |
+}); |