Created
March 12, 2020 18:46
-
-
Save troy-lamerton/7b60a02dcebc663e872d5243e831504a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// white-noise-processor.js | |
class WhiteNoiseProcessor extends AudioWorkletProcessor { | |
process (inputs, outputs, parameters) { | |
const output = outputs[0] | |
output.forEach(channel => { | |
for (let i = 0; i < channel.length; i++) { | |
channel[i] = Math.random() * 2 - 1 | |
} | |
}) | |
return true | |
} | |
} | |
registerProcessor('white-noise-processor', WhiteNoiseProcessor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment