Engine::SoundInstance Class Reference

A sound heard by a SoundListener because of a SoundSource. More...

#include <Audio.h>

List of all members.

Public Member Functions

 SoundInstance (ALuint buffer)
 Create associating with an OpenAL buffer object's name.
ALuint get_buffer ()
 Return the buffer name given on creation.
bool get_assigned ()
 return true if an ALSoundSource is being used.
unsigned int get_index ()
 Get the index value passed when assigned.
void assign (ALSoundSource &source, unsigned int index)
 Use an ALSoundSource.
void unassign ()
 Stop using an ALSoundSource.
void set_gain (ALfloat gain)
 Set how loud the sound should be played.
ALfloat get_gain ()
 return the gain set by set_gain()
void set_pitch (ALfloat pitch)
 Set the scale for the pitch of the sound (1 is normal).
void set_position (btVector3 position)
 Set the position of the sound relative to the viewer.
void set_looping (bool looping=true)
 Set whether the sound should repeat continuosly.
bool get_looping ()
 Return true iff the sound should repeat continuosly.
void play ()
 Play the sound.
void stop ()
 Stop the sound from playing.
bool get_playing ()
 Return true iff the sound is playing.
void update_al ()
 Update the assigned ALSoundSource.

Private Attributes

ALSoundSourcem_source
unsigned int m_source_index
ALuint m_buffer
ALfloat m_gain
ALfloat m_pitch
btVector3 m_position
bool m_looping
bool m_playing
bool m_assigning


Detailed Description

A sound heard by a SoundListener because of a SoundSource.

May or may not be actually played. Only the most audioable sounds are fed into OpenAL. The less audiable ones are ignored for performance reasons.

Definition at line 218 of file Audio.h.


Constructor & Destructor Documentation

Engine::SoundInstance::SoundInstance ( ALuint  buffer  ) 

Create associating with an OpenAL buffer object's name.

Definition at line 468 of file Audio.cpp.


Member Function Documentation

void Engine::SoundInstance::assign ( ALSoundSource source,
unsigned int  index 
)

Use an ALSoundSource.

After this, the ALSoundSource is not assigned to any SoundInstance it was assigned to before. This will make the sound actually audiable.

Definition at line 490 of file Audio.cpp.

bool Engine::SoundInstance::get_assigned (  ) 

return true if an ALSoundSource is being used.

Definition at line 480 of file Audio.cpp.

ALuint Engine::SoundInstance::get_buffer (  ) 

Return the buffer name given on creation.

Definition at line 485 of file Audio.cpp.

ALfloat Engine::SoundInstance::get_gain (  ) 

return the gain set by set_gain()

Definition at line 511 of file Audio.cpp.

unsigned int Engine::SoundInstance::get_index (  ) 

Get the index value passed when assigned.

Definition at line 580 of file Audio.cpp.

bool Engine::SoundInstance::get_looping (  ) 

Return true iff the sound should repeat continuosly.

Definition at line 427 of file Audio.cpp.

bool Engine::SoundInstance::get_playing (  ) 

Return true iff the sound is playing.

Definition at line 542 of file Audio.cpp.

void Engine::SoundInstance::play (  ) 

Play the sound.

Definition at line 532 of file Audio.cpp.

void Engine::SoundInstance::set_gain ( ALfloat  gain  ) 

Set how loud the sound should be played.

1 is normal volume, 0.5 is -6dB, 0.25 is -25dB, etc. 0 is silent.

Definition at line 506 of file Audio.cpp.

void Engine::SoundInstance::set_looping ( bool  looping = true  ) 

Set whether the sound should repeat continuosly.

A looping sound source can be assigned an ALSoundSource at any time. A sound source which doesn't loop that could not be assigned an ALSoundSource will never be heard. The looping value shouldn't be changed while playing and attached to a ALSoundSource. You can call this function with the previous state again though, it will just do nothing.

Definition at line 526 of file Audio.cpp.

void Engine::SoundInstance::set_pitch ( ALfloat  pitch  ) 

Set the scale for the pitch of the sound (1 is normal).

Definition at line 516 of file Audio.cpp.

void Engine::SoundInstance::set_position ( btVector3  position  ) 

Set the position of the sound relative to the viewer.

Definition at line 521 of file Audio.cpp.

void Engine::SoundInstance::stop (  ) 

Stop the sound from playing.

Definition at line 537 of file Audio.cpp.

void Engine::SoundInstance::unassign (  ) 

Stop using an ALSoundSource.

Definition at line 501 of file Audio.cpp.

void Engine::SoundInstance::update_al (  ) 

Update the assigned ALSoundSource.

Definition at line 547 of file Audio.cpp.


Member Data Documentation

bool Engine::SoundInstance::m_assigning [private]

Definition at line 279 of file Audio.h.

ALuint Engine::SoundInstance::m_buffer [private]

Definition at line 273 of file Audio.h.

ALfloat Engine::SoundInstance::m_gain [private]

Definition at line 274 of file Audio.h.

bool Engine::SoundInstance::m_looping [private]

Definition at line 277 of file Audio.h.

ALfloat Engine::SoundInstance::m_pitch [private]

Definition at line 275 of file Audio.h.

bool Engine::SoundInstance::m_playing [private]

Definition at line 278 of file Audio.h.

btVector3 Engine::SoundInstance::m_position [private]

Definition at line 276 of file Audio.h.

ALSoundSource* Engine::SoundInstance::m_source [private]

Definition at line 271 of file Audio.h.

unsigned int Engine::SoundInstance::m_source_index [private]

Definition at line 272 of file Audio.h.


The documentation for this class was generated from the following files:
Get Racer at SourceForge.net. Fast, secure and Free Open Source software downloads

Generated at Mon Sep 6 00:41:17 2010 by Doxygen version 1.4.7 for Racer version svn335.