forked from teamnwah/openmw-tes3coop
Allow specifying the sound type to playSound and playSound3D
This commit is contained in:
parent
ac4dfd3b39
commit
14e0c182f3
9 changed files with 37 additions and 31 deletions
|
@ -46,9 +46,10 @@ namespace MWBase
|
||||||
enum PlayType {
|
enum PlayType {
|
||||||
Play_TypeSfx = 1<<3, /* Normal SFX sound */
|
Play_TypeSfx = 1<<3, /* Normal SFX sound */
|
||||||
Play_TypeVoice = 1<<4, /* Voice sound */
|
Play_TypeVoice = 1<<4, /* Voice sound */
|
||||||
Play_TypeMusic = 1<<5, /* Music track */
|
Play_TypeFoot = 1<<5, /* Footstep sound */
|
||||||
Play_TypeMovie = 1<<6, /* Movie audio track */
|
Play_TypeMusic = 1<<6, /* Music track */
|
||||||
Play_TypeMask = Play_TypeSfx|Play_TypeVoice|Play_TypeMusic|Play_TypeMovie
|
Play_TypeMovie = 1<<7, /* Movie audio track */
|
||||||
|
Play_TypeMask = Play_TypeSfx|Play_TypeVoice|Play_TypeFoot|Play_TypeMusic|Play_TypeMovie
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -102,11 +103,12 @@ namespace MWBase
|
||||||
///< Play a 2D audio track, using a custom decoder
|
///< Play a 2D audio track, using a custom decoder
|
||||||
|
|
||||||
virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch,
|
virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch,
|
||||||
PlayMode mode=Play_Normal) = 0;
|
PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal) = 0;
|
||||||
///< Play a sound, independently of 3D-position
|
///< Play a sound, independently of 3D-position
|
||||||
|
|
||||||
virtual SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId,
|
virtual SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId,
|
||||||
float volume, float pitch, PlayMode mode=Play_Normal) = 0;
|
float volume, float pitch, PlayType type=Play_TypeSfx,
|
||||||
|
PlayMode mode=Play_Normal) = 0;
|
||||||
///< Play a sound from an object
|
///< Play a sound from an object
|
||||||
|
|
||||||
virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId) = 0;
|
virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId) = 0;
|
||||||
|
|
|
@ -53,7 +53,9 @@ namespace MWClass
|
||||||
physics.addObject(ptr,ref->mBase->mData.mFlags & ESM::Light::Carry);
|
physics.addObject(ptr,ref->mBase->mData.mFlags & ESM::Light::Carry);
|
||||||
|
|
||||||
if (!ref->mBase->mSound.empty())
|
if (!ref->mBase->mSound.empty())
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop);
|
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0,
|
||||||
|
MWBase::SoundManager::Play_TypeSfx,
|
||||||
|
MWBase::SoundManager::Play_Loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Light::getModel(const MWWorld::Ptr &ptr) const
|
std::string Light::getModel(const MWWorld::Ptr &ptr) const
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace MWGui
|
||||||
|
|
||||||
void BookWindow::onTakeButtonClicked (MyGUI::Widget* sender)
|
void BookWindow::onTakeButtonClicked (MyGUI::Widget* sender)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
MWBase::Environment::get().getSoundManager()->playSound("Item Book Up", 1.0, 1.0);
|
||||||
|
|
||||||
MWWorld::ActionTake take(mBook);
|
MWWorld::ActionTake take(mBook);
|
||||||
take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||||
|
|
|
@ -87,7 +87,7 @@ namespace MWGui
|
||||||
|
|
||||||
void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
|
void ScrollWindow::onTakeButtonClicked (MyGUI::Widget* _sender)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getSoundManager()->playSound ("Item Book Up", 1.0, 1.0, MWBase::SoundManager::Play_NoTrack);
|
MWBase::Environment::get().getSoundManager()->playSound("Item Book Up", 1.0, 1.0);
|
||||||
|
|
||||||
MWWorld::ActionTake take(mScroll);
|
MWWorld::ActionTake take(mScroll);
|
||||||
take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
take.execute (MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||||
|
|
|
@ -118,7 +118,9 @@ namespace MWScript
|
||||||
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
std::string sound = runtime.getStringLiteral (runtime[0].mInteger);
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, sound, 1.0, 1.0, mLoop ? MWBase::SoundManager::Play_Loop :
|
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, sound, 1.0, 1.0,
|
||||||
|
MWBase::SoundManager::Play_TypeSfx,
|
||||||
|
mLoop ? MWBase::SoundManager::Play_Loop :
|
||||||
MWBase::SoundManager::Play_Normal);
|
MWBase::SoundManager::Play_Normal);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -145,7 +147,9 @@ namespace MWScript
|
||||||
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
Interpreter::Type_Float pitch = runtime[0].mFloat;
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D (ptr, sound, volume, pitch, mLoop ? MWBase::SoundManager::Play_Loop :
|
MWBase::Environment::get().getSoundManager()->playSound3D(ptr, sound, volume, pitch,
|
||||||
|
MWBase::SoundManager::Play_TypeSfx,
|
||||||
|
mLoop ? MWBase::SoundManager::Play_Loop :
|
||||||
MWBase::SoundManager::Play_Normal);
|
MWBase::SoundManager::Play_Normal);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,9 @@ namespace MWSound
|
||||||
case Play_TypeVoice:
|
case Play_TypeVoice:
|
||||||
volume *= mVoiceVolume;
|
volume *= mVoiceVolume;
|
||||||
break;
|
break;
|
||||||
|
case Play_TypeFoot:
|
||||||
|
volume *= mFootstepsVolume;
|
||||||
|
break;
|
||||||
case Play_TypeMusic:
|
case Play_TypeMusic:
|
||||||
case Play_TypeMovie:
|
case Play_TypeMovie:
|
||||||
volume *= mMusicVolume;
|
volume *= mMusicVolume;
|
||||||
|
@ -314,18 +317,18 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MWBase::SoundPtr SoundManager::playSound(const std::string& soundId, float volume, float pitch, PlayMode mode)
|
MWBase::SoundPtr SoundManager::playSound(const std::string& soundId, float volume, float pitch, PlayType type, PlayMode mode)
|
||||||
{
|
{
|
||||||
MWBase::SoundPtr sound;
|
MWBase::SoundPtr sound;
|
||||||
if(!mOutput->isInitialized())
|
if(!mOutput->isInitialized())
|
||||||
return sound;
|
return sound;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
float basevol = volumeFromType(Play_TypeSfx);
|
float basevol = volumeFromType(type);
|
||||||
float min, max;
|
float min, max;
|
||||||
std::string file = lookup(soundId, volume, min, max);
|
std::string file = lookup(soundId, volume, min, max);
|
||||||
|
|
||||||
sound = mOutput->playSound(file, volume, basevol, pitch, mode|Play_TypeSfx);
|
sound = mOutput->playSound(file, volume, basevol, pitch, mode|type);
|
||||||
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
|
@ -336,7 +339,7 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
MWBase::SoundPtr SoundManager::playSound3D(const MWWorld::Ptr &ptr, const std::string& soundId,
|
MWBase::SoundPtr SoundManager::playSound3D(const MWWorld::Ptr &ptr, const std::string& soundId,
|
||||||
float volume, float pitch, PlayMode mode)
|
float volume, float pitch, PlayType type, PlayMode mode)
|
||||||
{
|
{
|
||||||
MWBase::SoundPtr sound;
|
MWBase::SoundPtr sound;
|
||||||
if(!mOutput->isInitialized())
|
if(!mOutput->isInitialized())
|
||||||
|
@ -344,13 +347,13 @@ namespace MWSound
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Look up the sound in the ESM data
|
// Look up the sound in the ESM data
|
||||||
float basevol = volumeFromType(Play_TypeSfx);
|
float basevol = volumeFromType(type);
|
||||||
float min, max;
|
float min, max;
|
||||||
std::string file = lookup(soundId, volume, 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]);
|
||||||
|
|
||||||
sound = mOutput->playSound3D(file, objpos, volume, basevol, pitch, min, max, mode|Play_TypeSfx);
|
sound = mOutput->playSound3D(file, objpos, volume, basevol, pitch, min, max, mode|type);
|
||||||
if((mode&Play_NoTrack))
|
if((mode&Play_NoTrack))
|
||||||
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
||||||
else
|
else
|
||||||
|
|
|
@ -35,8 +35,6 @@ namespace MWSound
|
||||||
float mSFXVolume;
|
float mSFXVolume;
|
||||||
float mMusicVolume;
|
float mMusicVolume;
|
||||||
float mVoiceVolume;
|
float mVoiceVolume;
|
||||||
|
|
||||||
// not implemented
|
|
||||||
float mFootstepsVolume;
|
float mFootstepsVolume;
|
||||||
|
|
||||||
boost::shared_ptr<Sound> mMusic;
|
boost::shared_ptr<Sound> mMusic;
|
||||||
|
@ -108,11 +106,12 @@ namespace MWSound
|
||||||
virtual MWBase::SoundPtr playTrack(const DecoderPtr& decoder, PlayType type);
|
virtual MWBase::SoundPtr playTrack(const DecoderPtr& decoder, PlayType type);
|
||||||
///< Play a 2D audio track, using a custom decoder
|
///< Play a 2D audio track, using a custom decoder
|
||||||
|
|
||||||
virtual MWBase::SoundPtr playSound(const std::string& soundId, float volume, float pitch, PlayMode mode=Play_Normal);
|
virtual MWBase::SoundPtr playSound(const std::string& soundId, float volume, float pitch, PlayType type=Play_TypeSfx, PlayMode mode=Play_Normal);
|
||||||
///< Play a sound, independently of 3D-position
|
///< Play a sound, independently of 3D-position
|
||||||
|
|
||||||
virtual MWBase::SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId,
|
virtual MWBase::SoundPtr playSound3D(const MWWorld::Ptr &reference, const std::string& soundId,
|
||||||
float volume, float pitch, PlayMode mode=Play_Normal);
|
float volume, float pitch, PlayType type=Play_TypeSfx,
|
||||||
|
PlayMode mode=Play_Normal);
|
||||||
///< Play a sound from an object
|
///< Play a sound from an object
|
||||||
|
|
||||||
virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId);
|
virtual void stopSound3D(const MWWorld::Ptr &reference, const std::string& soundId);
|
||||||
|
|
|
@ -21,17 +21,13 @@ void MWWorld::Action::execute (const Ptr& actor)
|
||||||
if (!mSoundId.empty())
|
if (!mSoundId.empty())
|
||||||
{
|
{
|
||||||
if (mKeepSound && actor.getRefData().getHandle()=="player")
|
if (mKeepSound && actor.getRefData().getHandle()=="player")
|
||||||
{
|
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0);
|
||||||
// sound moves with player when teleporting
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(mSoundId, 1.0, 1.0,
|
|
||||||
MWBase::SoundManager::Play_NoTrack);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target
|
bool local = mTarget.isEmpty() || !mTarget.isInCell(); // no usable target
|
||||||
|
|
||||||
MWBase::Environment::get().getSoundManager()->playSound3D(local ? actor : mTarget,
|
MWBase::Environment::get().getSoundManager()->playSound3D(local ? actor : mTarget,
|
||||||
mSoundId, 1.0, 1.0,
|
mSoundId, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx,
|
||||||
mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
|
mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -518,14 +518,14 @@ void WeatherManager::update(float duration)
|
||||||
if (!ambientSnd.empty() && std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), ambientSnd) == mSoundsPlaying.end())
|
if (!ambientSnd.empty() && std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), ambientSnd) == mSoundsPlaying.end())
|
||||||
{
|
{
|
||||||
mSoundsPlaying.push_back(ambientSnd);
|
mSoundsPlaying.push_back(ambientSnd);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(ambientSnd, 1.0, 1.0, MWBase::SoundManager::Play_Loop);
|
MWBase::Environment::get().getSoundManager()->playSound(ambientSnd, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string rainSnd = mWeatherSettings[mCurrentWeather].mRainLoopSoundID;
|
std::string rainSnd = mWeatherSettings[mCurrentWeather].mRainLoopSoundID;
|
||||||
if (!rainSnd.empty() && std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), rainSnd) == mSoundsPlaying.end())
|
if (!rainSnd.empty() && std::find(mSoundsPlaying.begin(), mSoundsPlaying.end(), rainSnd) == mSoundsPlaying.end())
|
||||||
{
|
{
|
||||||
mSoundsPlaying.push_back(rainSnd);
|
mSoundsPlaying.push_back(rainSnd);
|
||||||
MWBase::Environment::get().getSoundManager()->playSound(rainSnd, 1.0, 1.0, MWBase::SoundManager::Play_Loop);
|
MWBase::Environment::get().getSoundManager()->playSound(rainSnd, 1.0, 1.0, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_Loop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue