Uncaught RangeError: Maximum call stack size exceeded
function updateAnalysers(id) {
var canvas = document.getElementById(id);
canvasWidth = canvas.width;
canvasHeight = canvas.height;
analyserContext = canvas.getContext('2d');
{
var fils = Math.round(canvasWidth / 3);
var byts = new Uint8Array(analyserNode.frequencyBinCount);
analyserNode.getByteFrequencyData(byts);
analyserContext.clearRect(0, 0, canvasWidth, canvasHeight);
analyserContext.fillStyle = 'GRAY';
analyserContext.lineCap = 'round';
var multiplier = analyserNode.frequencyBinCount / fils;
for (var i = 0; i < fils; ++i) {
var magnitude = 0;
var offset = Math.floor( i * multiplier );
for (var j = 0; j< multiplier; j++)
magnitude += byts[offset + j];
magnitude = (magnitude / multiplier) + 2;
analyserContext.fillRect(i * 3, canvasHeight, 1, -magnitude);
}
}
rafID = window.requestAnimationFrame( updateAnalysers("analyser") );
}
O erro ocorre nesta última linha:
rafID = window.requestAnimationFrame( updateAnalysers("analyser") );
Como corrigilo?
rafID = window.requestAnimationFrame( updateAnalysers );
funciona que é uma beleza