Public Member Functions | Protected Member Functions | Private Types | Private Attributes

sound::SoundBase Class Reference

Base Sound class. More...

#include <_src_sound_sound_base.hh>

Inheritance diagram for sound::SoundBase:
sound::SoundNOP sound::SoundPLIB

List of all members.

Public Member Functions

virtual bool Enable (const bool enable=true)=0
virtual bool IfEnabled (void)=0
bool IfPlaying (const Sample::Name &sampleName)
bool Play (const Sample::Name &sampleName, const defs::ePlayLoop playLoop, const fp volume=defs::DEFAULT_VOLUME)
bool Stop (void)
bool Stop (const Sample::Name &sampleName)
virtual fp GetVolume (void)=0
virtual bool SetVolume (const fp volume)=0
fp GetVolume (const Sample::Name &sampleName)
bool SetVolume (const Sample::Name &sampleName, const fp volume)
CLASS_METHOD const string ComputePathnameSoundFile (const string &soundFilename)

Protected Member Functions

 SoundBase (void)
virtual ~SoundBase ()
virtual shptr< SampleCreateSample (const Sample::Name &sampleName)=0

Private Types

typedef std::map< Sample::Name,
shptr< Sample > > 
SampleMap

Private Attributes

SampleMap mSampleMap
 cache of sound samples

Detailed Description

Base Sound class.

SoundBase: ---------- SoundBase provides generic functionality. SoundBase controls sound samples in terms of the base Sample class. A derivative of Sound is specific to a sound system. If no sound system is available, SoundNOP will be compiled.

Sound keeps tracking of samples being played: --------------------------------------------- Play() will become a NOP if redundantly passed the same args while it is still playing. So clients can rely on Sound to keep track of which samples are playing.

Class design: ------------- A derivative of SoundBase initializes the sound system and controls the master volume. A derivative of Sample plays sound files. SoundBase provides caching of Samples. SoundBase is able to define the Sample-related methods, but defers other functionality to a SoundBase derivative.


Member Typedef Documentation

typedef std::map< Sample::Name, shptr<Sample> > sound::SoundBase::SampleMap [private]

Constructor & Destructor Documentation

sound::SoundBase::SoundBase ( void   )  [protected]

ctor/dtor.

sound::SoundBase::~SoundBase (  )  [protected, virtual]

Member Function Documentation

const string sound::SoundBase::ComputePathnameSoundFile ( const string &  soundFilename  ) 

Compute full pathname to a sound file according to these rules:

  • If arg is a pure filename (no slashes) then prepends directory to sound data files.
  • If arg has any slashes then it is returned unchanged (relative or absolute pathname).
virtual shptr<Sample> sound::SoundBase::CreateSample ( const Sample::Name sampleName  )  [protected, pure virtual]

Implemented in sound::SoundPLIB.

virtual bool sound::SoundBase::Enable ( const bool  enable = true  )  [pure virtual]
fp sound::SoundBase::GetVolume ( const Sample::Name sampleName  ) 
Returns:
Volume of a sample.
virtual fp sound::SoundBase::GetVolume ( void   )  [pure virtual]

Implemented in sound::SoundPLIB.

virtual bool sound::SoundBase::IfEnabled ( void   )  [pure virtual]

Implemented in sound::SoundPLIB.

bool sound::SoundBase::IfPlaying ( const Sample::Name sampleName  ) 
Returns:
True if sample is playing.
bool sound::SoundBase::Play ( const Sample::Name sampleName,
const defs::ePlayLoop  playLoop,
const fp  volume = defs::DEFAULT_VOLUME 
)

Play sound sample.

Parameters:
sampleName 
playLoop Play continuously or once.
volume Default is DEFAULT_VOLUME.
Returns:
false if error (else true, even if sound is disabled).
bool sound::SoundBase::SetVolume ( const Sample::Name sampleName,
const fp  volume 
)

Set volume of a sample.

Parameters:
sampleName 
volume 0.0 = off, 1.0 max volume.
virtual bool sound::SoundBase::SetVolume ( const fp  volume  )  [pure virtual]

Implemented in sound::SoundPLIB.

bool sound::SoundBase::Stop ( void   ) 

Stop playing all samples.

bool sound::SoundBase::Stop ( const Sample::Name sampleName  ) 

Stop playing a sample.


Member Data Documentation

cache of sound samples


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Palomino Flight Simulator documents generated by doxygen 1.7.1 on Tue May 15 2012 22:40:12