|
|
|
|
Documentation |
|
Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages Search
NLSOUND::CSourceDSound Class ReferenceDirectSound sound source.
More...
#include <source_dsound.h>
Inheritance diagram for NLSOUND::CSourceDSound:
List of all members.
Public Methods |
| CSourceDSound (uint sourcename=0) |
| Constructor. More...
|
virtual | ~CSourceDSound () |
| Destructor. More...
|
void | init (LPDIRECTSOUND directSound) |
| Initialize the DirectSound buffers. Called by the sound driver only. More...
|
uint | sourceName () |
| Return the OpenAL source name. More...
|
IBuffer * | getBuffer () |
| Returns the buffer associated with this source. More...
|
void | reset () |
void | updateVolume (const NLMISC::CVector &listener) |
| Update the source's volume according to its distance and fade out curve. It takes the current position of the listener as argument. More...
|
virtual void | setAlpha (double a) |
| Set the alpha value for the volume-distance curve. More...
|
|
virtual void | setStaticBuffer (IBuffer *buffer) |
| Set the buffer that will be played (no streaming) If the buffer is stereo, the source mode becomes stereo and the source relative mode is on, otherwise the source is considered as a 3D source. More...
|
|
virtual void | setLooping (bool l) |
| Set looping on/off for future playbacks (default: off). More...
|
virtual bool | getLooping () const |
| Return the looping state. More...
|
virtual bool | play () |
| Play the static buffer (or stream in and play). More...
|
virtual void | stop () |
| Stop playing. More...
|
virtual void | pause () |
| Pause. Call play() to resume. More...
|
virtual bool | isPlaying () const |
| Return the playing state. More...
|
virtual bool | isStopped () const |
| Return true if playing is finished or stop() has been called. More...
|
virtual bool | isPaused () const |
| Return the paused state. More...
|
virtual void | update () |
| Update the source (e.g. continue to stream the data in). More...
|
virtual bool | update2 () |
| Update the source (e.g. More...
|
virtual uint32 | getTime () |
| Returns the number of milliseconds the source has been playing. More...
|
|
virtual void | setPos (const NLMISC::CVector &pos, bool deferred) |
| Set the position vector (default: (0,0,0)). More...
|
const NLMISC::CVector & | getPos () const |
| Get the position vector. More...
|
virtual void | setVelocity (const NLMISC::CVector &vel, bool deferred) |
| Set the velocity vector (3D mode only) (default: (0,0,0)). More...
|
virtual void | getVelocity (NLMISC::CVector &vel) const |
| Get the velocity vector. More...
|
virtual void | setDirection (const NLMISC::CVector &dir) |
| Set the direction vector (3D mode only) (default: (0,0,0) as non-directional). More...
|
virtual void | getDirection (NLMISC::CVector &dir) const |
| Get the direction vector. More...
|
virtual void | setGain (float gain) |
| Set the gain (volume value inside [0 , 1]) (default: 1) 0.0 -> silence 0.5 -> -6dB 1.0 -> no attenuation values > 1 (amplification) not supported by most drivers. More...
|
virtual float | getGain () const |
| Get the gain. More...
|
virtual void | setPitch (float pitch) |
| Shift the frequency. More...
|
virtual float | getPitch () const |
| Get the pitch. More...
|
virtual void | setSourceRelativeMode (bool mode) |
| Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false). More...
|
virtual bool | getSourceRelativeMode () const |
| Get the source relative mode. More...
|
virtual void | setMinMaxDistances (float mindist, float maxdist, bool deferred) |
| Set the min and max distances (default: 1, MAX_FLOAT) (3D mode only). More...
|
virtual void | getMinMaxDistances (float &mindist, float &maxdist) const |
| Get the min and max distances. More...
|
virtual void | setCone (float innerAngle, float outerAngle, float outerGain) |
| Set the cone angles (in radian) and gain (in [0 , 1]) (default: 2PI, 2PI, 0) (3D mode only). More...
|
virtual void | getCone (float &innerAngle, float &outerAngle, float &outerGain) const |
| Get the cone angles (in radian). More...
|
virtual void | setEAXProperty (uint prop, void *value, uint valuesize) |
| Set any EAX source property if EAX available. More...
|
Private Methods |
void | release () |
| Release all DirectSound resources. More...
|
bool | lock (uint32 writePos, uint32 size, uint8 *&ptr1, DWORD &bytes1, uint8 *&ptr2, DWORD &bytes2) |
bool | unlock (uint8 *ptr1, DWORD bytes1, uint8 *ptr2, DWORD bytes2) |
void | swap () |
void | getFadeOutSize (uint32 writePos, uint32 &xfadeSize, sint16 *&in1, uint32 &writtenTooMuch) |
| Calculate the size of the crossfade and set the pointer in the sample buffer to the sample that comes after the write cursor in the DirectSound buffer. More...
|
bool | fill () |
bool | silence () |
void | crossFade () |
void | fadeOut () |
void | fadeIn () |
bool | needsUpdate () |
| Check whether the play position has advanced enough to require an update. More...
|
void | setUsed (bool v) |
bool | isUsed () |
Private Attributes |
uint | _SourceName |
uint32 | _BufferSize |
IBuffer * | _SwapBuffer |
bool | _Loop |
TSourceDSoundUserState | _UserState |
LPDIRECTSOUNDBUFFER | _SecondaryBuffer |
TSourceDSoundBufferState | _SecondaryBufferState |
LPDIRECTSOUND3DBUFFER | _3DBuffer |
CRITICAL_SECTION | _CriticalSection |
uint32 | _NextWritePos |
uint32 | _BytesWritten |
uint32 | _SilenceWritten |
uint32 | _EndPosition |
TSourceDSoundEndState | _EndState |
float | _Freq |
uint32 | _SampleRate |
bool | _IsUsed |
sint32 | _Volume |
float | _Gain |
double | _Alpha |
NLMISC::CVector | _Pos |
Static Private Attributes |
uint32 | _UpdateCopySize = 16384 |
uint32 | _SwapCopySize = 32768 |
uint | _DefaultChannels = 1 |
uint | _DefaultSampleRate = 22050 |
uint | _DefaultSampleSize = 16 |
uint32 | _XFadeSize = 64 |
uint32 | _SecondaryBufferSize = 65536 |
Friends |
class | CSoundDriverDSound |
Detailed Description
DirectSound sound source.
For arguments as 3D vectors, use the NeL vector coordinate system
-
Author:
-
Peter Hanappe , Nevrax France
-
Date:
-
2002
Definition at line 93 of file source_dsound.h.
Constructor & Destructor Documentation
NLSOUND::CSourceDSound::CSourceDSound |
( |
uint |
sourcename = 0 |
) |
|
|
|
Constructor.
Definition at line 98 of file source_dsound.cpp.
References _3DBuffer, _Alpha, _BufferSize, _BytesWritten, _CriticalSection, _DefaultSampleRate, _EndPosition, _EndState, _Freq, _Gain, _IsUsed, _Loop, _NextWritePos, _SampleRate, _SecondaryBuffer, _SecondaryBufferState, _SilenceWritten, _SwapBuffer, _UserState, _Volume, NLSOUND::NL_DSOUND_SILENCED, NLSOUND::NL_DSOUND_STOPPED, and NLSOUND::NL_DSOUND_TAIL1. |
NLSOUND::CSourceDSound::~CSourceDSound |
( |
|
) |
[virtual] |
|
Member Function Documentation
void NLSOUND::CSourceDSound::crossFade |
( |
|
) |
[private] |
|
|
Definition at line 1618 of file source_dsound.cpp.
References NLSOUND::ISource::_Buffer, _BufferSize, _BytesWritten, _CriticalSection, _Freq, _NextWritePos, _SecondaryBuffer, _SecondaryBufferSize, _SecondaryBufferState, _SilenceWritten, _SwapBuffer, _SwapCopySize, DBGPOS, getFadeOutSize, INITTIME, NLSOUND::NL_DSOUND_FILLING, NLSOUND::NL_DSOUND_SILENCING, and setPitch.
Referenced by play. |
void NLSOUND::CSourceDSound::fadeIn |
( |
|
) |
[private] |
|
|
Definition at line 2065 of file source_dsound.cpp.
References NLSOUND::ISource::_Buffer, _BufferSize, _BytesWritten, _EndPosition, _EndState, _Freq, _NextWritePos, _SecondaryBuffer, _SecondaryBufferSize, _SecondaryBufferState, _SilenceWritten, _SwapCopySize, _UserState, data, DBGPOS, INITTIME, lock, NLSOUND::NL_DSOUND_FILLING, NLSOUND::NL_DSOUND_SILENCING, NLSOUND::NL_DSOUND_STOPPED, NLSOUND::NL_DSOUND_TAIL1, NLSOUND::NL_DSOUND_TAIL2, NLSOUND_MIN, res, setPitch, and updateVolume.
Referenced by play. |
void NLSOUND::CSourceDSound::fadeOut |
( |
|
) |
[private] |
|
|
Definition at line 1881 of file source_dsound.cpp.
References NLSOUND::ISource::_Buffer, _BufferSize, _BytesWritten, _EndPosition, _EndState, _NextWritePos, _SecondaryBuffer, _SecondaryBufferSize, _SecondaryBufferState, _SilenceWritten, _SwapCopySize, _UserState, DBGPOS, getFadeOutSize, INITTIME, NLSOUND::NL_DSOUND_SILENCING, NLSOUND::NL_DSOUND_STOPPED, NLSOUND::NL_DSOUND_TAIL1, and NLSOUND::NL_DSOUND_TAIL2.
Referenced by pause, and stop. |
bool NLSOUND::CSourceDSound::fill |
( |
|
) |
[private] |
|
|
Definition at line 1186 of file source_dsound.cpp.
References NLSOUND::ISource::_Buffer, _BufferSize, _BytesWritten, _EndPosition, _EndState, _NextWritePos, _SecondaryBuffer, _SecondaryBufferSize, _SecondaryBufferState, _SilenceWritten, _UpdateCopySize, _UserState, data, DBGPOS, INITTIME, lock, NLSOUND::NL_DSOUND_SILENCING, NLSOUND::NL_DSOUND_STOPPED, NLSOUND::NL_DSOUND_TAIL1, NLSOUND::NL_DSOUND_TAIL2, NLSOUND_MIN, and res.
Referenced by update2. |
IBuffer * NLSOUND::CSourceDSound::getBuffer |
( |
|
) |
|
|
void NLSOUND::CSourceDSound::getCone |
( |
float & |
innerAngle, |
|
|
float & |
outerAngle, |
|
|
float & |
outerGain |
|
) |
const [virtual] |
|
void NLSOUND::CSourceDSound::getDirection |
( |
NLMISC::CVector & |
dir |
) |
const [virtual] |
|
void NLSOUND::CSourceDSound::getFadeOutSize |
( |
uint32 |
writePos, |
|
|
uint32 & |
xfadeSize, |
|
|
sint16 *& |
in1, |
|
|
uint32 & |
writtenTooMuch |
|
) |
[private] |
|
|
Calculate the size of the crossfade and set the pointer in the sample buffer to the sample that comes after the write cursor in the DirectSound buffer.
This method also returns the number of samples that have been written after the write cursor.
Definition at line 1524 of file source_dsound.cpp.
References NLSOUND::ISource::_Buffer, _BufferSize, _BytesWritten, _NextWritePos, _SecondaryBufferSize, _SilenceWritten, _XFadeSize, data, DBGPOS, and NLSOUND_DISTANCE.
Referenced by crossFade, and fadeOut. |
float NLSOUND::CSourceDSound::getGain |
( |
|
) |
const [virtual] |
|
bool NLSOUND::CSourceDSound::getLooping |
( |
|
) |
const [virtual] |
|
void NLSOUND::CSourceDSound::getMinMaxDistances |
( |
float & |
mindist, |
|
|
float & |
maxdist |
|
) |
const [virtual] |
|
float NLSOUND::CSourceDSound::getPitch |
( |
|
) |
const [virtual] |
|
bool NLSOUND::CSourceDSound::getSourceRelativeMode |
( |
|
) |
const [virtual] |
|
virtual uint32 NLSOUND::CSourceDSound::getTime |
( |
void |
|
) |
[inline, virtual] |
|
void NLSOUND::CSourceDSound::getVelocity |
( |
NLMISC::CVector & |
vel |
) |
const [virtual] |
|
void NLSOUND::CSourceDSound::init |
( |
LPDIRECTSOUND |
directSound |
) |
|
|
bool NLSOUND::CSourceDSound::isPaused |
( |
|
) |
const [virtual] |
|
bool NLSOUND::CSourceDSound::isPlaying |
( |
|
) |
const [virtual] |
|
bool NLSOUND::CSourceDSound::isStopped |
( |
|
) |
const [virtual] |
|
bool NLSOUND::CSourceDSound::isUsed |
( |
|
) |
[inline, private] |
|
bool NLSOUND::CSourceDSound::lock |
( |
uint32 |
writePos, |
|
|
uint32 |
size, |
|
|
uint8 *& |
ptr1, |
|
|
DWORD & |
bytes1, |
|
|
uint8 *& |
ptr2, |
|
|
DWORD & |
bytes2 |
|
) |
[private] |
|
bool NLSOUND::CSourceDSound::needsUpdate |
( |
|
) |
[private] |
|
void NLSOUND::CSourceDSound::pause |
( |
|
) |
[virtual] |
|
bool NLSOUND::CSourceDSound::play |
( |
|
) |
[virtual] |
|
|
Play the static buffer (or stream in and play).
Implements NLSOUND::ISource.
Definition at line 335 of file source_dsound.cpp.
References NLSOUND::ISource::_Buffer, _BytesWritten, _CriticalSection, _SecondaryBufferState, _SwapBuffer, _UserState, crossFade, DBGPOS, fadeIn, NLSOUND::NL_DSOUND_FILLING, NLSOUND::NL_DSOUND_PLAYING, NLSOUND::NL_DSOUND_SILENCED, NLSOUND::NL_DSOUND_SILENCING, and swap. |
void NLSOUND::CSourceDSound::release |
( |
|
) |
[private] |
|
void NLSOUND::CSourceDSound::reset |
( |
|
) |
|
|
virtual void NLSOUND::CSourceDSound::setAlpha |
( |
double |
a |
) |
[inline, virtual] |
|
|
Set the alpha value for the volume-distance curve.
alpha = 0.0: the volume will decrease linearly between 0dB and -100 dB alpha = 1.0: the volume will decrease linearly between 1.0 and 0.0 (linear scale) alpha = -1.0: the volume will decrease inversely with the distance (1/dist). This is the default used by DirectSound/OpenAL
For any other value of alpha, an interpolation is be done between the two adjacent curves. For example, if alpha equals 0.5, the volume will be halfway between the linear dB curve and the linear amplitude curve.
Reimplemented from NLSOUND::ISource.
Definition at line 257 of file source_dsound.h.
References _Alpha. |
void NLSOUND::CSourceDSound::setCone |
( |
float |
innerAngle, |
|
|
float |
outerAngle, |
|
|
float |
outerGain |
|
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setDirection |
( |
const NLMISC::CVector & |
dir |
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setEAXProperty |
( |
uint |
prop, |
|
|
void * |
value, |
|
|
uint |
valuesize |
|
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setGain |
( |
float |
gain |
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setLooping |
( |
bool |
l |
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setMinMaxDistances |
( |
float |
mindist, |
|
|
float |
maxdist, |
|
|
bool |
deferred |
|
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setPitch |
( |
float |
pitch |
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setPos |
( |
const NLMISC::CVector & |
pos, |
|
|
bool |
deferred |
|
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setSourceRelativeMode |
( |
bool |
mode |
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setStaticBuffer |
( |
IBuffer * |
buffer |
) |
[virtual] |
|
void NLSOUND::CSourceDSound::setUsed |
( |
bool |
v |
) |
[inline, private] |
|
void NLSOUND::CSourceDSound::setVelocity |
( |
const NLMISC::CVector & |
vel, |
|
|
bool |
deferred |
|
) |
[virtual] |
|
bool NLSOUND::CSourceDSound::silence |
( |
|
) |
[private] |
|
|
Definition at line 1394 of file source_dsound.cpp.
References _BufferSize, _BytesWritten, _EndPosition, _EndState, _NextWritePos, _SecondaryBuffer, _SecondaryBufferSize, _SecondaryBufferState, _SilenceWritten, _UpdateCopySize, _UserState, DBGPOS, INITTIME, lock, NLSOUND::NL_DSOUND_ENDED, NLSOUND::NL_DSOUND_PLAYING, NLSOUND::NL_DSOUND_SILENCED, NLSOUND::NL_DSOUND_STOPPED, NLSOUND::NL_DSOUND_TAIL1, and NLSOUND::NL_DSOUND_TAIL2.
Referenced by update2. |
uint NLSOUND::CSourceDSound::sourceName |
( |
|
) |
[inline] |
|
void NLSOUND::CSourceDSound::stop |
( |
|
) |
[virtual] |
|
void NLSOUND::CSourceDSound::swap |
( |
|
) |
[private] |
|
bool NLSOUND::CSourceDSound::unlock |
( |
uint8 * |
ptr1, |
|
|
DWORD |
bytes1, |
|
|
uint8 * |
ptr2, |
|
|
DWORD |
bytes2 |
|
) |
[private] |
|
void NLSOUND::CSourceDSound::update |
( |
|
) |
[virtual] |
|
bool NLSOUND::CSourceDSound::update2 |
( |
|
) |
[virtual] |
|
|
Update the source (e.g.
continue to stream the data in) Returns an indication whether the source actually streamed data or not.
Definition at line 526 of file source_dsound.cpp.
References _CriticalSection, _NextWritePos, _SecondaryBufferSize, _UpdateCopySize, fill, INITTIME, NLSOUND::NL_DSOUND_FILLING, NLSOUND::NL_DSOUND_SILENCED, NLSOUND::NL_DSOUND_SILENCING, res, and silence.
Referenced by update. |
void NLSOUND::CSourceDSound::updateVolume |
( |
const NLMISC::CVector & |
listener |
) |
|
|
Friends And Related Function Documentation
friend class CSoundDriverDSound [friend]
|
|
Member Data Documentation
LPDIRECTSOUND3DBUFFER NLSOUND::CSourceDSound::_3DBuffer [private]
|
|
|
Definition at line 342 of file source_dsound.h.
Referenced by CSourceDSound, getCone, getDirection, getMinMaxDistances, getSourceRelativeMode, getVelocity, init, release, setCone, setDirection, setMinMaxDistances, setPos, setSourceRelativeMode, and setVelocity. |
double NLSOUND::CSourceDSound::_Alpha [private]
|
|
uint32 NLSOUND::CSourceDSound::_BufferSize [private]
|
|
uint32 NLSOUND::CSourceDSound::_BytesWritten [private]
|
|
|
Definition at line 351 of file source_dsound.h.
Referenced by crossFade, CSourceDSound, fadeIn, fadeOut, fill, getFadeOutSize, getTime, play, setStaticBuffer, silence, stop, and swap. |
CRITICAL_SECTION NLSOUND::CSourceDSound::_CriticalSection [private]
|
|
uint NLSOUND::CSourceDSound::_DefaultChannels = 1 [static, private]
|
|
uint NLSOUND::CSourceDSound::_DefaultSampleRate = 22050 [static, private]
|
|
uint NLSOUND::CSourceDSound::_DefaultSampleSize = 16 [static, private]
|
|
uint32 NLSOUND::CSourceDSound::_EndPosition [private]
|
|
float NLSOUND::CSourceDSound::_Freq [private]
|
|
float NLSOUND::CSourceDSound::_Gain [private]
|
|
bool NLSOUND::CSourceDSound::_IsUsed [private]
|
|
bool NLSOUND::CSourceDSound::_Loop [private]
|
|
uint32 NLSOUND::CSourceDSound::_NextWritePos [private]
|
|
uint32 NLSOUND::CSourceDSound::_SampleRate [private]
|
|
LPDIRECTSOUNDBUFFER NLSOUND::CSourceDSound::_SecondaryBuffer [private]
|
|
|
Definition at line 333 of file source_dsound.h.
Referenced by crossFade, CSourceDSound, fadeIn, fadeOut, fill, getPitch, init, lock, needsUpdate, release, setPitch, silence, unlock, and updateVolume. |
uint32 NLSOUND::CSourceDSound::_SecondaryBufferSize = 65536 [static, private]
|
|
uint32 NLSOUND::CSourceDSound::_SilenceWritten [private]
|
|
uint NLSOUND::CSourceDSound::_SourceName [private]
|
|
IBuffer* NLSOUND::CSourceDSound::_SwapBuffer [private]
|
|
uint32 NLSOUND::CSourceDSound::_SwapCopySize = 32768 [static, private]
|
|
uint32 NLSOUND::CSourceDSound::_UpdateCopySize = 16384 [static, private]
|
|
|
Definition at line 330 of file source_dsound.h.
Referenced by CSourceDSound, fadeIn, fadeOut, fill, isPaused, isPlaying, isStopped, pause, play, silence, and stop. |
sint32 NLSOUND::CSourceDSound::_Volume [private]
|
|
uint32 NLSOUND::CSourceDSound::_XFadeSize = 64 [static, private]
|
|
The documentation for this class was generated from the following files:
|
|