forked from teamnwah/openmw-tes3coop
Fade out music before change occurs
This commit is contained in:
parent
fe8437ae10
commit
60a7d3d6e0
2 changed files with 43 additions and 3 deletions
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
namespace MWSound
|
namespace MWSound
|
||||||
{
|
{
|
||||||
SoundManager::SoundManager(const VFS::Manager* vfs, const std::map<std::string,std::string>& fallbackMap, bool useSound)
|
SoundManager::SoundManager(const VFS::Manager* vfs, const std::map<std::string, std::string>& fallbackMap, bool useSound)
|
||||||
: mVFS(vfs)
|
: mVFS(vfs)
|
||||||
, mFallback(fallbackMap)
|
, mFallback(fallbackMap)
|
||||||
, mOutput(new DEFAULT_OUTPUT(*this))
|
, mOutput(new DEFAULT_OUTPUT(*this))
|
||||||
|
@ -328,9 +328,23 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoundManager::advanceMusic(const std::string& filename)
|
||||||
|
{
|
||||||
|
if (!isMusicPlaying())
|
||||||
|
{
|
||||||
|
streamMusicFull(filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mMusicFader = 0.5f;
|
||||||
|
mNextMusic = filename;
|
||||||
|
|
||||||
|
mMusic->setFadeout(mMusicFader);
|
||||||
|
}
|
||||||
|
|
||||||
void SoundManager::streamMusic(const std::string& filename)
|
void SoundManager::streamMusic(const std::string& filename)
|
||||||
{
|
{
|
||||||
streamMusicFull("Music/"+filename);
|
advanceMusic("Music/"+filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::startRandomTitle()
|
void SoundManager::startRandomTitle()
|
||||||
|
@ -370,7 +384,7 @@ namespace MWSound
|
||||||
i = (i+1) % filelist.size();
|
i = (i+1) % filelist.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
streamMusicFull(filelist[i]);
|
advanceMusic(filelist[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SoundManager::isMusicPlaying()
|
bool SoundManager::isMusicPlaying()
|
||||||
|
@ -1029,6 +1043,25 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SoundManager::updateMusic(float duration)
|
||||||
|
{
|
||||||
|
if (!mNextMusic.empty())
|
||||||
|
{
|
||||||
|
mMusic->updateFade(duration);
|
||||||
|
|
||||||
|
mOutput->startUpdate();
|
||||||
|
mOutput->updateStream(mMusic);
|
||||||
|
mOutput->finishUpdate();
|
||||||
|
|
||||||
|
if (mMusic->getRealVolume() <= 0.f)
|
||||||
|
{
|
||||||
|
streamMusicFull(mNextMusic);
|
||||||
|
mNextMusic.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SoundManager::update(float duration)
|
void SoundManager::update(float duration)
|
||||||
{
|
{
|
||||||
if(!mOutput->isInitialized())
|
if(!mOutput->isInitialized())
|
||||||
|
@ -1040,6 +1073,7 @@ namespace MWSound
|
||||||
updateSounds(duration);
|
updateSounds(duration);
|
||||||
updateRegionSound(duration);
|
updateRegionSound(duration);
|
||||||
updateWaterSound(duration);
|
updateWaterSound(duration);
|
||||||
|
updateMusic(duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,9 +114,15 @@ namespace MWSound
|
||||||
MWBase::SoundStreamPtr playVoice(DecoderPtr decoder, const osg::Vec3f &pos, bool playlocal);
|
MWBase::SoundStreamPtr playVoice(DecoderPtr decoder, const osg::Vec3f &pos, bool playlocal);
|
||||||
|
|
||||||
void streamMusicFull(const std::string& filename);
|
void streamMusicFull(const std::string& filename);
|
||||||
|
void advanceMusic(const std::string& filename);
|
||||||
|
|
||||||
void updateSounds(float duration);
|
void updateSounds(float duration);
|
||||||
void updateRegionSound(float duration);
|
void updateRegionSound(float duration);
|
||||||
void updateWaterSound(float duration);
|
void updateWaterSound(float duration);
|
||||||
|
void updateMusic(float duration);
|
||||||
|
|
||||||
|
float mMusicFader;
|
||||||
|
std::string mNextMusic;
|
||||||
|
|
||||||
float volumeFromType(PlayType type) const;
|
float volumeFromType(PlayType type) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue