What I am getting

What I want

I am trying to create a music music visualization app and I am stuck on the circular wave pattern
//draw the waveform to the screen
function CircularWavePattern() {
//vis name
this.name = "circularWavePattern";
//draw the wave form to the screen
this.draw = function() {
push();
noFill();
stroke(255, 0, 0);
strokeWeight(2);
beginShape();
//calculate the waveform from the fft.
var wave = fourier.waveform();
for (var i = 0; i < wave.length; i++) {
//for each element of the waveform map it to screen
//coordinates and make a new vertex at the point.
var x = map(i, 0, wave.length, 0, width) * cos(i);
var y = map(wave[i], -1, 1, 0, height) * sin(i);
vertex(x, y);
}
endShape();
pop();
};
}