zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Zeni::Sound_Source Class Reference

Plays Sound Data. More...

#include <Sound_Source.h>

Public Member Functions

 Sound_Source ()
 
 Sound_Source (const Sound_Buffer &buffer, const float &pitch=ZENI_DEFAULT_PITCH, const float &gain=ZENI_DEFAULT_GAIN, const Point3f &position=Point3f(), const Vector3f &velocity=Vector3f(), const bool &looping=false)
 
 ~Sound_Source ()
 
float calculate_gain (const Point3f &listener_position) const
 Get the actual volume gain, given gain+position+near_clamp+far_clamp+rolloff. More...
 
const Sound_Bufferget_buffer () const
 Get the Sound_Buffer's OpenAL id. More...
 
float get_duration () const
 Get the duration of the Sound_Buffer in seconds. More...
 
float get_gain () const
 Get the gain. More...
 
float get_max_distance () const
 
float get_pitch () const
 Get the pitch. More...
 
Point3f get_position () const
 Get the position of the Sound_Buffer. More...
 
int get_priority () const
 Get the Sound_Source's priority. More...
 
float get_reference_distance () const
 
float get_rolloff () const
 
float get_time () const
 Get the current position in the Sound_Buffer, offset in seconds. More...
 
Time_HQ get_unstop_time () const
 Get the Time_HQ at which the Sound_Source was most recently played or unpaused. More...
 
Vector3f get_velocity () const
 Get the velocity of the Sound_Buffer. More...
 
bool is_assigned () const
 Check to see if the Sound_Source is assigned to actual hardware. More...
 
bool is_looping () const
 Check to see if the Sound_Buffer is set to loop back to the start once it is done playing. More...
 
bool is_paused () const
 Check to see if the Sound_Source is paused. More...
 
bool is_playing () const
 Check to see if the Sound_Source is playing. More...
 
bool is_stopped () const
 Check to see if the Sound_Source is stopped. More...
 
void pause ()
 Pause the Sound_Source. More...
 
void play ()
 Begin playing or unpause the Sound_Source. More...
 
void set_buffer (const Sound_Buffer &buffer)
 Set the Sound_Buffer to be played. More...
 
void set_gain (const float &gain=ZENI_DEFAULT_GAIN)
 Set the gain. More...
 
void set_looping (const bool &looping)
 Set whether the Sound_Buffer should loop back to the start once it is done playing. More...
 
void set_max_distance (const float &max_distance=ZENI_DEFAULT_MAX_SOUND_DISTANCE)
 
void set_pitch (const float &pitch=ZENI_DEFAULT_PITCH)
 Set the pitch. More...
 
void set_position (const Point3f &position)
 Set the position of the Sound_Source. More...
 
void set_priority (const int &priority=ZENI_DEFAULT_SOUND_PRIORITY)
 Set the priority that this Sound_Source should have. Higher numbers are more likely to be selected for play. More...
 
void set_reference_distance (const float &reference_distance=ZENI_DEFAULT_REFERENCE_DISTANCE)
 
void set_rolloff (const float &rolloff=ZENI_DEFAULT_ROLLOFF)
 
void set_time (const float &time)
 Set the current position in the Sound_Buffer, offset in seconds. More...
 
void set_velocity (const Vector3f &velocity)
 Set the velocity of the Sound_Source for the doppler effect. More...
 
void stop ()
 Stop the Sound_Source. (Essentially the same as pause but resets the current time.) More...
 

Friends

class Sound_Source_Pool
 

Detailed Description

Plays Sound Data.

A Sound_Source plays sound data from a Sound_Buffer. The term comes from the idea that OpenAL is built for 3D positional sound. A Sound_Source is defined by the Sound_Buffer it is playing as well as its position, velocity, and several other factors.

Author
bazald

Contact: bazal.nosp@m.d@ze.nosp@m.nipex.nosp@m..com

Definition at line 147 of file Sound_Source.h.

Constructor & Destructor Documentation

Zeni::Sound_Source::Sound_Source ( )

Definition at line 529 of file Sound_Source.cpp.

References Zeni::get_Sound_Source_Pool().

Zeni::Sound_Source::Sound_Source ( const Sound_Buffer buffer,
const float &  pitch = ZENI_DEFAULT_PITCH,
const float &  gain = ZENI_DEFAULT_GAIN,
const Point3f position = Point3f(),
const Vector3f velocity = Vector3f(),
const bool &  looping = false 
)

Definition at line 549 of file Sound_Source.cpp.

References Zeni::get_Sound_Source_Pool().

Zeni::Sound_Source::~Sound_Source ( )

Definition at line 576 of file Sound_Source.cpp.

References Zeni::get_Sound_Source_Pool().

Member Function Documentation

float Zeni::Sound_Source::calculate_gain ( const Point3f listener_position) const

Get the actual volume gain, given gain+position+near_clamp+far_clamp+rolloff.

Definition at line 611 of file Sound_Source.cpp.

References max, and min.

Referenced by Zeni::Sound_Source_Pool::Positional_Replacement_Policy::operator()().

const Sound_Buffer & Zeni::Sound_Source::get_buffer ( ) const
inline

Get the Sound_Buffer's OpenAL id.

Definition at line 62 of file Sound_Source.hxx.

References assert.

float Zeni::Sound_Source::get_duration ( ) const
inline

Get the duration of the Sound_Buffer in seconds.

Definition at line 63 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::get_duration().

Referenced by get_time().

float Zeni::Sound_Source::get_gain ( ) const
inline

Get the gain.

Definition at line 65 of file Sound_Source.hxx.

