Base functionality for sound sources.
More...
#include <LSSSoundSource.h>
List of all members.
Public Types |
enum | LSS_ERROR { LSS_E_INVALID_BUFFER = 0
} |
enum | LSS_SOUND_STATE { LSS_SS_PLAYING,
LSS_SS_PAUSED,
LSS_SS_STOPPED
} |
enum | LSS_LOOP_MODE { LSS_LM_INFINITE = ~0,
LSS_LM_FORCEDWORD = 0x7FFFFFFFUL
} |
Public Member Functions |
LSE_INLINE LSE_CALLCTOR | CSoundSource (LSUINT32 _ui32Id) |
virtual LSS_SOUND_SOURCE LSE_CALL | GetType () const =0 |
virtual LSBOOL LSE_CALL | Static () const =0 |
LSUINT32 LSE_CALL | GetId () const |
LSS_SOUND_STATE LSE_CALL | GetState () const |
virtual LSBOOL LSE_CALL | Play (LSUINT32 _ui32LoopCount=1)=0 |
virtual LSBOOL LSE_CALL | Pause ()=0 |
virtual LSBOOL LSE_CALL | Stop ()=0 |
const CVector3 &LSE_CALL | GetPos () const |
LSVOID LSE_CALL | SetPos (const CVector3 &_vPos) |
const CVector3 &LSE_CALL | GetVel () const |
LSVOID LSE_CALL | SetVel (const CVector3 &_vVel) |
const CVector3 &LSE_CALL | GetDir () const |
LSVOID LSE_CALL | SetDir (const CVector3 &_vDir) |
LSSREAL LSE_CALL | GetMaxDist () const |
LSVOID LSE_CALL | SetMaxDist (LSSREAL _fDist) |
LSSREAL LSE_CALL | GetPitchMultiplier () const |
LSVOID LSE_CALL | SetPitchMultiplier (LSSREAL _fPitch) |
LSSREAL LSE_CALL | GetGain () const |
LSVOID LSE_CALL | SetGain (LSSREAL _fGain) |
LSSREAL LSE_CALL | GetRolloff () const |
LSVOID LSE_CALL | SetRolloff (LSSREAL _fRolloff) |
LSSREAL LSE_CALL | GetMinGain () const |
LSVOID LSE_CALL | SetMinGain (LSSREAL _fMinGain) |
LSSREAL LSE_CALL | GetMaxGain () const |
LSVOID LSE_CALL | SetMaxGain (LSSREAL _fMaxGain) |
LSSREAL LSE_CALL | GetOuterConeGain () const |
LSVOID LSE_CALL | SetOuterConeGain (LSSREAL _fOuterConeGain) |
LSSREAL LSE_CALL | GetInnerConeAngle () const |
LSVOID LSE_CALL | SetInnerConeAngle (LSSREAL _fInnerConeGain) |
LSSREAL LSE_CALL | GetConeAngle () const |
LSVOID LSE_CALL | SetConeAngle (LSSREAL _fConeAngle) |
virtual LSVOID LSE_CALL | Tick (LSUINT64 _ui64TimeSinceLastUpdate) |
virtual LSVOID LSE_CALL | SynchronousUpdate (LSUINTPTR _uiptrUserPtr) |
LSVOID LSE_CALL | SetLoopCount (LSUINT32 _ui32Count) |
LSBOOL LSE_CALL | Loop () const |
LSUINT32 LSE_CALL | TotalLoops () const |
LSBOOL LSE_CALL | Expired () const |
LSVOID LSE_CALL | SetExpirationDate (const LSUINT64 &_ui64Micros) |
virtual LSBOOL LSE_CALL | CanSoftReset () const |
virtual LSVOID LSE_CALL | EventSoundEndedAsync () |
LSBOOL LSE_CALL | JustStarted () const |
LSBOOL LSE_CALL | JustStopped () const |
Protected Types |
enum | { LSS_INVALID_BUFFER = 0
} |
Protected Member Functions |
virtual LSVOID LSE_CALL | ApplyStates () |
LSVOID LSE_CALL | UpdateLoop () |
virtual LSBOOL LSE_CALL | DeviceActivated () |
virtual LSVOID LSE_CALL | DeviceWillClose () |
virtual LSVOID LSE_CALL | EnterDeletableState () const |
Protected Attributes |
LSUINT64 | m_ui64Time |
LSUINT64 | m_ui64DeadTime |
LSUINT64 | m_ui64SoundTime |
LSUINT64 | m_ui64ExpirationDate |
CVector3 | m_vPos |
CVector3 | m_vVel |
CVector3 | m_vDir |
LSSREAL | m_fPitch |
LSSREAL | m_fGain |
LSSREAL | m_fDist |
LSSREAL | m_fRolloff |
LSSREAL | m_fMinGain |
LSSREAL | m_fMaxGain |
LSSREAL | m_fOuterGain |
LSSREAL | m_fInnerAngle |
LSSREAL | m_fConeAngle |
LSBOOL | m_bDirty |
LSUINT32 | m_ui32Id |
LSS_SOUND_STATE | m_ssState |
LSS_SOUND_STATE | m_ssLastStateSynchronous |
LSBOOL | m_bJustBeganSynchronous |
LSBOOL | m_bJustEndedSynchronous |
LSUINT32 | m_ui32LoopCount |
LSBOOL | m_bSoundSystemLooping |
ALuint | m_uiAlSourceId |
Static Protected Attributes |
static LSUINT32 | m_ui32IdCounter |
Friends |
class | CSoundManager |
Detailed Description
Base functionality for sound sources.
Class CSoundSource Description: Base functionality for sound sources. Sources are like instances of 3D models. The shared data is part of the CSoundBuffer class and this class maintains references to them. This class is just the base class for sound sources. There are 2 types of sources: static and streaming. They connect to buffers differently (actually streaming uses its own buffers), but share all of the same properties. This class provides all of the similar properties and the CStaticSoundSource and CStreamingSoundSource inherit from this and add their own methods for connecting to buffers.
Member Enumeration Documentation
An invalid buffer ID (not related to OpenAL etc.)
Our state. Playing, paused, or stopped.
Member Function Documentation
virtual LSVOID LSE_CALL lss::CSoundSource::ApplyStates |
( |
| ) |
[protected, virtual] |
Apply states to the hardware or sound system (OpenAL for example). Does not clear the dirty flag.
virtual LSBOOL LSE_CALL lss::CSoundSource::CanSoftReset |
( |
| ) |
const [virtual] |
Set the value indicating whether this source should resist soft resets or not. A soft reset is a reset that stops sources that do not resist soft resets, then releases all unreferenced data (sources/buffers). This is not the same as a soft unload, which can happen at any time just to save RAM and works only on expired data. A soft reset will stop sources that do not resist the stopping action by returning true via this function.
- Returns:
- Returns false. Override this class to return any other value.
virtual LSBOOL LSE_CALL lss::CSoundSource::DeviceActivated |
( |
| ) |
[protected, virtual] |
A device has been created. We can register with the hardware. The sound manager notifies us of this event after the device has been changed. If there is a device already when we are created, we are notified via this function immediately after being created.
- Returns:
- Returns false if there is an error uploading our sound data to the hardware.
virtual LSVOID LSE_CALL lss::CSoundSource::DeviceWillClose |
( |
| ) |
[protected, virtual] |
Notifies us that the device is about to be lost (changed). We need to sever our connections to it, although we may retain our data/ settings.
virtual LSVOID LSE_CALL lss::CSoundSource::EnterDeletableState |
( |
| ) |
const [protected, virtual] |
Enter a deletable state. In some sound systems, the sound sources cannot be removed from the system under some circumstances, such as when they are playing. Use this function to enter a state that allows deletion of the object.
virtual LSVOID LSE_CALL lss::CSoundSource::EventSoundEndedAsync |
( |
| ) |
[virtual] |
Handle the expiration of the sound. This virtual function should be overridden by an inheriting class to handle the event where the sound stops playing. This function is called immediately when the end of the sound is detected. This means this function could be called on any thread at any time, so care must be taken to handle synchronization issues from this function.
LSBOOL LSE_CALL lss::CSoundSource::Expired |
( |
| ) |
const |
Have we expired? We expire when our dead time exceeds the expiration date. This is used for (optional) automatical removal.
- Returns:
- Returns true if this source has been dead (in the LSS_SS_STOPPED state) for at least as long as its expiration date value.
LSSREAL LSE_CALL lss::CSoundSource::GetConeAngle |
( |
| ) |
const |
Get our cone angle in degrees.
- Returns:
- Returns the outer cone angle for this source in degrees.
const CVector3& LSE_CALL lss::CSoundSource::GetDir |
( |
| ) |
const |
Get our direction.
- Returns:
- Returns a vector indicating the direction of the source.
LSSREAL LSE_CALL lss::CSoundSource::GetGain |
( |
| ) |
const |
Get our gain.
- Returns:
- Returns the gain for this source.
LSUINT32 LSE_CALL lss::CSoundSource::GetId |
( |
| ) |
const |
Get our ID.
- Returns:
- Returns the unique identifier for this sound source.
LSSREAL LSE_CALL lss::CSoundSource::GetInnerConeAngle |
( |
| ) |
const |
Get our cone inner angle in degrees.
- Returns:
- Returns the inner cone angle for this source in degrees.
LSSREAL LSE_CALL lss::CSoundSource::GetMaxDist |
( |
| ) |
const |
Get our distance.
- Returns:
- Returns the maximum distance value for this source.
LSSREAL LSE_CALL lss::CSoundSource::GetMaxGain |
( |
| ) |
const |
Get our maximum gain.
- Returns:
- Returns the maximum gain for this source.
LSSREAL LSE_CALL lss::CSoundSource::GetMinGain |
( |
| ) |
const |
Get our minimum gain.
- Returns:
- Returns the minimum gain for this source.
LSSREAL LSE_CALL lss::CSoundSource::GetOuterConeGain |
( |
| ) |
const |
Get our out-of-cone gain.
- Returns:
- Returns the gain value applied to the region outside the cone angle for this source.
LSSREAL LSE_CALL lss::CSoundSource::GetPitchMultiplier |
( |
| ) |
const |
Get our pitch multiplier.
- Returns:
- Returns the pitch multiplier for this source.
const CVector3& LSE_CALL lss::CSoundSource::GetPos |
( |
| ) |
const |
Get our position.
- Returns:
- Returns the position of the source. The position is always returned as a 3D vector, even though the source may be only 2D or 1D.
LSSREAL LSE_CALL lss::CSoundSource::GetRolloff |
( |
| ) |
const |
Get our roll-off.
- Returns:
- Returns the roll-off for this source.
Get our state.
- Returns:
- Returns the state of this source.
virtual LSS_SOUND_SOURCE LSE_CALL lss::CSoundSource::GetType |
( |
| ) |
const [pure virtual] |
Get the type of this source. Returns one of the LSS_SOUND_SOURCE values.
- Returns:
- Returns an LSS_SOUND_SOURCE enumerated value indicating the type of sound source this object is. Source types 1D, 2D, or 3D, and are static or streaming.
const CVector3& LSE_CALL lss::CSoundSource::GetVel |
( |
| ) |
const |
Get our velocity.
- Returns:
- Returns a reference to a vector indicating the velocity of the source.
LSE_INLINE LSBOOL LSE_CALL lss::CSoundSource::JustStarted |
( |
| ) |
const |
Did this sound just begin playing as of the last synchronous update?
- Returns:
- Returns true if the sound started playing since the last main-thread update.
LSE_INLINE LSBOOL LSE_CALL lss::CSoundSource::JustStopped |
( |
| ) |
const |
Did this sound just stop playing as of the last synchronous update?
- Returns:
- Returns true if the sound stopped playing since the last main-thread update.
LSBOOL LSE_CALL lss::CSoundSource::Loop |
( |
| ) |
const |
Are we set to loop?
- Returns:
- Returns true if we will loop again after the current play is finished. Returns false if the sound will stop after the current play is finished.
virtual LSBOOL LSE_CALL lss::CSoundSource::Pause |
( |
| ) |
[pure virtual] |
Pause the sound. If there is no buffer, returns false.
- Returns:
- Returns false if there is no buffer attached to the source.
virtual LSBOOL LSE_CALL lss::CSoundSource::Play |
( |
LSUINT32 |
_ui32LoopCount = 1 | ) |
[pure virtual] |
Begin playing the sound. If there is no buffer, returns false. The sound plays regardless of whether or not there is a sound device. If there is no sound device, the sound will begin playing at the correct position when a device becomes active. The sound begins playing on the next tick event.
- Parameters:
-
_ui32LoopCount | Number of times to loop the sound or LSS_LM_INFINITE to for a never-ending loop. |
- Returns:
- Returns false if there was an error playing the sound, true otherwise. Typically the only condition that can cause a false return is if there is no buffer attached to the source.
LSVOID LSE_CALL lss::CSoundSource::SetConeAngle |
( |
LSSREAL |
_fConeAngle | ) |
|
Set our cone angle in degrees.
- Parameters:
-
_fConeAngle | The new cone angle for this source in degrees. |
LSVOID LSE_CALL lss::CSoundSource::SetDir |
( |
const CVector3 & |
_vDir | ) |
|
Set our direction.
- Parameters:
-
_vDir | The new direction of the source. |
LSVOID LSE_CALL lss::CSoundSource::SetExpirationDate |
( |
const LSUINT64 & |
_ui64Micros | ) |
|
Set the expiration date for this source. The expiration date is the number of microseconds the sound can remain in the LSS_SS_STOPPED state before being automatically deleted.
- Parameters:
-
_ui64Micros | Number of microseconds the sound can spend in the LSS_SS_STOPPED state before being automatically deleted. |
LSVOID LSE_CALL lss::CSoundSource::SetGain |
( |
LSSREAL |
_fGain | ) |
|
Set our gain.
- Parameters:
-
_fGain | The gain for this source. |
LSVOID LSE_CALL lss::CSoundSource::SetInnerConeAngle |
( |
LSSREAL |
_fInnerConeGain | ) |
|
Set our cone inner angle.
- Parameters:
-
_fInnerConeGain | The inner cone angle. |
LSVOID LSE_CALL lss::CSoundSource::SetLoopCount |
( |
LSUINT32 |
_ui32Count | ) |
|
Set the loop count.
- Parameters:
-
_ui32Count | The loop count. 1 = no repeat. LSS_LM_INFINITE = repeat for forever. |
LSVOID LSE_CALL lss::CSoundSource::SetMaxDist |
( |
LSSREAL |
_fDist | ) |
|
Set our distance.
- Parameters:
-
_fDist | The maximum distance for this source. |
LSVOID LSE_CALL lss::CSoundSource::SetMaxGain |
( |
LSSREAL |
_fMaxGain | ) |
|
Set our maximum gain.
- Parameters:
-
_fMaxGain | The maximum gain for this source. |
LSVOID LSE_CALL lss::CSoundSource::SetMinGain |
( |
LSSREAL |
_fMinGain | ) |
|
Set our minimum gain.
- Parameters:
-
_fMinGain | The minimum gain for this source. |
LSVOID LSE_CALL lss::CSoundSource::SetOuterConeGain |
( |
LSSREAL |
_fOuterConeGain | ) |
|
Set our out-of-cone gain.
- Parameters:
-
_fOuterConeGain | The gain used in the region outside the cone angle of this source. |
LSVOID LSE_CALL lss::CSoundSource::SetPitchMultiplier |
( |
LSSREAL |
_fPitch | ) |
|
Set our pitch multiplier.
- Parameters:
-
_fPitch | The pitch multiplier for this source. |
LSVOID LSE_CALL lss::CSoundSource::SetPos |
( |
const CVector3 & |
_vPos | ) |
|
Set our position.
- Parameters:
-
_vPos | A variable-dimensional vector indicating the position of the source. |
LSVOID LSE_CALL lss::CSoundSource::SetRolloff |
( |
LSSREAL |
_fRolloff | ) |
|
Set our roll-off.
- Parameters:
-
_fRolloff | The roll-off for this source. |
LSVOID LSE_CALL lss::CSoundSource::SetVel |
( |
const CVector3 & |
_vVel | ) |
|
Set our velocity.
- Parameters:
-
_vVel | The velocity of the source. |
virtual LSBOOL LSE_CALL lss::CSoundSource::Static |
( |
| ) |
const [pure virtual] |
Is this source static (non-streaming)?
- Returns:
- Returns true or false to indicate whether the source is streaming or not.
virtual LSBOOL LSE_CALL lss::CSoundSource::Stop |
( |
| ) |
[pure virtual] |
Stop the sound. Sets the position back to 0 and waits for a play command.
- Returns:
- Returns false if there is no buffer, true otherwise.
virtual LSVOID LSE_CALL lss::CSoundSource::SynchronousUpdate |
( |
LSUINTPTR |
_uiptrUserPtr | ) |
[virtual] |
A synchronous update on the main game thread. This function is guaranteed always to be called on the main game thread, typically at the start of a logical update.
- Parameters:
-
_uiptrUserPtr | User data passed during the update on the main thread. |
virtual LSVOID LSE_CALL lss::CSoundSource::Tick |
( |
LSUINT64 |
_ui64TimeSinceLastUpdate | ) |
[virtual] |
Update the source. This usually entails checking the dirty flag and updating the hardware accordingly. Time is given in microseconds.
- Parameters:
-
_ui64TimeSinceLastUpdate | Microseconds by which to update this source. |
LSUINT32 LSE_CALL lss::CSoundSource::TotalLoops |
( |
| ) |
const |
How many times have we looped?
- Returns:
- Returns the total number of times the sound has looped since the last play command.
LSVOID LSE_CALL lss::CSoundSource::UpdateLoop |
( |
| ) |
[protected] |
Update the looping status.
The documentation for this class was generated from the following file: