From b8be867e6e3bca87668bcb7f2f2e0fc9b5af07a9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 7 Apr 2012 14:58:52 -0700 Subject: [PATCH 1/3] Work around a bug in the Windows OpenAL router --- apps/openmw/mwsound/openal_output.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 9959bedc84..615def7019 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -467,10 +467,15 @@ void OpenAL_Output::init(const std::string &devname) else fail("Failed to open \""+devname+"\""); } - if(alcIsExtensionPresent(mDevice, "ALC_ENUMERATE_ALL_EXT")) - std::cout << "Opened \""< Date: Sat, 7 Apr 2012 15:28:38 -0700 Subject: [PATCH 2/3] Add a setting to select the sound device name --- apps/openmw/mwsound/soundmanager.cpp | 15 ++++++++++++++- files/settings-default.cfg | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index eaa18e6dcd..a09a4b0563 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -7,6 +7,7 @@ #include #include +#include #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" @@ -64,7 +65,19 @@ namespace MWSound for(size_t i = 0;i < names.size();i++) std::cout <<" "<init(); + std::string devname = Settings::Manager::getString("device", "Sound"); + try + { + mOutput->init(devname); + } + catch(std::exception &e) + { + if(devname.empty()) + throw; + std::cout <<"Failed to open device \""<init(); + Settings::Manager::setString("device", "Sound", ""); + } } catch(std::exception &e) { diff --git a/files/settings-default.cfg b/files/settings-default.cfg index f616471cce..71637c326d 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -53,3 +53,7 @@ fog end factor = 1.0 [Terrain] # Max. number of lights that affect the terrain. Setting to 1 will only reflect sunlight num lights = 8 + +[Sound] +# Device name. Blank means default +device = From 59ccab0b2ce69e3485bc3d1b65da65d578365ba6 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 7 Apr 2012 16:00:30 -0700 Subject: [PATCH 3/3] Add sound volume settings --- apps/openmw/mwsound/soundmanager.cpp | 22 ++++++++++++++++------ apps/openmw/mwsound/soundmanager.hpp | 4 ++++ files/settings-default.cfg | 5 +++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index a09a4b0563..730d9d9b21 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 cad5f61871..d64db299b4 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 71637c326d..878b9b0957 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