OpenALSoundSource Class Reference

#include <openal_sound_source.hpp>

Inherits SoundSource.

Inherited by StreamSoundSource.

List of all members.

Public Member Functions

 OpenALSoundSource ()
virtual ~OpenALSoundSource ()
virtual void play ()
virtual void stop ()
virtual bool playing ()
virtual void update ()
virtual void set_looping (bool looping)
virtual void set_relative (bool relative)
virtual void set_gain (float gain)
 Set volume (0.0 is silent, 1.0 is normal).
virtual void set_pitch (float pitch)
virtual void set_position (const Vector &position)
virtual void set_velocity (const Vector &position)
virtual void set_reference_distance (float distance)

Protected Attributes

ALuint source

Friends

class SoundManager


Detailed Description

Definition at line 24 of file openal_sound_source.hpp.


Constructor & Destructor Documentation

OpenALSoundSource::OpenALSoundSource (  ) 

Definition at line 20 of file openal_sound_source.cpp.

References SoundManager::check_al_error(), set_reference_distance(), and source.

00020                                      :
00021   source()
00022 {
00023   alGenSources(1, &source);
00024   SoundManager::check_al_error("Couldn't create audio source: ");
00025   set_reference_distance(128);
00026 }

OpenALSoundSource::~OpenALSoundSource (  )  [virtual]

Definition at line 28 of file openal_sound_source.cpp.

References source, and stop().

00029 {
00030   stop();
00031   alDeleteSources(1, &source);
00032 }


Member Function Documentation

void OpenALSoundSource::play (  )  [virtual]

Implements SoundSource.

Definition at line 43 of file openal_sound_source.cpp.

References SoundManager::check_al_error(), and source.

Referenced by StreamSoundSource::update().

00044 {
00045   alSourcePlay(source);
00046   SoundManager::check_al_error("Couldn't start audio source: ");
00047 }

void OpenALSoundSource::stop (  )  [virtual]

Implements SoundSource.

Definition at line 35 of file openal_sound_source.cpp.

References SoundManager::check_al_error(), and source.

Referenced by StreamSoundSource::update(), ~OpenALSoundSource(), and StreamSoundSource::~StreamSoundSource().

00036 {
00037   alSourceStop(source);
00038   alSourcei(source, AL_BUFFER, AL_NONE);
00039   SoundManager::check_al_error("Problem stopping audio source: ");
00040 }

bool OpenALSoundSource::playing (  )  [virtual]

Implements SoundSource.

Definition at line 50 of file openal_sound_source.cpp.

References source.

Referenced by StreamSoundSource::update().

00051 {
00052   ALint state = AL_PLAYING;
00053   alGetSourcei(source, AL_SOURCE_STATE, &state);
00054   return state != AL_STOPPED;
00055 }

void OpenALSoundSource::update (  )  [virtual]

Reimplemented in StreamSoundSource.

Definition at line 58 of file openal_sound_source.cpp.

00059 {
00060 }

void OpenALSoundSource::set_looping ( bool  looping  )  [virtual]

Implements SoundSource.

Reimplemented in StreamSoundSource.

Definition at line 63 of file openal_sound_source.cpp.

References source.

00064 {
00065   alSourcei(source, AL_LOOPING, looping ? AL_TRUE : AL_FALSE);
00066 }

void OpenALSoundSource::set_relative ( bool  relative  )  [virtual]

Implements SoundSource.

Definition at line 69 of file openal_sound_source.cpp.

References source.

00070 {
00071   alSourcei(source, AL_SOURCE_RELATIVE, relative ? AL_TRUE : AL_FALSE);
00072 }

void OpenALSoundSource::set_gain ( float  gain  )  [virtual]

Set volume (0.0 is silent, 1.0 is normal).

Implements SoundSource.

Definition at line 87 of file openal_sound_source.cpp.

References source.

Referenced by StreamSoundSource::update().

00088 {
00089   alSourcef(source, AL_GAIN, gain);
00090 }

void OpenALSoundSource::set_pitch ( float  pitch  )  [virtual]

Implements SoundSource.

Definition at line 93 of file openal_sound_source.cpp.

References source.

00094 {
00095   alSourcef(source, AL_PITCH, pitch);
00096 }

void OpenALSoundSource::set_position ( const Vector position  )  [virtual]

Implements SoundSource.

Definition at line 75 of file openal_sound_source.cpp.

References source, Vector::x, and Vector::y.

00076 {
00077   alSource3f(source, AL_POSITION, position.x, position.y, 0);
00078 }

void OpenALSoundSource::set_velocity ( const Vector position  )  [virtual]

Implements SoundSource.

Definition at line 81 of file openal_sound_source.cpp.

References source, Vector::x, and Vector::y.

00082 {
00083   alSource3f(source, AL_VELOCITY, velocity.x, velocity.y, 0);
00084 }

void OpenALSoundSource::set_reference_distance ( float  distance  )  [virtual]

Implements SoundSource.

Definition at line 99 of file openal_sound_source.cpp.

References source.

Referenced by OpenALSoundSource().

00100 {
00101   alSourcef(source, AL_REFERENCE_DISTANCE, distance);
00102 }


Friends And Related Function Documentation

friend class SoundManager [friend]

Definition at line 45 of file openal_sound_source.hpp.


Member Data Documentation

ALuint OpenALSoundSource::source [protected]

Definition at line 47 of file openal_sound_source.hpp.

Referenced by StreamSoundSource::fillBufferAndQueue(), OpenALSoundSource(), play(), playing(), set_gain(), set_looping(), set_pitch(), set_position(), set_reference_distance(), set_relative(), StreamSoundSource::set_sound_file(), set_velocity(), stop(), StreamSoundSource::update(), and ~OpenALSoundSource().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:33 2014 for SuperTux by  doxygen 1.5.1