forked from teamnwah/openmw-tes3coop
Store some sound properties in the Sound class
This commit is contained in:
parent
c072babd17
commit
7008bd2fe1
2 changed files with 36 additions and 10 deletions
|
@ -12,8 +12,18 @@ namespace MWSound
|
||||||
Sound& operator=(const Sound &rhs);
|
Sound& operator=(const Sound &rhs);
|
||||||
Sound(const Sound &rhs);
|
Sound(const Sound &rhs);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
float mVolume; /* NOTE: Real volume = mVolume*mBaseVolume */
|
||||||
|
float mBaseVolume;
|
||||||
|
float mMinDistance;
|
||||||
|
float mMaxDistance;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sound() { }
|
Sound() : mVolume(1.0f)
|
||||||
|
, mBaseVolume(1.0f)
|
||||||
|
, mMinDistance(20.0f) /* 1 * min_range_scale */
|
||||||
|
, mMaxDistance(12750.0f) /* 255 * max_range_scale */
|
||||||
|
{ }
|
||||||
virtual ~Sound() { }
|
virtual ~Sound() { }
|
||||||
|
|
||||||
friend class OpenAL_Output;
|
friend class OpenAL_Output;
|
||||||
|
|
|
@ -140,6 +140,7 @@ namespace MWSound
|
||||||
if(mMusic)
|
if(mMusic)
|
||||||
mMusic->stop();
|
mMusic->stop();
|
||||||
mMusic = mOutput->streamSound(filename, 0.4f, 1.0f);
|
mMusic = mOutput->streamSound(filename, 0.4f, 1.0f);
|
||||||
|
mMusic->mBaseVolume = 0.4f;
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -180,10 +181,13 @@ namespace MWSound
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// The range values are not tested
|
// The range values are not tested
|
||||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
float basevol = 1.0f; /* TODO: volume settings */
|
||||||
std::string filePath = std::string("Sound/")+filename;
|
std::string filePath = std::string("Sound/")+filename;
|
||||||
|
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||||
|
|
||||||
|
SoundPtr sound = mOutput->playSound3D(filePath, pos.pos, basevol, 1.0f, 20.0f, 12750.0f, false);
|
||||||
|
sound->mBaseVolume = basevol;
|
||||||
|
|
||||||
SoundPtr sound = mOutput->playSound3D(filePath, pos.pos, 1.0f, 1.0f, 100.0f, 20000.0f, false);
|
|
||||||
mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound"));
|
mActiveSounds[sound] = std::make_pair(ptr, std::string("_say_sound"));
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
|
@ -200,12 +204,18 @@ namespace MWSound
|
||||||
|
|
||||||
void SoundManager::playSound(const std::string& soundId, float volume, float pitch, bool loop)
|
void SoundManager::playSound(const std::string& soundId, float volume, float pitch, bool loop)
|
||||||
{
|
{
|
||||||
float min, max;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string file = lookup(soundId, volume, min, max);
|
float basevol = 1.0f; /* TODO: volume settings */
|
||||||
|
float min, max;
|
||||||
|
std::string file = lookup(soundId, basevol, min, max);
|
||||||
|
|
||||||
|
SoundPtr sound = mOutput->playSound(file, volume*basevol, pitch, loop);
|
||||||
|
sound->mVolume = volume;
|
||||||
|
sound->mBaseVolume = basevol;
|
||||||
|
sound->mMinDistance = min;
|
||||||
|
sound->mMaxDistance = max;
|
||||||
|
|
||||||
SoundPtr sound = mOutput->playSound(file, volume, pitch, loop);
|
|
||||||
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
mActiveSounds[sound] = std::make_pair(MWWorld::Ptr(), soundId);
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
|
@ -217,16 +227,22 @@ namespace MWSound
|
||||||
void SoundManager::playSound3D(MWWorld::Ptr ptr, const std::string& soundId,
|
void SoundManager::playSound3D(MWWorld::Ptr ptr, const std::string& soundId,
|
||||||
float volume, float pitch, bool loop, bool untracked)
|
float volume, float pitch, bool loop, bool untracked)
|
||||||
{
|
{
|
||||||
float min, max;
|
|
||||||
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 min, max;
|
||||||
|
std::string file = lookup(soundId, basevol, min, max);
|
||||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||||
std::string file = lookup(soundId, volume, min, max);
|
|
||||||
|
|
||||||
SoundPtr sound = mOutput->playSound3D(file, pos.pos, volume, pitch, min, max, loop);
|
SoundPtr sound = mOutput->playSound3D(file, pos.pos, volume*basevol, pitch, min, max, loop);
|
||||||
|
sound->mVolume = volume;
|
||||||
|
sound->mBaseVolume = basevol;
|
||||||
|
sound->mMinDistance = min;
|
||||||
|
sound->mMaxDistance = max;
|
||||||
|
|
||||||
mActiveSounds[sound] = (!untracked ? std::make_pair(ptr, soundId) :
|
mActiveSounds[sound] = (!untracked ? std::make_pair(ptr, soundId) :
|
||||||
std::make_pair(MWWorld::Ptr(), std::string()));
|
std::make_pair(MWWorld::Ptr(), soundId));
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue