PageRenderTime 27ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llaudio/lllistener_fmod.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 125 lines | 60 code | 24 blank | 41 comment | 0 complexity | 314d5fbb155cf28037884fb8c3e1c928 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file listener_fmod.cpp
  3. * @brief implementation of LISTENER class abstracting the audio
  4. * support as a FMOD 3D implementation (windows only)
  5. *
  6. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #include "linden_common.h"
  28. #include "llaudioengine.h"
  29. #include "lllistener_fmod.h"
  30. #include "fmod.h"
  31. //-----------------------------------------------------------------------
  32. // constructor
  33. //-----------------------------------------------------------------------
  34. LLListener_FMOD::LLListener_FMOD()
  35. {
  36. init();
  37. }
  38. //-----------------------------------------------------------------------
  39. LLListener_FMOD::~LLListener_FMOD()
  40. {
  41. }
  42. //-----------------------------------------------------------------------
  43. void LLListener_FMOD::init(void)
  44. {
  45. // do inherited
  46. LLListener::init();
  47. mDopplerFactor = 1.0f;
  48. mRolloffFactor = 1.0f;
  49. }
  50. //-----------------------------------------------------------------------
  51. void LLListener_FMOD::translate(LLVector3 offset)
  52. {
  53. LLListener::translate(offset);
  54. FSOUND_3D_Listener_SetAttributes(mPosition.mV, NULL, mListenAt.mV[0],mListenAt.mV[1],mListenAt.mV[2], mListenUp.mV[0],mListenUp.mV[1],mListenUp.mV[2]);
  55. }
  56. //-----------------------------------------------------------------------
  57. void LLListener_FMOD::setPosition(LLVector3 pos)
  58. {
  59. LLListener::setPosition(pos);
  60. FSOUND_3D_Listener_SetAttributes(pos.mV, NULL, mListenAt.mV[0],mListenAt.mV[1],mListenAt.mV[2], mListenUp.mV[0],mListenUp.mV[1],mListenUp.mV[2]);
  61. }
  62. //-----------------------------------------------------------------------
  63. void LLListener_FMOD::setVelocity(LLVector3 vel)
  64. {
  65. LLListener::setVelocity(vel);
  66. FSOUND_3D_Listener_SetAttributes(NULL, vel.mV, mListenAt.mV[0],mListenAt.mV[1],mListenAt.mV[2], mListenUp.mV[0],mListenUp.mV[1],mListenUp.mV[2]);
  67. }
  68. //-----------------------------------------------------------------------
  69. void LLListener_FMOD::orient(LLVector3 up, LLVector3 at)
  70. {
  71. LLListener::orient(up, at);
  72. // Welcome to the transition between right and left
  73. // (coordinate systems, that is)
  74. // Leaving the at vector alone results in a L/R reversal
  75. // since DX is left-handed and we (LL, OpenGL, OpenAL) are right-handed
  76. at = -at;
  77. FSOUND_3D_Listener_SetAttributes(NULL, NULL, at.mV[0],at.mV[1],at.mV[2], up.mV[0],up.mV[1],up.mV[2]);
  78. }
  79. //-----------------------------------------------------------------------
  80. void LLListener_FMOD::commitDeferredChanges()
  81. {
  82. FSOUND_Update();
  83. }
  84. void LLListener_FMOD::setRolloffFactor(F32 factor)
  85. {
  86. mRolloffFactor = factor;
  87. FSOUND_3D_SetRolloffFactor(factor);
  88. }
  89. F32 LLListener_FMOD::getRolloffFactor()
  90. {
  91. return mRolloffFactor;
  92. }
  93. void LLListener_FMOD::setDopplerFactor(F32 factor)
  94. {
  95. mDopplerFactor = factor;
  96. FSOUND_3D_SetDopplerFactor(factor);
  97. }
  98. F32 LLListener_FMOD::getDopplerFactor()
  99. {
  100. return mDopplerFactor;
  101. }