Thanks to Fu-Kwun Hwang and lookang !!!
Triangular wave is here!!

the code is:

[quote]if(triangularWave)
{
  for(int i=0;i<n;i++){

cta=(x[i]+w*t)%pi2;

if (cta<(pi/2)) y[i]=2*cta/pi*A;
else y[i]=2*A*(1-(cta-pi)/pi)-A*2;
if (cta>pi) y[i]=2*A*(1-(cta-pi)/pi)-2*A;
if (cta>(3*pi/2)) y[i]=-2*A*(1-(cta-pi)/pi);

return y[i];
}[/quote]
;D