# Creating 2D waveform for Cocos2d game

I'd like to have a Waveform in my iPhone game that I am developing using Cocos2d v2.0.

That's the ideal wave I'd like to achieve. A simpler wave which I would still be happy with is this one.

Some people suggested me to use ParticleEffects ands ParticleDesigners like 71squared but I am not sure that this is the right approach.

Brainstorming, I think that at the end a wave is a plot of some function, and at each frame translate the wave points that where from the origin apart (-x and +x) and computes new wave points for the origin.

Something like this:

for (duration of effect)
compute wave point intensity at origin and display it
and
for each wave point before the center translate to -x and display it
and after the center translate to +x and display it


Let me know what you think and if you have any better solution. I was thinking to achieve the display point by colouring a particular pixel but I need to figure out how :)..

One way would be to read as binary and parse from that.

for example: (Assuming you have a 8Bit wav file)

//Get your file
for each 8 bit chunk convert to unsigned Integer

//Generate image
for each Integer scale it down to half your image size
draw pixel wide line from center to top from scaled result.
Draw a mirror image of that line directly below.
X coord + 1