# Convert Triangle Wave to Sine Wave

I have this triangle wave as input:

and I want to derive a sine wave out of it. How do I go about it?

PS: I am doing this in Lua, so any piece of code close to that language would be appreciated.

• Could you take a drawing program and show us what kind of output you expect for this particular input? When the waveform abruptly goes back to zero, do you consider this as a rapid frequency increase - and thus, do you expect your sine wave to rapidly move through zero? Nov 1 '14 at 11:40
• I'm trying to make that wave smoother by transforming it to a sine wave. I'm expecting same zero-crossing points, same extreme level points but with the smooth of a sine wave. Any mathematical operation to do this? Nov 1 '14 at 13:07
• Yes, multiplying by pi and taking the sin will do the trick. Same extrema, same zero-crossings. Nov 1 '14 at 13:09
• y[x] = sin(pi * h[x]) ? where y[x] is the output at sample x and h[x] the input Nov 1 '14 at 13:15
• @pichenettes It's not working properly, as you can see in this input/output picture: hpics.li/9de5a96 Nov 1 '14 at 13:46

Assuming $x(t)$ swings between -1 and 1, $\sin \frac{\pi}{2} x(t)$ might do the trick.