I have the following which draws the frequency of an audio clip as soundbars:
const drawSinewave = function() {
requestAnimationFrame(drawSinewave);
analyser.getByteFrequencyData(sinewaveDataArray);
canvasCtx.fillStyle = 'white';
canvasCtx.fillRect(0, 0, canvas.width, canvas.height);
canvasCtx.lineWidth = 2;
canvasCtx.strokeStyle = "#40a9ff";
canvasCtx.beginPath();
const sliceWidth = canvas.width * 1.0 / analyser.fftSize;
let x = 0;
var barWidth = (canvas.width / analyser.fftSize) * 2.5;
var barHeight;
for(let i = 0; i < analyser.fftSize; i++) {
barHeight = sinewaveDataArray[i];
canvasCtx.fillStyle = 'rgb(' + (barHeight+100) + ',50,50)';
canvasCtx.fillRect(x,canvas.height-barHeight/2,barWidth,barHeight);
x += barWidth + 1;
}
canvasCtx.lineTo(canvas.width, canvas.height / 2);
canvasCtx.stroke();
};
However I would like to draw that around a circle, so like the bars come out like rays from a circle border. I have failed to figure this out. Could someone assist me?