MY_AUDIO.CPP 792 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "global.h"
  2. // Audio includes...
  3. #include "audio.h"
  4. #include "defines.h"
  5. #include "front.h"
  6. #include "eurofrnt\euro_int.h"
  7. #include "externs.h"
  8. extern match_data match_info;
  9. extern float camera_x,camera_y,camera_z;
  10. /*********************************/
  11. /*** Sound Fx Control Routines ***/
  12. /*********************************/
  13. void play_fx(int fx,float x,float y)
  14. {
  15. int pan,vol;
  16. float d,xd,yd,zd;
  17. xd=x-camera_x;
  18. yd=y-camera_x;
  19. zd=camera_z;
  20. d=calc_dist(x-camera_x,y-camera_y);
  21. d=calc_dist(d,zd);
  22. xd=xd/d;
  23. yd=yd/d;
  24. if (d<MAX_VOL_DIST)
  25. vol=0x7fff;
  26. else
  27. vol=(MAX_VOL_DIST/d)*0x7fff;
  28. d=((xd*cth)+(yd*sth));
  29. pan=0x8000+(d*0x8000);
  30. if (EUROmatch_info.audio==2)
  31. // 3D Sound...
  32. PlayPitchSample(fx,vol,pan);
  33. else
  34. // Mono...
  35. PlayPitchSample(fx,0x7fff,0x8000);
  36. }