Add a method to play an audio track with a custom decoder

actorid
Chris Robinson 12 years ago
parent 1571243ef0
commit 779ced0889

@ -22,6 +22,8 @@ namespace MWWorld
namespace MWSound
{
class Sound;
class Sound_Decoder;
typedef boost::shared_ptr<Sound_Decoder> DecoderPtr;
}
namespace MWBase
@ -89,6 +91,9 @@ namespace MWBase
virtual void stopSay(MWWorld::Ptr reference=MWWorld::Ptr()) = 0;
///< Stop an actor speaking
virtual SoundPtr playTrack(const MWSound::DecoderPtr& decoder) = 0;
///< Play a 2D audio track, using a custom decoder
virtual SoundPtr playSound(const std::string& soundId, float volume, float pitch,
int mode=Play_Normal) = 0;
///< Play a sound, independently of 3D-position

@ -275,6 +275,26 @@ namespace MWSound
}
MWBase::SoundPtr SoundManager::playTrack(const DecoderPtr& decoder)
{
MWBase::SoundPtr track;
if(!mOutput->isInitialized())
return track;
try
{
float basevol = mMasterVolume;
track = mOutput->streamSound(decoder, basevol, 1.0f, Play_NoEnv);
track->mBaseVolume = basevol;
track->mFlags = Play_NoEnv;
}
catch(std::exception &e)
{
std::cout <<"Sound Error: "<<e.what()<< std::endl;
}
return track;
}
MWBase::SoundPtr SoundManager::playSound(const std::string& soundId, float volume, float pitch, int mode)
{

@ -22,8 +22,6 @@ namespace MWSound
struct Sound_Decoder;
class Sound;
typedef boost::shared_ptr<Sound_Decoder> DecoderPtr;
enum Environment {
Env_Normal,
Env_Underwater
@ -105,6 +103,9 @@ namespace MWSound
virtual void stopSay(MWWorld::Ptr reference=MWWorld::Ptr());
///< Stop an actor speaking
virtual MWBase::SoundPtr playTrack(const DecoderPtr& decoder);
///< Play a 2D audio track, using a custom decoder
virtual MWBase::SoundPtr playSound(const std::string& soundId, float volume, float pitch, int mode=Play_Normal);
///< Play a sound, independently of 3D-position

Loading…
Cancel
Save