Skip to content

Instantly share code, notes, and snippets.

@troy-lamerton
Created March 12, 2020 18:46
Show Gist options
  • Save troy-lamerton/7b60a02dcebc663e872d5243e831504a to your computer and use it in GitHub Desktop.
Save troy-lamerton/7b60a02dcebc663e872d5243e831504a to your computer and use it in GitHub Desktop.
// 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