FIFE
|
The class for playing audio files. More...
#include <soundemitter.h>
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... | |
![]() | |
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 | |
SoundManager * | m_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 |
The class for playing audio files.
Definition at line 46 of file soundemitter.h.
typedef boost::function0<void> FIFE::SoundEmitter::type_callback |
Definition at line 48 of file soundemitter.h.
FIFE::SoundEmitter::SoundEmitter | ( | SoundManager * | manager, |
uint32_t | uid | ||
) |
Definition at line 42 of file soundemitter.cpp.
References FIFE::_log, CHECK_OPENAL_LOG, FIFE::DynamicSingleton< TimeManager >::instance(), FIFE::SoundManager::isActive(), FIFE::LogManager::LEVEL_ERROR, m_manager, m_source, FIFE::TimeManager::registerEvent(), and FIFE::TimeEvent::setPeriod().
FIFE::SoundEmitter::~SoundEmitter | ( | ) |
Definition at line 54 of file soundemitter.cpp.
References FIFE::DynamicSingleton< TimeManager >::instance(), FIFE::SoundManager::isActive(), m_manager, m_source, reset(), FIFE::TimeEvent::setPeriod(), and FIFE::TimeManager::unregisterEvent().
|
private |
Internal function to attach a soundclip to the source.
Definition at line 109 of file soundemitter.cpp.
References FIFE::_log, FIFE::SoundClip::acquireStream(), FIFE::SoundClip::beginStreaming(), FIFE::BUFFER_NUM, CHECK_OPENAL_LOG, FIFE::SoundClip::countBuffers(), FIFE::SoundClip::getBuffers(), FIFE::SoundClip::isStream(), FIFE::LogManager::LEVEL_ERROR, m_loop, m_soundclip, m_source, and m_streamid.
Referenced by setSoundClip().
|
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().
float FIFE::SoundEmitter::getCursor | ( | SoundPositionType | type | ) |
Returns the cursor position in the audio file.
Definition at line 245 of file soundemitter.cpp.
References FIFE::_log, CHECK_OPENAL_LOG, FIFE::SoundClip::getStreamPos(), FIFE::SoundClip::isStream(), FIFE::LogManager::LEVEL_ERROR, m_soundclip, m_source, m_streamid, FIFE::SD_BYTE_POS, FIFE::SD_SAMPLE_POS, and FIFE::SD_TIME_POS.
|
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().
|
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.
|
inline |
Returns the gain of the emitter.
Definition at line 136 of file soundemitter.h.
References m_source.
|
inline |
|
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().
|
inline |
Get the current sound clip used by this emitter.
Definition at line 85 of file soundemitter.h.
References m_soundclip.
|
inline |
Tests if the audio data is stereo data or mono.
Definition at line 146 of file soundemitter.h.
References FIFE::SoundClip::getDecoder(), FIFE::SoundDecoder::isStereo(), and m_soundclip.
Referenced by getDuration().
|
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.
defaultall | If 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().
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.
cb | function callback |
Definition at line 105 of file soundemitter.cpp.
References m_callback.
void FIFE::SoundEmitter::setCursor | ( | SoundPositionType | type, |
float | value | ||
) |
Sets the cursor position in the audio file.
Definition at line 197 of file soundemitter.cpp.
References FIFE::_log, FIFE::SoundClip::acquireStream(), FIFE::BUFFER_NUM, CHECK_OPENAL_LOG, FIFE::SoundClip::getBuffers(), FIFE::SoundClip::isStream(), FIFE::LogManager::LEVEL_ERROR, m_soundclip, m_source, m_streamid, FIFE::SD_BYTE_POS, FIFE::SD_SAMPLE_POS, FIFE::SD_TIME_POS, FIFE::TimeEvent::setPeriod(), and FIFE::SoundClip::setStreamPos().
Referenced by stop().
|
inline |
Sets the gain of the emitter.
gain | The gain value. 0=silence ... 1.0=normal loudness. |
Definition at line 128 of file soundemitter.h.
References m_source.
Referenced by reset().
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.
|
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().
|
inline |
Sets Positioning-Type Default is false.
relative | If 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().
|
inline |
Sets the AL_ROLEOFF_FACTOR.
Rolloff factor judges the strength of attenuation over distance.
rolloff | Rolloff 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.
soundclip | SoundClipPtr of the sound to be used. |
Definition at line 98 of file soundemitter.cpp.
References attachSoundClip(), FIFE::IResource::getHandle(), m_soundclip, and m_soundclipid.
|
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().
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().
|
privatevirtual |
Implementation of the pure virtual function from TimeEvent to update streaming.
Implements FIFE::TimeEvent.
Definition at line 128 of file soundemitter.cpp.
References FIFE::_log, CHECK_OPENAL_LOG, FIFE::SoundClip::getStream(), FIFE::LogManager::LEVEL_ERROR, m_callback, m_loop, m_soundclip, m_source, m_streamid, FIFE::SD_BYTE_POS, FIFE::TimeEvent::setPeriod(), and FIFE::SoundClip::setStreamPos().
|
private |
Definition at line 232 of file soundemitter.h.
Referenced by setCallback(), and updateEvent().
|
private |
Definition at line 230 of file soundemitter.h.
|
private |
Definition at line 231 of file soundemitter.h.
Referenced by attachSoundClip(), setLooping(), and updateEvent().
|
private |
Definition at line 225 of file soundemitter.h.
Referenced by release(), SoundEmitter(), and ~SoundEmitter().
|
private |
Definition at line 227 of file soundemitter.h.
Referenced by attachSoundClip(), getBitResolution(), getCursor(), getDecodedLength(), getDuration(), getSampleRate(), getSoundClip(), isStereo(), pause(), play(), reset(), setCursor(), setLooping(), setSoundClip(), stop(), and updateEvent().
|
private |
Definition at line 228 of file soundemitter.h.
Referenced by setSoundClip().
|
private |
Definition at line 226 of file soundemitter.h.
Referenced by attachSoundClip(), getCursor(), getGain(), pause(), play(), reset(), setCursor(), setGain(), setLooping(), setPosition(), setPositioning(), setRolloff(), setVelocity(), SoundEmitter(), stop(), updateEvent(), and ~SoundEmitter().
|
private |
Definition at line 229 of file soundemitter.h.
Referenced by attachSoundClip(), getCursor(), reset(), setCursor(), and updateEvent().