Referenced by Zeni::Sound_Source_Pool::Replacement_Policy::operator()().

float Zeni::Sound_Source::get_max_distance ( ) const
inline

Definition at line 70 of file Sound_Source.hxx.

float Zeni::Sound_Source::get_pitch ( ) const
inline

Get the pitch.

Definition at line 64 of file Sound_Source.hxx.

Point3f Zeni::Sound_Source::get_position ( ) const
inline

Get the position of the Sound_Buffer.

Definition at line 66 of file Sound_Source.hxx.

int Zeni::Sound_Source::get_priority ( ) const
inline
float Zeni::Sound_Source::get_reference_distance ( ) const
inline

Definition at line 69 of file Sound_Source.hxx.

float Zeni::Sound_Source::get_rolloff ( ) const
inline

Definition at line 71 of file Sound_Source.hxx.

float Zeni::Sound_Source::get_time ( ) const

Get the current position in the Sound_Buffer, offset in seconds.

Definition at line 581 of file Sound_Source.cpp.

References get_duration(), Zeni::Time_HQ::get_seconds_since(), and Zeni::Sound_Source_HW::get_time().

Time_HQ Zeni::Sound_Source::get_unstop_time ( ) const
inline

Get the Time_HQ at which the Sound_Source was most recently played or unpaused.

Definition at line 61 of file Sound_Source.hxx.

Referenced by Zeni::Sound_Source_Pool::Replacement_Policy::operator()(), and Zeni::Sound_Source_Pool::Positional_Replacement_Policy::operator()().

Vector3f Zeni::Sound_Source::get_velocity ( ) const
inline

Get the velocity of the Sound_Buffer.

Definition at line 67 of file Sound_Source.hxx.

bool Zeni::Sound_Source::is_assigned ( ) const
inline

Check to see if the Sound_Source is assigned to actual hardware.

Definition at line 81 of file Sound_Source.hxx.

Referenced by Zeni::Sound_Source_Pool::update().

bool Zeni::Sound_Source::is_looping ( ) const
inline

Check to see if the Sound_Buffer is set to loop back to the start once it is done playing.

Definition at line 68 of file Sound_Source.hxx.

bool Zeni::Sound_Source::is_paused ( ) const
inline

Check to see if the Sound_Source is paused.

Definition at line 78 of file Sound_Source.hxx.

bool Zeni::Sound_Source::is_playing ( ) const
inline
bool Zeni::Sound_Source::is_stopped ( ) const
inline

Check to see if the Sound_Source is stopped.

Definition at line 79 of file Sound_Source.hxx.

void Zeni::Sound_Source::pause ( )
inline
void Zeni::Sound_Source::play ( )
inline

Begin playing or unpause the Sound_Source.

Definition at line 73 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::play(), Zeni::Sound_Source_HW::PLAYING, and Zeni::Time_HQ::update().

Referenced by Zeni::Sound::set_BGM().

void Zeni::Sound_Source::set_buffer ( const Sound_Buffer buffer)
inline

Set the Sound_Buffer to be played.

Definition at line 40 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_buffer().

Referenced by Zeni::Sound::set_BGM().

void Zeni::Sound_Source::set_gain ( const float &  gain = ZENI_DEFAULT_GAIN)
inline

Set the gain.

Definition at line 42 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_gain().

void Zeni::Sound_Source::set_looping ( const bool &  looping)
inline

Set whether the Sound_Buffer should loop back to the start once it is done playing.

Definition at line 45 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_looping().

void Zeni::Sound_Source::set_max_distance ( const float &  max_distance = ZENI_DEFAULT_MAX_SOUND_DISTANCE)
inline

Definition at line 57 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_max_distance().

void Zeni::Sound_Source::set_pitch ( const float &  pitch = ZENI_DEFAULT_PITCH)
inline

Set the pitch.

Definition at line 41 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_pitch().

void Zeni::Sound_Source::set_position ( const Point3f position)
inline

Set the position of the Sound_Source.

Definition at line 43 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_position().

void Zeni::Sound_Source::set_priority ( const int priority = ZENI_DEFAULT_SOUND_PRIORITY)
inline

Set the priority that this Sound_Source should have. Higher numbers are more likely to be selected for play.

Definition at line 39 of file Sound_Source.hxx.

void Zeni::Sound_Source::set_reference_distance ( const float &  reference_distance = ZENI_DEFAULT_REFERENCE_DISTANCE)
inline

Definition at line 56 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_reference_distance().

void Zeni::Sound_Source::set_rolloff ( const float &  rolloff = ZENI_DEFAULT_ROLLOFF)
inline

Definition at line 58 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_rolloff().

void Zeni::Sound_Source::set_time ( const float &  time)
inline

Set the current position in the Sound_Buffer, offset in seconds.

Definition at line 47 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_time(), and Zeni::Time_HQ::update().

Referenced by Zeni::Sound::set_BGM().

void Zeni::Sound_Source::set_velocity ( const Vector3f velocity)
inline

Set the velocity of the Sound_Source for the doppler effect.

Definition at line 44 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::set_velocity().

void Zeni::Sound_Source::stop ( )
inline

Stop the Sound_Source. (Essentially the same as pause but resets the current time.)

Definition at line 75 of file Sound_Source.hxx.

References Zeni::Sound_Source_HW::stop(), and Zeni::Sound_Source_HW::STOPPED.

Referenced by Zeni::Sound::set_BGM().

Friends And Related Function Documentation

friend class Sound_Source_Pool
friend

Definition at line 148 of file Sound_Source.h.


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