PixelLightAPI  .
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
PLSound::SoundManager Class Reference

Abstract sound manager main class. More...

#include <SoundManager.h>

Inheritance diagram for PLSound::SoundManager:
Inheritance graph
[legend]

List of all members.

Classes

class  Format
 Sound format. More...

Public Types

enum  EListener {
  ListenerPosition = 0, ListenerVelocity = 1, ListenerForward = 2, ListenerUpward = 3,
  ListenerNumber = 4
}
 Listener attributes. More...

Public Member Functions

 pl_class (PLSOUND_RTTI_EXPORT, SoundManager,"PLSound", PLCore::Object,"Abstract sound manager main class") pl_class_endpublic
 Sound statistics.
virtual PLSOUND_API ~SoundManager ()
 Destructor.
PLSOUND_API const Statistics & GetStatistics () const
 Returns the sound statistics.
PLSOUND_API PLCore::uint32 GetNumOfResources () const
 Returns the number of resources.
PLSOUND_API ResourceGetResource (PLCore::uint32 nIndex=0) const
 Returns a sound resource.
PLSOUND_API bool AddResource (Resource &cResource)
 Adds a sound resource to the sound manager.
PLSOUND_API bool RemoveResource (Resource &cResource)
 Removes a sound resource from the sound manager.
virtual PLCore::String GetDescription () const =0
 Returns the sound manager description.
virtual bool GetFormatList (PLCore::List< Format > &lstList) const =0
 Gets a list of all known sound formats.
virtual float GetVolume () const =0
 Gets the master volume.
virtual void SetVolume (float fVolume=1.0f)=0
 Sets the master volume.
virtual float GetPitch () const =0
 Returns the master pitch multiplier.
virtual void SetPitch (float fPitch=1.0f)=0
 Sets the master pitch multiplier.
virtual float GetDopplerFactor () const =0
 Gets the doppler factor.
virtual void SetDopplerFactor (float fFactor=1.0f)=0
 Sets the doppler factor.
virtual BufferCreateSoundBuffer (const PLCore::String &sFilename="", bool bStream=false)=0
 Creates a sound buffer.
virtual SourceCreateSoundSource (Buffer *pSoundBuffer=nullptr)=0
 Creates a sound source.
virtual PLMath::Vector3 GetListenerAttribute (EListener nAttribute) const =0
 Gets a listener attribute value.
virtual bool SetListenerAttribute (EListener nAttribute, const PLMath::Vector3 &vV)=0
 Sets a listener attribute value.

Protected Member Functions

PLSOUND_API SoundManager ()
 Constructor.

Protected Attributes

Statistics m_sStatistics
PLCore::Array< Resource * > m_lstResources

Detailed Description

Abstract sound manager main class.

Note:
  • Does not unload unused resources automatically by default

Member Enumeration Documentation

Listener attributes.

Enumerator:
ListenerPosition 

Position (float3, x/y/z)

ListenerVelocity 

Velocity in meters per second (float3, x/y/z)

ListenerForward 

Forward unit length orientation vector (float3, x/y/z)

ListenerUpward 

Upwards facing unit length orientation vector (float3, x/y/z)

ListenerNumber 

Number of listener properties


Constructor & Destructor Documentation

virtual PLSOUND_API PLSound::SoundManager::~SoundManager ( ) [virtual]

Destructor.

PLSOUND_API PLSound::SoundManager::SoundManager ( ) [protected]

Constructor.


Member Function Documentation

PLSound::SoundManager::pl_class ( PLSOUND_RTTI_EXPORT  ,
SoundManager  ,
"PLSound"  ,
PLCore::Object  ,
"Abstract sound manager main class"   
) [inline]

Sound statistics.

< Number of sound buffers

< Number of sound sources

< Number of currently active sound sources

PLSOUND_API const Statistics& PLSound::SoundManager::GetStatistics ( ) const

Returns the sound statistics.

Returns:
The sound statistics
PLSOUND_API PLCore::uint32 PLSound::SoundManager::GetNumOfResources ( ) const

Returns the number of resources.

Returns:
Number of resources
PLSOUND_API Resource* PLSound::SoundManager::GetResource ( PLCore::uint32  nIndex = 0) const

Returns a sound resource.

Parameters:
[in]nIndexIndex of the resource to return
Returns:
The resource at the given index, a null pointer on error
PLSOUND_API bool PLSound::SoundManager::AddResource ( Resource cResource)

Adds a sound resource to the sound manager.

Parameters:
[in]cResourceSound resource to add
Returns:
'true' if all went fine and the sound resource was added to the sound manager, else 'false'
Note:
  • The sound resource itself is only added to the sound manager's list of resources!
PLSOUND_API bool PLSound::SoundManager::RemoveResource ( Resource cResource)

