|
|
|
@ -36,15 +36,7 @@ using namespace Mangle::Sound;
|
|
|
|
|
typedef OEngine::Sound::SoundManager OEManager;
|
|
|
|
|
typedef OEngine::Sound::SoundManagerPtr OEManagerPtr;
|
|
|
|
|
|
|
|
|
|
/* Set the position on a sound based on a Ptr. TODO: We do not support
|
|
|
|
|
tracking moving objects yet, once a sound is started it stays in
|
|
|
|
|
the same place until it finishes.
|
|
|
|
|
|
|
|
|
|
This obviously has to be fixed at some point for player/npc
|
|
|
|
|
footstep sounds and the like. However, updating all sounds each
|
|
|
|
|
frame is expensive, so there should be a special flag for sounds
|
|
|
|
|
that need to track their attached object.
|
|
|
|
|
*/
|
|
|
|
|
// Set the position on a sound based on a Ptr.
|
|
|
|
|
static void setPos(SoundPtr &snd, const MWWorld::Ptr ref)
|
|
|
|
|
{
|
|
|
|
|
// Get sound position from the reference
|
|
|
|
@ -114,7 +106,7 @@ namespace MWSound
|
|
|
|
|
|
|
|
|
|
// Add a sound to the list and play it
|
|
|
|
|
void add(const std::string &file,
|
|
|
|
|
MWWorld::Ptr reference,
|
|
|
|
|
MWWorld::Ptr ptr,
|
|
|
|
|
const std::string &id,
|
|
|
|
|
float volume, float pitch,
|
|
|
|
|
float min, float max,
|
|
|
|
@ -127,7 +119,7 @@ namespace MWSound
|
|
|
|
|
snd->setVolume(volume);
|
|
|
|
|
snd->setPitch(pitch);
|
|
|
|
|
snd->setRange(min,max);
|
|
|
|
|
setPos(snd, reference);
|
|
|
|
|
setPos(snd, ptr);
|
|
|
|
|
snd->play();
|
|
|
|
|
}
|
|
|
|
|
catch(...)
|
|
|
|
@ -138,23 +130,20 @@ namespace MWSound
|
|
|
|
|
|
|
|
|
|
// Stop a sound and remove it from the list. If id="" then
|
|
|
|
|
// remove the entire object and stop all its sounds.
|
|
|
|
|
void remove(MWWorld::Ptr reference, const std::string &id = "")
|
|
|
|
|
void remove(MWWorld::Ptr ptr, const std::string &id = "")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isPlaying(MWWorld::Ptr reference, const std::string &id) const
|
|
|
|
|
bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void removeCell(const MWWorld::Ptr::CellStore *cell)
|
|
|
|
|
{
|
|
|
|
|
// Note to Nico: You can get the cell of a Ptr via the getCell
|
|
|
|
|
// function. Just iterate over all sounds and remove those
|
|
|
|
|
// with matching cell.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void updatePositions(MWWorld::Ptr reference)
|
|
|
|
|
void updatePositions(MWWorld::Ptr ptr)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -171,15 +160,15 @@ namespace MWSound
|
|
|
|
|
delete mData;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SoundManager::say (MWWorld::Ptr reference, const std::string& filename)
|
|
|
|
|
void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename)
|
|
|
|
|
{
|
|
|
|
|
// The range values are not tested
|
|
|
|
|
mData->add(filename, reference, "_say_sound", 1, 1, 100, 10000, false);
|
|
|
|
|
mData->add(filename, ptr, "_say_sound", 1, 1, 100, 10000, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SoundManager::sayDone (MWWorld::Ptr reference) const
|
|
|
|
|
bool SoundManager::sayDone (MWWorld::Ptr ptr) const
|
|
|
|
|
{
|
|
|
|
|
return !mData->isPlaying(reference, "_say_sound");
|
|
|
|
|
return !mData->isPlaying(ptr, "_say_sound");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SoundManager::streamMusic (const std::string& filename)
|
|
|
|
@ -187,9 +176,10 @@ namespace MWSound
|
|
|
|
|
// Play the sound and tell it to stream, if possible. TODO:
|
|
|
|
|
// Store the reference, the jukebox will need to check status,
|
|
|
|
|
// control volume etc.
|
|
|
|
|
SoundPtr music = mData->mgr->play(filename);
|
|
|
|
|
SoundPtr music = mData->mgr->load(filename);
|
|
|
|
|
music->setStreaming(true);
|
|
|
|
|
music->setVolume(0.4);
|
|
|
|
|
music->play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SoundManager::playSound (const std::string& soundId, float volume, float pitch)
|
|
|
|
@ -206,19 +196,19 @@ namespace MWSound
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SoundManager::playSound3D (MWWorld::Ptr reference, const std::string& soundId,
|
|
|
|
|
void SoundManager::playSound3D (MWWorld::Ptr ptr, const std::string& soundId,
|
|
|
|
|
float volume, float pitch, bool loop)
|
|
|
|
|
{
|
|
|
|
|
// Look up the sound in the ESM data
|
|
|
|
|
float min, max;
|
|
|
|
|
const std::string &file = mData->lookup(soundId, volume, min, max);
|
|
|
|
|
if(file != "")
|
|
|
|
|
mData->add(file, reference, soundId, volume, pitch, min, max, loop);
|
|
|
|
|
mData->add(file, ptr, soundId, volume, pitch, min, max, loop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SoundManager::stopSound3D (MWWorld::Ptr reference, const std::string& soundId)
|
|
|
|
|
void SoundManager::stopSound3D (MWWorld::Ptr ptr, const std::string& soundId)
|
|
|
|
|
{
|
|
|
|
|
mData->remove(reference, soundId);
|
|
|
|
|
mData->remove(ptr, soundId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SoundManager::stopSound (MWWorld::Ptr::CellStore *cell)
|
|
|
|
@ -226,13 +216,13 @@ namespace MWSound
|
|
|
|
|
mData->removeCell(cell);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SoundManager::getSoundPlaying (MWWorld::Ptr reference, const std::string& soundId) const
|
|
|
|
|
bool SoundManager::getSoundPlaying (MWWorld::Ptr ptr, const std::string& soundId) const
|
|
|
|
|
{
|
|
|
|
|
return mData->isPlaying(reference, soundId);
|
|
|
|
|
return mData->isPlaying(ptr, soundId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SoundManager::updateObject(MWWorld::Ptr reference)
|
|
|
|
|
void SoundManager::updateObject(MWWorld::Ptr ptr)
|
|
|
|
|
{
|
|
|
|
|
mData->updatePositions(reference);
|
|
|
|
|
mData->updatePositions(ptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|