FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FIFE::SoundEmitter Class Reference

The class for playing audio files. More...

#include <soundemitter.h>

+ Inheritance diagram for FIFE::SoundEmitter:
+ Collaboration diagram for FIFE::SoundEmitter:

Public Types

typedef boost::function0< void > type_callback
 

Public Member Functions

 SoundEmitter (SoundManager *manager, uint32_t uid)
 
 ~SoundEmitter ()
 
uint32_t getId () const
 Returns the emitter-id. More...
 
void setPositioning (bool relative)
 Sets Positioning-Type Default is false. More...
 
void setRolloff (float rolloff)
 Sets the AL_ROLEOFF_FACTOR. More...
 
void setSoundClip (SoundClipPtr soundclip)
 Sets the sound clip to be used by this emitter. More...
 
SoundClipPtr getSoundClip ()
 Get the current sound clip used by this emitter. More...
 
void setCallback (const type_callback &cb)
 Sets the callback to use when the STREAM has finished being played. More...
 
void reset (bool defaultall=false)
 Reset the emitter, free all internal buffers. More...
 
void release ()
 Releases the emitter. More...
 
void setLooping (bool loop)
 Sets the playing mode. More...
 
void play ()
 Plays the associated audio file. More...
 
void stop ()
 Stops playing the audio file and rewinds to the beginning. More...
 
void pause ()
 Pauses playing the audio file. More...
 
void setGain (float gain)
 Sets the gain of the emitter. More...
 
float getGain ()
 Returns the gain of the emitter. More...
 
bool isStereo ()
 Tests if the audio data is stereo data or mono. More...
 
int16_t getBitResolution ()
 Returns the bit resolution. More...
 
uint64_t getSampleRate ()
 Returns the sample rate. More...
 
uint64_t getDecodedLength ()
 Returns the length of the decoded length in bytes. More...
 
uint64_t getDuration ()
 Returns the duration of the sound clip in milliseconds. More...
 
void setCursor (SoundPositionType type, float value)
 Sets the cursor position in the audio file. More...
 
float getCursor (SoundPositionType type)
 Returns the cursor position in the audio file. More...
 
void setPosition (float x, float y, float z)
 Sets the position of the SoundEmitter in the virtual audio space. More...
 
void setVelocity (float x, float y, float z)
 Sets the velocity of the SoundEmitter in the virtual audio space. More...
 

Private Member Functions

virtual void updateEvent (uint32_t time)
 Implementation of the pure virtual function from TimeEvent to update streaming. More...
 
void attachSoundClip ()
 Internal function to attach a soundclip to the source. More...
 
- Private Member Functions inherited from FIFE::TimeEvent
 TimeEvent (int32_t period=-1)
 Default constructor. More...
 
virtual ~TimeEvent ()
 Destructor. More...
 
void managerUpdateEvent (uint32_t time)
 Called by TimeManager to update the event. More...
 
void setPeriod (int32_t period)
 Set the period of the event. More...
 
int32_t getPeriod ()
 Get the period of the event. More...
 
uint32_t getLastUpdateTime ()
 Get the last time the event was updated. More...
 
void setLastUpdateTime (uint32_t ms)
 Set the last time the event was updated. More...
 

Private Attributes

SoundManagerm_manager
 
ALuint m_source
 
SoundClipPtr m_soundclip
 
uint32_t m_soundclipid
 
uint32_t m_streamid
 
uint32_t m_emitterid
 
bool m_loop
 
type_callback m_callback
 

Detailed Description

The class for playing audio files.

Definition at line 46 of file soundemitter.h.

Member Typedef Documentation

typedef boost::function0<void> FIFE::SoundEmitter::type_callback

Definition at line 48 of file soundemitter.h.

Constructor & Destructor Documentation

Member Function Documentation

void FIFE::SoundEmitter::attachSoundClip ( )
private
int16_t FIFE::SoundEmitter::getBitResolution ( )
inline

Returns the bit resolution.

Definition at line 155 of file soundemitter.h.

References FIFE::SoundDecoder::getBitResolution(), FIFE::SoundClip::getDecoder(), and m_soundclip.

Referenced by getDuration().

+ Here is the caller graph for this function:

float FIFE::SoundEmitter::getCursor ( SoundPositionType  type)
uint64_t FIFE::SoundEmitter::getDecodedLength ( )
inline

Returns the length of the decoded length in bytes.

Definition at line 173 of file soundemitter.h.

References FIFE::SoundDecoder::getDecodedLength(), FIFE::SoundClip::getDecoder(), and m_soundclip.

Referenced by getDuration().

+ Here is the caller graph for this function:

uint64_t FIFE::SoundEmitter::getDuration ( )
inline

Returns the duration of the sound clip in milliseconds.

Definition at line 183 of file soundemitter.h.

References getBitResolution(), getDecodedLength(), getSampleRate(), isStereo(), and m_soundclip.

float FIFE::SoundEmitter::getGain ( )
inline

Returns the gain of the emitter.

Returns
The gain value. 0=silence ... 1.0=normal loudness.

Definition at line 136 of file soundemitter.h.

References m_source.

uint32_t FIFE::SoundEmitter::getId ( ) const
inline

Returns the emitter-id.

Definition at line 55 of file soundemitter.h.

References m_emitterid.

uint64_t FIFE::SoundEmitter::getSampleRate ( )
inline

Returns the sample rate.

Definition at line 164 of file soundemitter.h.

References FIFE::SoundClip::getDecoder(), FIFE::SoundDecoder::getSampleRate(), and m_soundclip.

Referenced by getDuration().

+ Here is the caller graph for this function:

SoundClipPtr FIFE::SoundEmitter::getSoundClip ( )
inline

Get the current sound clip used by this emitter.