Removes a sound resource from the sound manager.

Parameters:
[in]cResourceSound resource to remove
Returns:
'true' if all went fine and the sound resource was removed from the sound manager, else 'false' (maybe the resource isn't in the sound manager)
Note:
  • The sound resource itself isn't destroyed, it is just removed from the sound manager's list of resources!
virtual PLCore::String PLSound::SoundManager::GetDescription ( ) const [pure virtual]

Returns the sound manager description.

Returns:
Sound manager description
virtual bool PLSound::SoundManager::GetFormatList ( PLCore::List< Format > &  lstList) const [pure virtual]

Gets a list of all known sound formats.

Parameters:
[out]lstListList to receive the known sound formats (see Format)
Returns:
'true' if all went fine, else 'false'
Note:
  • The given list is NOT cleared before the formats are added
virtual float PLSound::SoundManager::GetVolume ( ) const [pure virtual]

Gets the master volume.

Returns:
Volume (value from 0.0-1.0 -> 0.0 = silence, 1.0 = full volume)
virtual void PLSound::SoundManager::SetVolume ( float  fVolume = 1.0f) [pure virtual]

Sets the master volume.

Parameters:
[in]fVolumeVolume (value from 0.0-1.0 -> 0.0 = silence, 1.0 = full volume)
virtual float PLSound::SoundManager::GetPitch ( ) const [pure virtual]

Returns the master pitch multiplier.

Returns:
Pitch multiplier
Remarks:
pitch < 1.0 = slower
pitch = 1.0 = normal
pitch > 1.0 = faster
virtual void PLSound::SoundManager::SetPitch ( float  fPitch = 1.0f) [pure virtual]

Sets the master pitch multiplier.

Parameters:
[in]fPitchPitch multiplier
See also:
virtual float PLSound::SoundManager::GetDopplerFactor ( ) const [pure virtual]

Gets the doppler factor.

Returns:
Doppler factor
Remarks:
If velocities are applied to the listener object or to any source object, then doppler shift will be applied to the audio. The following formula is used to calculate doppler shift:
f’ = f*(DV – DF*vl)/(DV + DF*vs)
DV = doppler velocity
DF = doppler factor
vl = listener velocity (scalar value along source-to-listener vector)
vs = source velocity (scalar value along source-to-listener vector)
f = frequency of sample
f’ = Doppler shifted frequency
The doppler velocity (340) represents the speed of sound.
The doppler factor is used to exaggerate or de-emphasize the doppler shift.
virtual void PLSound::SoundManager::SetDopplerFactor ( float  fFactor = 1.0f) [pure virtual]

Sets the doppler factor.

Parameters:
[in]fFactorDoppler factor
See also:
virtual Buffer* PLSound::SoundManager::CreateSoundBuffer ( const PLCore::String sFilename = "",
bool  bStream = false 
) [pure virtual]

Creates a sound buffer.

Parameters:
[in]sFilenameSound filename, if empty, only create the sound buffer without loading it (full path, supported file formats are API dependent)
[in]bStreamStream the file? (recommended for large files!)
Returns:
The created sound buffer, a null pointer on error
Note:
  • If there's already a sound buffer with this name, this sound buffer is returned
  • Not each sound buffer can be streamed, use SoundBuffer::IsStreamed() to check whether streaming is used.
virtual Source* PLSound::SoundManager::CreateSoundSource ( Buffer pSoundBuffer = nullptr) [pure virtual]

Creates a sound source.

Parameters:
[in]pSoundBufferSound buffer to load, a null pointer if load no sound buffer by default
Returns:
The created sound source, a null pointer on error
Remarks:
The simplest creation of a sound source ready for playback would be
SoundSource *pSS = pSM->CreateSoundSource(CreateSoundBuffer("MySound.wav"));
Whereby 'MySound.wav' isn't loaded twice if there's already such a sound buffer.
virtual PLMath::Vector3 PLSound::SoundManager::GetListenerAttribute ( EListener  nAttribute) const [pure virtual]

Gets a listener attribute value.

Parameters:
[in]nAttributeListener attribute to return
Returns:
Requested listener attribute value
virtual bool PLSound::SoundManager::SetListenerAttribute ( EListener  nAttribute,
const PLMath::Vector3 vV 
) [pure virtual]

Sets a listener attribute value.

Parameters:
[in]nAttributeListener attribute to set
[in]vVNew listener attribute value
Returns:
'true' if all went fine, else 'false'

Member Data Documentation

Statistics PLSound::SoundManager::m_sStatistics [protected]

Sound statistics

Sound resources of this sound manager

Reimplemented from PLCore::ResourceManager< Buffer >.


The documentation for this class was generated from the following file:


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:42
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported