mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 11:06:43 +00:00
Merge remote branch 'chris/sound'
This commit is contained in:
commit
8e6c445111
4 changed files with 51 additions and 10 deletions
|
@ -467,10 +467,15 @@ void OpenAL_Output::init(const std::string &devname)
|
||||||
else
|
else
|
||||||
fail("Failed to open \""+devname+"\"");
|
fail("Failed to open \""+devname+"\"");
|
||||||
}
|
}
|
||||||
if(alcIsExtensionPresent(mDevice, "ALC_ENUMERATE_ALL_EXT"))
|
|
||||||
std::cout << "Opened \""<<alcGetString(mDevice, ALC_ALL_DEVICES_SPECIFIER)<<"\"" << std::endl;
|
|
||||||
else
|
else
|
||||||
std::cout << "Opened \""<<alcGetString(mDevice, ALC_DEVICE_SPECIFIER)<<"\"" << std::endl;
|
{
|
||||||
|
const ALCchar *name = NULL;
|
||||||
|
if(alcIsExtensionPresent(mDevice, "ALC_ENUMERATE_ALL_EXT"))
|
||||||
|
name = alcGetString(mDevice, ALC_ALL_DEVICES_SPECIFIER);
|
||||||
|
if(alcGetError(mDevice) != AL_NO_ERROR || !name)
|
||||||
|
name = alcGetString(mDevice, ALC_DEVICE_SPECIFIER);
|
||||||
|
std::cout << "Opened \""<<name<<"\"" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
mContext = alcCreateContext(mDevice, NULL);
|
mContext = alcCreateContext(mDevice, NULL);
|
||||||
if(!mContext || alcMakeContextCurrent(mContext) == ALC_FALSE)
|
if(!mContext || alcMakeContextCurrent(mContext) == ALC_FALSE)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
|
|
||||||
#include <components/esm_store/store.hpp>
|
#include <components/esm_store/store.hpp>
|
||||||
|
#include <components/settings/settings.hpp>
|
||||||
|
|
||||||
#include "../mwworld/environment.hpp"
|
#include "../mwworld/environment.hpp"
|
||||||
#include "../mwworld/world.hpp"
|
#include "../mwworld/world.hpp"
|
||||||
|
@ -49,11 +50,20 @@ namespace MWSound
|
||||||
: mResourceMgr(Ogre::ResourceGroupManager::getSingleton())
|
: mResourceMgr(Ogre::ResourceGroupManager::getSingleton())
|
||||||
, mEnvironment(environment)
|
, mEnvironment(environment)
|
||||||
, mOutput(new DEFAULT_OUTPUT(*this))
|
, mOutput(new DEFAULT_OUTPUT(*this))
|
||||||
|
, mMasterVolume(1.0f)
|
||||||
|
, mSFXVolume(1.0f)
|
||||||
|
, mMusicVolume(1.0f)
|
||||||
{
|
{
|
||||||
if(!useSound)
|
if(!useSound)
|
||||||
return;
|
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 output: " << SOUND_OUT << std::endl;
|
||||||
std::cout << "Sound decoder: " << SOUND_IN << std::endl;
|
std::cout << "Sound decoder: " << SOUND_IN << std::endl;
|
||||||
|
|
||||||
|
@ -64,7 +74,19 @@ namespace MWSound
|
||||||
for(size_t i = 0;i < names.size();i++)
|
for(size_t i = 0;i < names.size();i++)
|
||||||
std::cout <<" "<<names[i]<< std::endl;
|
std::cout <<" "<<names[i]<< std::endl;
|
||||||
|
|
||||||
|
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 \""<<devname<<"\", trying default"<< std::endl;
|
||||||
mOutput->init();
|
mOutput->init();
|
||||||
|
Settings::Manager::setString("device", "Sound", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -141,9 +163,10 @@ namespace MWSound
|
||||||
std::cout <<"Playing "<<filename<< std::endl;
|
std::cout <<"Playing "<<filename<< std::endl;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
float basevol = mMasterVolume * mMusicVolume;
|
||||||
stopMusic();
|
stopMusic();
|
||||||
mMusic = mOutput->streamSound(filename, 0.4f, 1.0f, Play_NoEnv);
|
mMusic = mOutput->streamSound(filename, basevol, 1.0f, Play_NoEnv);
|
||||||
mMusic->mBaseVolume = 0.4f;
|
mMusic->mBaseVolume = basevol;
|
||||||
mMusic->mFlags = Play_NoEnv;
|
mMusic->mFlags = Play_NoEnv;
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
|
@ -187,7 +210,7 @@ namespace MWSound
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// The range values are not tested
|
// The range values are not tested
|
||||||
float basevol = 1.0f; /* TODO: volume settings */
|
float basevol = mMasterVolume * mSFXVolume;
|
||||||
std::string filePath = "Sound/"+filename;
|
std::string filePath = "Sound/"+filename;
|
||||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||||
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]);
|
||||||
|
@ -218,7 +241,7 @@ namespace MWSound
|
||||||
return sound;
|
return sound;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
float basevol = 1.0f; /* TODO: volume settings */
|
float basevol = mMasterVolume * mSFXVolume;
|
||||||
float min, max;
|
float min, max;
|
||||||
std::string file = lookup(soundId, basevol, min, max);
|
std::string file = lookup(soundId, basevol, min, max);
|
||||||
|
|
||||||
|
@ -248,7 +271,7 @@ namespace MWSound
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Look up the sound in the ESM data
|
// Look up the sound in the ESM data
|
||||||
float basevol = 1.0f; /* TODO: volume settings */
|
float basevol = mMasterVolume * mSFXVolume;
|
||||||
float min, max;
|
float min, max;
|
||||||
std::string file = lookup(soundId, basevol, min, max);
|
std::string file = lookup(soundId, basevol, min, max);
|
||||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||||
|
|
|
@ -56,6 +56,10 @@ namespace MWSound
|
||||||
|
|
||||||
std::auto_ptr<Sound_Output> mOutput;
|
std::auto_ptr<Sound_Output> mOutput;
|
||||||
|
|
||||||
|
float mMasterVolume;
|
||||||
|
float mSFXVolume;
|
||||||
|
float mMusicVolume;
|
||||||
|
|
||||||
boost::shared_ptr<Sound> mMusic;
|
boost::shared_ptr<Sound> mMusic;
|
||||||
std::string mCurrentPlaylist;
|
std::string mCurrentPlaylist;
|
||||||
|
|
||||||
|
|
|
@ -53,3 +53,12 @@ fog end factor = 1.0
|
||||||
[Terrain]
|
[Terrain]
|
||||||
# Max. number of lights that affect the terrain. Setting to 1 will only reflect sunlight
|
# Max. number of lights that affect the terrain. Setting to 1 will only reflect sunlight
|
||||||
num lights = 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
|
||||||
|
|
Loading…
Reference in a new issue