|
|
|
@ -260,7 +260,16 @@ bool OpenAL_SoundStream::isPlaying()
|
|
|
|
|
|
|
|
|
|
void OpenAL_SoundStream::update()
|
|
|
|
|
{
|
|
|
|
|
alSourcef(mSource, AL_GAIN, mVolume*mBaseVolume);
|
|
|
|
|
ALfloat gain = mVolume*mBaseVolume;
|
|
|
|
|
ALfloat pitch = 1.0f;
|
|
|
|
|
if(!(mFlags&Play_NoEnv) && mOutput.mLastEnvironment == Env_Underwater)
|
|
|
|
|
{
|
|
|
|
|
gain *= 0.9f;
|
|
|
|
|
pitch *= 0.7f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alSourcef(mSource, AL_GAIN, gain);
|
|
|
|
|
alSourcef(mSource, AL_PITCH, pitch);
|
|
|
|
|
alSource3f(mSource, AL_POSITION, mPos[0], mPos[2], -mPos[1]);
|
|
|
|
|
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
|
|
|
|
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
|
|
|
@ -388,7 +397,16 @@ bool OpenAL_Sound::isPlaying()
|
|
|
|
|
|
|
|
|
|
void OpenAL_Sound::update()
|
|
|
|
|
{
|
|
|
|
|
alSourcef(mSource, AL_GAIN, mVolume*mBaseVolume);
|
|
|
|
|
ALfloat gain = mVolume*mBaseVolume;
|
|
|
|
|
ALfloat pitch = 1.0f;
|
|
|
|
|
if(!(mFlags&Play_NoEnv) && mOutput.mLastEnvironment == Env_Underwater)
|
|
|
|
|
{
|
|
|
|
|
gain *= 0.9f;
|
|
|
|
|
pitch *= 0.7f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alSourcef(mSource, AL_GAIN, gain);
|
|
|
|
|
alSourcef(mSource, AL_PITCH, pitch);
|
|
|
|
|
alSource3f(mSource, AL_POSITION, mPos[0], mPos[2], -mPos[1]);
|
|
|
|
|
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
|
|
|
|
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
|
|
|
@ -397,10 +415,18 @@ void OpenAL_Sound::update()
|
|
|
|
|
|
|
|
|
|
void OpenAL_Sound3D::update()
|
|
|
|
|
{
|
|
|
|
|
ALfloat gain = mVolume*mBaseVolume;
|
|
|
|
|
ALfloat pitch = 1.0f;
|
|
|
|
|
if(mPos.squaredDistance(mOutput.mPos) > mMaxDistance*mMaxDistance)
|
|
|
|
|
alSourcef(mSource, AL_GAIN, 0.0f);
|
|
|
|
|
else
|
|
|
|
|
alSourcef(mSource, AL_GAIN, mVolume*mBaseVolume);
|
|
|
|
|
gain = 0.0f;
|
|
|
|
|
else if(!(mFlags&Play_NoEnv) && mOutput.mLastEnvironment == Env_Underwater)
|
|
|
|
|
{
|
|
|
|
|
gain *= 0.9f;
|
|
|
|
|
pitch *= 0.7f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alSourcef(mSource, AL_GAIN, gain);
|
|
|
|
|
alSourcef(mSource, AL_PITCH, pitch);
|
|
|
|
|
alSource3f(mSource, AL_POSITION, mPos[0], mPos[2], -mPos[1]);
|
|
|
|
|
alSource3f(mSource, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
|
|
|
|
alSource3f(mSource, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
|
|
|
@ -638,6 +664,11 @@ SoundPtr OpenAL_Output::playSound(const std::string &fname, float volume, float
|
|
|
|
|
alSourcef(src, AL_MAX_DISTANCE, 1000.0f);
|
|
|
|
|
alSourcef(src, AL_ROLLOFF_FACTOR, 0.0f);
|
|
|
|
|
|
|
|
|
|
if(!(flags&Play_NoEnv) && mLastEnvironment == Env_Underwater)
|
|
|
|
|
{
|
|
|
|
|
volume *= 0.9f;
|
|
|
|
|
pitch *= 0.7f;
|
|
|
|
|
}
|
|
|
|
|
alSourcef(src, AL_GAIN, volume);
|
|
|
|
|
alSourcef(src, AL_PITCH, pitch);
|
|
|
|
|
|
|
|
|
@ -685,6 +716,11 @@ SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const Ogre::Vector
|
|
|
|
|
alSourcef(src, AL_MAX_DISTANCE, max);
|
|
|
|
|
alSourcef(src, AL_ROLLOFF_FACTOR, 1.0f);
|
|
|
|
|
|
|
|
|
|
if(!(flags&Play_NoEnv) && mLastEnvironment == Env_Underwater)
|
|
|
|
|
{
|
|
|
|
|
volume *= 0.9f;
|
|
|
|
|
pitch *= 0.7f;
|
|
|
|
|
}
|
|
|
|
|
alSourcef(src, AL_GAIN, (pos.squaredDistance(mPos) > max*max) ?
|
|
|
|
|
0.0f : volume);
|
|
|
|
|
alSourcef(src, AL_PITCH, pitch);
|
|
|
|
@ -701,7 +737,7 @@ SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const Ogre::Vector
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SoundPtr OpenAL_Output::streamSound(const std::string &fname, float volume, float pitch)
|
|
|
|
|
SoundPtr OpenAL_Output::streamSound(const std::string &fname, float volume, float pitch, int flags)
|
|
|
|
|
{
|
|
|
|
|
boost::shared_ptr<OpenAL_SoundStream> sound;
|
|
|
|
|
ALuint src;
|
|
|
|
@ -713,6 +749,8 @@ SoundPtr OpenAL_Output::streamSound(const std::string &fname, float volume, floa
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if((flags&Play_Loop))
|
|
|
|
|
std::cout <<"Warning: cannot loop stream "<<fname<< std::endl;
|
|
|
|
|
DecoderPtr decoder = mManager.getDecoder();
|
|
|
|
|
decoder->open(fname);
|
|
|
|
|
sound.reset(new OpenAL_SoundStream(*this, src, decoder));
|
|
|
|
@ -731,6 +769,11 @@ SoundPtr OpenAL_Output::streamSound(const std::string &fname, float volume, floa
|
|
|
|
|
alSourcef(src, AL_MAX_DISTANCE, 1000.0f);
|
|
|
|
|
alSourcef(src, AL_ROLLOFF_FACTOR, 0.0f);
|
|
|
|
|
|
|
|
|
|
if(!(flags&Play_NoEnv) && mLastEnvironment == Env_Underwater)
|
|
|
|
|
{
|
|
|
|
|
volume *= 0.9f;
|
|
|
|
|
pitch *= 0.7f;
|
|
|
|
|
}
|
|
|
|
|
alSourcef(src, AL_GAIN, volume);
|
|
|
|
|
alSourcef(src, AL_PITCH, pitch);
|
|
|
|
|
|
|
|
|
@ -743,9 +786,10 @@ SoundPtr OpenAL_Output::streamSound(const std::string &fname, float volume, floa
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void OpenAL_Output::updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir)
|
|
|
|
|
void OpenAL_Output::updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env)
|
|
|
|
|
{
|
|
|
|
|
mPos = pos;
|
|
|
|
|
mLastEnvironment = env;
|
|
|
|
|
|
|
|
|
|
if(mContext)
|
|
|
|
|
{
|
|
|
|
@ -762,7 +806,7 @@ void OpenAL_Output::updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3
|
|
|
|
|
|
|
|
|
|
OpenAL_Output::OpenAL_Output(SoundManager &mgr)
|
|
|
|
|
: Sound_Output(mgr), mDevice(0), mContext(0), mBufferCacheMemSize(0),
|
|
|
|
|
mStreamThread(new StreamThread)
|
|
|
|
|
mLastEnvironment(Env_Normal), mStreamThread(new StreamThread)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|