|
|
|
@ -255,7 +255,7 @@ namespace MWSound
|
|
|
|
|
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
|
|
|
|
|
|
|
|
|
MWBase::SoundPtr sound = mOutput->playSound3D(filePath, objpos, 1.0f, basevol, 1.0f,
|
|
|
|
|
20.0f, 12750.0f, Play_Normal|Play_TypeVoice);
|
|
|
|
|
20.0f, 12750.0f, Play_Normal|Play_TypeVoice, 0);
|
|
|
|
|
mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound"));
|
|
|
|
|
}
|
|
|
|
|
catch(std::exception &e)
|
|
|
|
@ -273,7 +273,7 @@ namespace MWSound
|
|
|
|
|
float basevol = volumeFromType(Play_TypeVoice);
|
|
|
|
|
std::string filePath = "Sound/"+filename;
|
|
|
|
|
|
|
|
|
|
MWBase::SoundPtr sound = mOutput->playSound(filePath, 1.0f, basevol, 1.0f, Play_Normal|Play_TypeVoice);
|
|
|
|
|
MWBase::SoundPtr sound = mOutput->playSound(filePath, 1.0f, basevol, 1.0f, Play_Normal|Play_TypeVoice, 0);
|
|
|
|
|
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), std::string("_say_sound"));
|
|
|
|
|
}
|
|
|
|
|
catch(std::exception &e)
|
|
|
|
@ -320,7 +320,7 @@ namespace MWSound
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MWBase::SoundPtr SoundManager::playSound(const std::string& soundId, float volume, float pitch, PlayType type, PlayMode mode)
|
|
|
|
|
MWBase::SoundPtr SoundManager::playSound(const std::string& soundId, float volume, float pitch, PlayType type, PlayMode mode, float offset)
|
|
|
|
|
{
|
|
|
|
|
MWBase::SoundPtr sound;
|
|
|
|
|
if(!mOutput->isInitialized())
|
|
|
|
@ -331,7 +331,7 @@ namespace MWSound
|
|
|
|
|
float min, max;
|
|
|
|
|
std::string file = lookup(soundId, volume, min, max);
|
|
|
|
|
|
|
|
|
|
sound = mOutput->playSound(file, volume, basevol, pitch, mode|type);
|
|
|
|
|
sound = mOutput->playSound(file, volume, basevol, pitch, mode|type, offset);
|
|
|
|
|
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
|
|
|
|
}
|
|
|
|
|
catch(std::exception &e)
|
|
|
|
@ -342,7 +342,7 @@ namespace MWSound
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWBase::SoundPtr SoundManager::playSound3D(const MWWorld::Ptr &ptr, const std::string& soundId,
|
|
|
|
|
float volume, float pitch, PlayType type, PlayMode mode)
|
|
|
|
|
float volume, float pitch, PlayType type, PlayMode mode, float offset)
|
|
|
|
|
{
|
|
|
|
|
MWBase::SoundPtr sound;
|
|
|
|
|
if(!mOutput->isInitialized())
|
|
|
|
@ -353,10 +353,10 @@ namespace MWSound
|
|
|
|
|
float basevol = volumeFromType(type);
|
|
|
|
|
float min, max;
|
|
|
|
|
std::string file = lookup(soundId, volume, min, max);
|
|
|
|
|
const ESM::Position &pos = ptr.getRefData().getPosition();;
|
|
|
|
|
const ESM::Position &pos = ptr.getRefData().getPosition();
|
|
|
|
|
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
|
|
|
|
|
|
|
|
|
sound = mOutput->playSound3D(file, objpos, volume, basevol, pitch, min, max, mode|type);
|
|
|
|
|
sound = mOutput->playSound3D(file, objpos, volume, basevol, pitch, min, max, mode|type, offset);
|
|
|
|
|
if((mode&Play_NoTrack))
|
|
|
|
|
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
|
|
|
|
else
|
|
|
|
@ -431,6 +431,20 @@ namespace MWSound
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SoundManager::fadeOutSound3D(const MWWorld::Ptr &ptr,
|
|
|
|
|
const std::string& soundId, float duration)
|
|
|
|
|
{
|
|
|
|
|
SoundMap::iterator snditer = mActiveSounds.begin();
|
|
|
|
|
while(snditer != mActiveSounds.end())
|
|
|
|
|
{
|
|
|
|
|
if(snditer->second.first == ptr && snditer->second.second == soundId)
|
|
|
|
|
{
|
|
|
|
|
snditer->first->setFadeout(duration);
|
|
|
|
|
}
|
|
|
|
|
snditer++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SoundManager::getSoundPlaying(const MWWorld::Ptr &ptr, const std::string& soundId) const
|
|
|
|
|
{
|
|
|
|
|
return isPlaying(ptr, soundId);
|
|
|
|
@ -520,6 +534,7 @@ namespace MWSound
|
|
|
|
|
timePassed += duration;
|
|
|
|
|
if(timePassed < (1.0f/30.0f))
|
|
|
|
|
return;
|
|
|
|
|
duration = timePassed;
|
|
|
|
|
timePassed = 0.0f;
|
|
|
|
|
|
|
|
|
|
// Make sure music is still playing
|
|
|
|
@ -542,6 +557,7 @@ namespace MWSound
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Check if any sounds are finished playing, and trash them
|
|
|
|
|
// Lower volume on fading out sounds
|
|
|
|
|
SoundMap::iterator snditer = mActiveSounds.begin();
|
|
|
|
|
while(snditer != mActiveSounds.end())
|
|
|
|
|
{
|
|
|
|
@ -556,6 +572,16 @@ namespace MWSound
|
|
|
|
|
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
|
|
|
|
snditer->first->setPosition(objpos);
|
|
|
|
|
}
|
|
|
|
|
//update fade out
|
|
|
|
|
if(snditer->first->mFadeOutTime>0)
|
|
|
|
|
{
|
|
|
|
|
float soundDuration=duration;
|
|
|
|
|
if(soundDuration>snditer->first->mFadeOutTime)
|
|
|
|
|
soundDuration=snditer->first->mFadeOutTime;
|
|
|
|
|
snditer->first->setVolume(snditer->first->mVolume
|
|
|
|
|
- soundDuration / snditer->first->mFadeOutTime * snditer->first->mVolume);
|
|
|
|
|
snditer->first->mFadeOutTime -= soundDuration;
|
|
|
|
|
}
|
|
|
|
|
snditer->first->update();
|
|
|
|
|
snditer++;
|
|
|
|
|
}
|
|
|
|
|