Returns
A SoundClipPtr of the sound clip.

Definition at line 85 of file soundemitter.h.

References m_soundclip.

bool FIFE::SoundEmitter::isStereo ( )
inline

Tests if the audio data is stereo data or mono.

Returns
Returns true if the audio data is stereo, false if mono.

Definition at line 146 of file soundemitter.h.

References FIFE::SoundClip::getDecoder(), FIFE::SoundDecoder::isStereo(), and m_soundclip.

Referenced by getDuration().

+ Here is the caller graph for this function:

void FIFE::SoundEmitter::pause ( )
inline

Pauses playing the audio file.

Definition at line 118 of file soundemitter.h.

References m_soundclip, and m_source.

void FIFE::SoundEmitter::play ( )

Plays the associated audio file.

Definition at line 175 of file soundemitter.cpp.

References FIFE::SoundClip::isStream(), m_soundclip, m_source, and FIFE::TimeEvent::setPeriod().

void FIFE::SoundEmitter::release ( )

Releases the emitter.

Definition at line 94 of file soundemitter.cpp.

References m_emitterid, m_manager, and FIFE::SoundManager::releaseEmitter().

void FIFE::SoundEmitter::reset ( bool  defaultall = false)

Reset the emitter, free all internal buffers.

Parameters
defaultallIf set to true, emitter position, velocity, gain and type will be set to the default values

Definition at line 65 of file soundemitter.cpp.

References FIFE::SoundClip::isStream(), m_soundclip, m_source, m_streamid, FIFE::SoundClip::quitStreaming(), FIFE::SharedPtr< T >::reset(), setGain(), FIFE::TimeEvent::setPeriod(), setPosition(), setPositioning(), and setVelocity().

Referenced by ~SoundEmitter().

+ Here is the caller graph for this function:

void FIFE::SoundEmitter::setCallback ( const type_callback cb)

Sets the callback to use when the STREAM has finished being played.

NOTE: This only works with streaming audio.

Parameters
cbfunction callback

Definition at line 105 of file soundemitter.cpp.

References m_callback.

void FIFE::SoundEmitter::setCursor ( SoundPositionType  type,
float  value 
)
void FIFE::SoundEmitter::setGain ( float  gain)
inline

Sets the gain of the emitter.

Parameters
gainThe gain value. 0=silence ... 1.0=normal loudness.

Definition at line 128 of file soundemitter.h.

References m_source.

Referenced by reset().

+ Here is the caller graph for this function:

void FIFE::SoundEmitter::setLooping ( bool  loop)

Sets the playing mode.

Definition at line 164 of file soundemitter.cpp.

References FIFE::SoundClip::isStream(), m_loop, m_soundclip, and m_source.

void FIFE::SoundEmitter::setPosition ( float  x,
float  y,
float  z 
)
inline

Sets the position of the SoundEmitter in the virtual audio space.

Definition at line 206 of file soundemitter.h.

References m_source.

Referenced by reset().

+ Here is the caller graph for this function:

void FIFE::SoundEmitter::setPositioning ( bool  relative)
inline

Sets Positioning-Type Default is false.

Parameters
relativeIf set to true, the emitters position will be interpreted relative to the listener object

Definition at line 65 of file soundemitter.h.

References m_source.

Referenced by reset().

+ Here is the caller graph for this function:

void FIFE::SoundEmitter::setRolloff ( float  rolloff)
inline

Sets the AL_ROLEOFF_FACTOR.

Rolloff factor judges the strength of attenuation over distance.

Parameters
rolloffRolloff factor. You'll need to do a lot of testing to find a value which suits your needs.

Definition at line 73 of file soundemitter.h.

References m_source.

void FIFE::SoundEmitter::setSoundClip ( SoundClipPtr  soundclip)

Sets the sound clip to be used by this emitter.

Parameters
soundclipSoundClipPtr of the sound to be used.

Definition at line 98 of file soundemitter.cpp.

References attachSoundClip(), FIFE::IResource::getHandle(), m_soundclip, and m_soundclipid.

void FIFE::SoundEmitter::setVelocity ( float  x,
float  y,
float  z 
)
inline

Sets the velocity of the SoundEmitter in the virtual audio space.

Definition at line 212 of file soundemitter.h.

References m_source.

Referenced by reset().

+ Here is the caller graph for this function:

void FIFE::SoundEmitter::stop ( )

Stops playing the audio file and rewinds to the beginning.

Definition at line 184 of file soundemitter.cpp.

References FIFE::SoundClip::isStream(), m_soundclip, m_source, FIFE::SD_BYTE_POS, setCursor(), and FIFE::TimeEvent::setPeriod().

void FIFE::SoundEmitter::updateEvent ( uint32_t  time)
privatevirtual

Member Data Documentation

type_callback FIFE::SoundEmitter::m_callback
private

Definition at line 232 of file soundemitter.h.

Referenced by setCallback(), and updateEvent().

uint32_t FIFE::SoundEmitter::m_emitterid
private

Definition at line 230 of file soundemitter.h.

Referenced by getId(), and release().

bool FIFE::SoundEmitter::m_loop
private

Definition at line 231 of file soundemitter.h.

Referenced by attachSoundClip(), setLooping(), and updateEvent().

SoundManager* FIFE::SoundEmitter::m_manager
private

Definition at line 225 of file soundemitter.h.

Referenced by release(), SoundEmitter(), and ~SoundEmitter().

uint32_t FIFE::SoundEmitter::m_soundclipid
private

Definition at line 228 of file soundemitter.h.

Referenced by setSoundClip().

uint32_t FIFE::SoundEmitter::m_streamid
private

Definition at line 229 of file soundemitter.h.

Referenced by attachSoundClip(), getCursor(), reset(), setCursor(), and updateEvent().


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