I am having trouble finding out how to form a triangle (not sawtooth) wave from a sine wave.
I understand how to create it for a Square wave:
if( sineValue >= 0 )
value = amp;
else
value = -amp;
But I am not sure how to change this to accommodate for a triangle wave.
A triangle wave is the integral of a square wave. So you need to integrate (sum) your square wave over time:
Note that this can be written more succinctly as: