home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / SoundAndMusic / cmix / lpc / synthesis / shift.c < prev   
C/C++ Source or Header  |  1991-12-11  |  617b  |  22 lines

  1. #include <math.h>
  2. double shift(thetao,phio,sr)
  3. float thetao,phio,sr;
  4. {
  5. #define  ABS(x) ((x < 0) ? (-x) : (x))
  6.       float a,b,c,d1,d2,x,dval,theta,phi;
  7.       float pi=3.1415927;
  8.       theta=thetao*pi/(sr/2.);
  9.       phi=phio*pi/(sr/2.);
  10.       a=cos(theta)*tan(phi)+sin(theta);
  11.       b=2.*tan(phi);
  12.       c=cos(theta)*tan(phi)-sin(theta);
  13. //    d1=(-b+sqrt(b**2-4.*a*c))/(2.*a)
  14. //    d2=(-b-sqrt(b**2-4.*a*c))/(2.*a)
  15.       x = pow(b,2.) - 4. * a * c;
  16.       d1 = (-b + pow(x,.5))/(2.*a);
  17.       d2 = (-b - pow(x,.5))/(2.*a);
  18.       if(ABS(d1) < 1.) dval=-d1;
  19.       if(ABS(d2) < 1.) dval=-d2;
  20.       return((double)dval);
  21. }
  22.