function playSound(){
let noise = context.createBufferSource()
noise.buffer = generateWhiteNoise()
const analyzer = context.createAnalyser()
analyzer.fftSize = 2048
let test = new Uint8Array(analyzer.frequencyBinCount)
noise.connect(analyzer)
analyzer.getByteFrequencyData(test)
console.log(test)
}
Currently im just trying to get the Analyzer node to work properly by testing it out with some whitenoise. The problem is that the test array is always 0 for every index. I cant figure out why.
function generateWhiteNoise() {
let bufferSize = context.sampleRate;
let buffer = context.createBuffer(1, bufferSize, context.sampleRate);
let output = buffer.getChannelData(0);
for (let i = 0; i < bufferSize; i++) {
output[i] = Math.random() * 2 - 1;
}
return buffer;
}
Here is my generateWhiteNoise() Function.