mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-25 04:11:33 +00:00
Merge pull request #1377 from LennyPenny/master
Fade out music before change occurs
This commit is contained in:
commit
af9db74010
2 changed files with 40 additions and 3 deletions
|
@ -328,9 +328,22 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SoundManager::advanceMusic(const std::string& filename)
|
||||||
|
{
|
||||||
|
if (!isMusicPlaying())
|
||||||
|
{
|
||||||
|
streamMusicFull(filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mNextMusic = filename;
|
||||||
|
|
||||||
|
mMusic->setFadeout(0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
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 +383,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()
|
||||||
|
@ -925,6 +938,8 @@ namespace MWSound
|
||||||
env
|
env
|
||||||
);
|
);
|
||||||
|
|
||||||
|
updateMusic(duration);
|
||||||
|
|
||||||
// Check if any sounds are finished playing, and trash them
|
// Check if any sounds are finished playing, and trash them
|
||||||
SoundMap::iterator snditer = mActiveSounds.begin();
|
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||||
while(snditer != mActiveSounds.end())
|
while(snditer != mActiveSounds.end())
|
||||||
|
@ -1029,6 +1044,23 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SoundManager::updateMusic(float duration)
|
||||||
|
{
|
||||||
|
if (!mNextMusic.empty())
|
||||||
|
{
|
||||||
|
mMusic->updateFade(duration);
|
||||||
|
|
||||||
|
mOutput->updateStream(mMusic);
|
||||||
|
|
||||||
|
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())
|
||||||
|
|
|
@ -114,9 +114,14 @@ 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);
|
||||||
|
|
||||||
|
std::string mNextMusic;
|
||||||
|
|
||||||
float volumeFromType(PlayType type) const;
|
float volumeFromType(PlayType type) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue