diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index a09a4b056..730d9d9b2 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -50,11 +50,20 @@ namespace MWSound : mResourceMgr(Ogre::ResourceGroupManager::getSingleton()) , mEnvironment(environment) , mOutput(new DEFAULT_OUTPUT(*this)) - + , mMasterVolume(1.0f) + , mSFXVolume(1.0f) + , mMusicVolume(1.0f) { if(!useSound) return; + mMasterVolume = Settings::Manager::getFloat("master volume", "Sound"); + mMasterVolume = std::min(std::max(mMasterVolume, 0.0f), 1.0f); + mSFXVolume = Settings::Manager::getFloat("sfx volume", "Sound"); + mSFXVolume = std::min(std::max(mSFXVolume, 0.0f), 1.0f); + mMusicVolume = Settings::Manager::getFloat("music volume", "Sound"); + mMusicVolume = std::min(std::max(mMusicVolume, 0.0f), 1.0f); + std::cout << "Sound output: " << SOUND_OUT << std::endl; std::cout << "Sound decoder: " << SOUND_IN << std::endl; @@ -154,9 +163,10 @@ namespace MWSound std::cout <<"Playing "<streamSound(filename, 0.4f, 1.0f, Play_NoEnv); - mMusic->mBaseVolume = 0.4f; + mMusic = mOutput->streamSound(filename, basevol, 1.0f, Play_NoEnv); + mMusic->mBaseVolume = basevol; mMusic->mFlags = Play_NoEnv; } catch(std::exception &e) @@ -200,7 +210,7 @@ namespace MWSound try { // The range values are not tested - float basevol = 1.0f; /* TODO: volume settings */ + float basevol = mMasterVolume * mSFXVolume; std::string filePath = "Sound/"+filename; const ESM::Position &pos = ptr.getCellRef().pos; const Ogre::Vector3 objpos(pos.pos[0], pos.pos[1], pos.pos[2]); @@ -231,7 +241,7 @@ namespace MWSound return sound; try { - float basevol = 1.0f; /* TODO: volume settings */ + float basevol = mMasterVolume * mSFXVolume; float min, max; std::string file = lookup(soundId, basevol, min, max); @@ -261,7 +271,7 @@ namespace MWSound try { // Look up the sound in the ESM data - float basevol = 1.0f; /* TODO: volume settings */ + float basevol = mMasterVolume * mSFXVolume; float min, max; std::string file = lookup(soundId, basevol, min, max); const ESM::Position &pos = ptr.getCellRef().pos; diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index cad5f6187..d64db299b 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -56,6 +56,10 @@ namespace MWSound std::auto_ptr mOutput; + float mMasterVolume; + float mSFXVolume; + float mMusicVolume; + boost::shared_ptr mMusic; std::string mCurrentPlaylist; diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 71637c326..878b9b095 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -57,3 +57,8 @@ num lights = 8 [Sound] # Device name. Blank means default device = + +# Volumes. Sfx and music volumes are both affected by the master volume +master volume = 1.0 +sfx volume = 1.0 +music volume = 0.4