PageRenderTime 52ms CodeModel.GetById 34ms app.highlight 13ms RepoModel.GetById 2ms 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
  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
 28#include "linden_common.h"
 29#include "llaudioengine.h"
 30#include "lllistener_fmod.h"
 31#include "fmod.h"
 32
 33//-----------------------------------------------------------------------
 34// constructor
 35//-----------------------------------------------------------------------
 36LLListener_FMOD::LLListener_FMOD()
 37{
 38	init();
 39}
 40
 41//-----------------------------------------------------------------------
 42LLListener_FMOD::~LLListener_FMOD()
 43{
 44}
 45
 46//-----------------------------------------------------------------------
 47void LLListener_FMOD::init(void)
 48{
 49	// do inherited
 50	LLListener::init();
 51	mDopplerFactor = 1.0f;
 52	mRolloffFactor = 1.0f;
 53}
 54
 55//-----------------------------------------------------------------------
 56void LLListener_FMOD::translate(LLVector3 offset)
 57{
 58	LLListener::translate(offset);
 59
 60	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]);
 61}
 62
 63//-----------------------------------------------------------------------
 64void LLListener_FMOD::setPosition(LLVector3 pos)
 65{
 66	LLListener::setPosition(pos);
 67
 68	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]);
 69}
 70
 71//-----------------------------------------------------------------------
 72void LLListener_FMOD::setVelocity(LLVector3 vel)
 73{
 74	LLListener::setVelocity(vel);
 75
 76	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]);
 77}
 78
 79//-----------------------------------------------------------------------
 80void LLListener_FMOD::orient(LLVector3 up, LLVector3 at)
 81{
 82	LLListener::orient(up, at);
 83
 84	// Welcome to the transition between right and left
 85	// (coordinate systems, that is)
 86	// Leaving the at vector alone results in a L/R reversal
 87	// since DX is left-handed and we (LL, OpenGL, OpenAL) are right-handed
 88	at = -at;
 89
 90	FSOUND_3D_Listener_SetAttributes(NULL, NULL, at.mV[0],at.mV[1],at.mV[2], up.mV[0],up.mV[1],up.mV[2]);
 91}
 92
 93//-----------------------------------------------------------------------
 94void LLListener_FMOD::commitDeferredChanges()
 95{
 96	FSOUND_Update();
 97}
 98
 99
100void LLListener_FMOD::setRolloffFactor(F32 factor)
101{
102	mRolloffFactor = factor;
103	FSOUND_3D_SetRolloffFactor(factor);
104}
105
106
107F32 LLListener_FMOD::getRolloffFactor()
108{
109	return mRolloffFactor;
110}
111
112
113void LLListener_FMOD::setDopplerFactor(F32 factor)
114{
115	mDopplerFactor = factor;
116	FSOUND_3D_SetDopplerFactor(factor);
117}
118
119
120F32 LLListener_FMOD::getDopplerFactor()
121{
122	return mDopplerFactor;
123}
124
125