forked from teamnwah/openmw-tes3coop
Add type flags to the sound play mode
This commit is contained in:
parent
dd3e568a00
commit
72ffceb206
2 changed files with 17 additions and 21 deletions
|
@ -39,9 +39,15 @@ namespace MWBase
|
||||||
Play_Normal = 0, /* tracked, non-looping, multi-instance, environment */
|
Play_Normal = 0, /* tracked, non-looping, multi-instance, environment */
|
||||||
Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */
|
Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */
|
||||||
Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */
|
Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */
|
||||||
Play_NoTrack = 1<<2 /* (3D only) Play the sound at the given object's position
|
Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position
|
||||||
* but do not keep it updated (the sound will not move with
|
* but do not keep it updated (the sound will not move with
|
||||||
* the object and will not stop when the object is deleted. */
|
* the object and will not stop when the object is deleted. */
|
||||||
|
|
||||||
|
Play_TypeSfx = 0, /* Normal SFX sound */
|
||||||
|
Play_TypeVoice = 1<<3, /* Voice sound */
|
||||||
|
Play_TypeMusic = 1<<4, /* Music track */
|
||||||
|
Play_TypeMovie = 1<<5, /* Movie audio track */
|
||||||
|
Play_TypeMask = Play_TypeSfx|Play_TypeVoice|Play_TypeMusic|Play_TypeMovie
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -171,9 +171,7 @@ namespace MWSound
|
||||||
DecoderPtr decoder = getDecoder();
|
DecoderPtr decoder = getDecoder();
|
||||||
decoder->open(filename);
|
decoder->open(filename);
|
||||||
|
|
||||||
mMusic = mOutput->streamSound(decoder, basevol, 1.0f, Play_NoEnv);
|
mMusic = mOutput->streamSound(decoder, basevol, 1.0f, Play_NoEnv|Play_TypeMusic);
|
||||||
mMusic->mBaseVolume = basevol;
|
|
||||||
mMusic->mFlags = Play_NoEnv;
|
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -222,7 +220,7 @@ namespace MWSound
|
||||||
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
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,
|
MWBase::SoundPtr sound = mOutput->playSound3D(filePath, objpos, 1.0f, basevol, 1.0f,
|
||||||
20.0f, 12750.0f, Play_Normal);
|
20.0f, 12750.0f, Play_Normal|Play_TypeVoice);
|
||||||
mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound"));
|
mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound"));
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
|
@ -240,7 +238,7 @@ namespace MWSound
|
||||||
float basevol = mMasterVolume * mVoiceVolume;
|
float basevol = mMasterVolume * mVoiceVolume;
|
||||||
std::string filePath = "Sound/"+filename;
|
std::string filePath = "Sound/"+filename;
|
||||||
|
|
||||||
MWBase::SoundPtr sound = mOutput->playSound(filePath, 1.0f, basevol, 1.0f, Play_Normal);
|
MWBase::SoundPtr sound = mOutput->playSound(filePath, 1.0f, basevol, 1.0f, Play_Normal|Play_TypeVoice);
|
||||||
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), std::string("_say_sound"));
|
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), std::string("_say_sound"));
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
|
@ -277,7 +275,7 @@ namespace MWSound
|
||||||
return track;
|
return track;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
track = mOutput->streamSound(decoder, mMasterVolume, 1.0f, Play_NoEnv);
|
track = mOutput->streamSound(decoder, mMasterVolume, 1.0f, Play_NoEnv|Play_TypeMovie);
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -296,7 +294,7 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
float basevol = mMasterVolume * mSFXVolume;
|
float basevol = mMasterVolume * mSFXVolume;
|
||||||
float min, max;
|
float min, max;
|
||||||
std::string file = lookup(soundId, basevol, min, max);
|
std::string file = lookup(soundId, volume, min, max);
|
||||||
|
|
||||||
sound = mOutput->playSound(file, volume, basevol, pitch, mode);
|
sound = mOutput->playSound(file, volume, basevol, pitch, mode);
|
||||||
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
||||||
|
@ -309,7 +307,7 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::SoundPtr SoundManager::playSound3D(MWWorld::Ptr ptr, const std::string& soundId,
|
MWBase::SoundPtr SoundManager::playSound3D(MWWorld::Ptr ptr, const std::string& soundId,
|
||||||
float volume, float pitch, int mode)
|
float volume, float pitch, int mode)
|
||||||
{
|
{
|
||||||
MWBase::SoundPtr sound;
|
MWBase::SoundPtr sound;
|
||||||
if(!mOutput->isInitialized())
|
if(!mOutput->isInitialized())
|
||||||
|
@ -319,7 +317,7 @@ namespace MWSound
|
||||||
// Look up the sound in the ESM data
|
// Look up the sound in the ESM data
|
||||||
float basevol = mMasterVolume * mSFXVolume;
|
float basevol = mMasterVolume * mSFXVolume;
|
||||||
float min, max;
|
float min, max;
|
||||||
std::string file = lookup(soundId, basevol, 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]);
|
const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]);
|
||||||
|
|
||||||
|
@ -538,18 +536,10 @@ namespace MWSound
|
||||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||||
while(snditer != mActiveSounds.end())
|
while(snditer != mActiveSounds.end())
|
||||||
{
|
{
|
||||||
if(snditer->second.second != "_say_sound")
|
if((snditer->first->mFlags&MWBase::SoundManager::Play_TypeVoice))
|
||||||
{
|
snditer->first->mBaseVolume = mMasterVolume * mVoiceVolume;
|
||||||
float basevol = mMasterVolume * mSFXVolume;
|
|
||||||
float min, max;
|
|
||||||
lookup(snditer->second.second, basevol, min, max);
|
|
||||||
snditer->first->mBaseVolume = basevol;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
snditer->first->mBaseVolume = mMasterVolume * mSFXVolume;
|
||||||
float basevol = mMasterVolume * mVoiceVolume;
|
|
||||||
snditer->first->mBaseVolume = basevol;
|
|
||||||
}
|
|
||||||
snditer->first->update();
|
snditer->first->update();
|
||||||
snditer++;
|
snditer++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue