Sound.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /***************************************************************************
  2. Sound.cpp - description
  3. -------------------
  4. begin : Wed Jan 26 2000
  5. copyright : (C) 2000 by Henrik Enqvist
  6. email : henqvist@excite.com
  7. ***************************************************************************/
  8. #include <stddef.h>
  9. #include "Private.h"
  10. #include "Sound.h"
  11. #include "Group.h"
  12. Sound::Sound(EmSample* sample, float dist, bool b3D) {
  13. m_b3D = b3D;
  14. m_fDistance = dist;
  15. p_Sample = sample;
  16. m_vtxSrc.x = 0;
  17. m_vtxSrc.y = 0;
  18. m_vtxSrc.z = 0;
  19. p_Parent = NULL;
  20. }
  21. void Sound::setParent(Group* g) {
  22. p_Parent = g;
  23. }
  24. void Sound::play(bool loop) {
  25. m_bLoop = loop;
  26. if (p_Sample == NULL) return;
  27. }
  28. void Sound::adjust() {
  29. EM_COUT("Sound::adjust()" << endl, 1);
  30. // int vol, pan;
  31. // float r2;
  32. if (!m_b3D) return;
  33. if (p_Sample == NULL) return;
  34. // Volume.
  35. /* r2 = (vtxAlPos.x*vtxAlPos.x + vtxAlPos.y*vtxAlPos.y + vtxAlPos.z*vtxAlPos.z)/100;
  36. r2 /= fDistance;
  37. r2 = EM_MAX(1, r2);
  38. vol = (int)((float)255/r2);
  39. vol = (int)EM_MIN(vol, 255);
  40. // Pan
  41. if ( EM_ZERO(vtxAlPos.z)) {
  42. if (vtxAlPos.x > 0) pan = 255;
  43. else pan = 0;
  44. } else {
  45. pan = (int) EMath::emAtan (vtxAlPos.x/ABS(vtxAlPos.z))*2;
  46. pan += 127;
  47. pan = EM_MAX(0, pan);
  48. }*/
  49. }