SGSoundSample Class Reference

manages everything we need to know for an individual audio sample More...

#include <sample_openal.hxx>

Inheritance diagram for SGSoundSample:
SGReferenced

List of all members.

Public Member Functions

 SGSoundSample ()
 Empty constructor, can be used to read data to the systems memory and not to the driver.
 SGSoundSample (const char *path, const char *file)
 Constructor.
 SGSoundSample (void **data, int len, int freq, int format=AL_FORMAT_MONO8)
 Constructor.
 ~SGSoundSample ()
 Destructor.
bool is_file () const
 Detect wheter this audio sample holds the information of a sound file.
bool has_changed ()
 Test if this audio sample configuration has changed since the last call.
bool has_static_data_changed ()
 Test if static dataa of audio sample configuration has changed.
void play (bool loop)
 Schedule this audio sample for playing.
bool is_looping ()
 Check if this audio sample is set to be continuous looping.
void stop ()
 Schedule this audio sample to stop playing.
void play_once ()
 Schedule this audio sample to play once.
void play_looped ()
 Schedule this audio sample to play looped.
bool is_playing ()
 Test if a audio sample is scheduled for playing.
void set_data (const unsigned char **data)
 Set the data associated with this audio sample.
void * get_data () const
 Return the data associated with this audio sample.
void free_data ()
 Free the data associated with this audio sample.
void set_source (unsigned int sid)
 Set the source id of this source.
unsigned int get_source ()
 Get the OpenAL source id of this source.
bool is_valid_source () const
 Test if the source-id of this audio sample may be passed to OpenAL.
void no_valid_source ()
 Set the source-id of this audio sample to invalid.
void set_buffer (unsigned int bid)
 Set the OpenAL buffer-id of this source.
unsigned int get_buffer ()
 Get the OpenAL buffer-id of this source.
bool is_valid_buffer () const
 Test if the buffer-id of this audio sample may be passed to OpenAL.
void no_valid_buffer ()
 Set the buffer-id of this audio sample to invalid.
void set_pitch (float p)
 Set the playback pitch of this audio sample.
float get_pitch ()
 Get the current pitch value of this audio sample.
void set_master_volume (float v)
 Set the master volume of this sample.
void set_volume (float v)
 Set the volume of this audio sample.
float get_volume ()
 Get the final volume value of this audio sample.
void set_format (int format)
 Set the OpenAL format of this audio sample.
int get_format ()
 Returns the format of this audio sample.
void set_frequency (int freq)
 Set the frequency (in Herz) of this audio sample.
int get_frequency ()
 Returns the frequency (in Herz) of this audio sample.
void set_size (size_t size)
 Sets the size (in bytes) of this audio sample.
size_t get_size () const
 Returns the size (in bytes) of this audio sample.
void set_relative_position (const SGVec3f &pos)
 Set the position of this sound relative to the base position.
void set_position (const SGVec3d &pos)
 Set the base position in Cartesian coordinates.
SGVec3dget_position ()
 Get the absolute position of this sound.
void set_orientation (const SGQuatd &ori)
 Set the orientation of this sound.
void set_direction (const SGVec3f &dir)
 Set direction of this sound relative to the orientation.
void set_audio_cone (float inner, float outer, float gain)
 Define the audio cone parameters for directional audio.
SGVec3fget_orientation ()
 Get the orientation vector of this sound.
float get_innerangle ()
 Get the inner angle of the audio cone.
float get_outerangle ()
 Get the outer angle of the audio cone.
float get_outergain ()
 Get the remaining gain at the edge of the outer cone.
void set_velocity (const SGVec3f &vel)
 Set the velocity vector (in meters per second) of this sound.
SGVec3fget_velocity ()
 Get velocity vector (in meters per second) of this sound.
void set_reference_dist (float dist)
 Set reference distance (in meters) of this sound.
float get_reference_dist ()
 Get reference distance ((in meters) of this sound.
void set_max_dist (float dist)
 Set maximum distance (in meters) of this sound.
float get_max_dist ()
 Get maximum distance (in meters) of this sound.
std::string get_sample_name () const
 Get the reference name of this audio sample.

Detailed Description

manages everything we need to know for an individual audio sample

Definition at line 51 of file sample_openal.hxx.


Constructor & Destructor Documentation

SGSoundSample::SGSoundSample ( const char *  path,
const char *  file 
)

Constructor.

Parameters:
path Path name to sound
file File name of sound Buffer data is freed by the sample group

Definition at line 80 of file sample_openal.cxx.

SGSoundSample::SGSoundSample ( void **  data,
int  len,
int  freq,
int  format = AL_FORMAT_MONO8 
)

Constructor.

Parameters:
data Pointer to a memory buffer containing this audio sample data The application may free the data by calling free_data(), otherwise it will be resident untill the class is destroyed. This pointer will be set to NULL after calling this function.
len Byte length of array
freq Frequency of the provided data (bytes per second)
format OpenAL format id of the data

Definition at line 157 of file sample_openal.cxx.


Member Function Documentation

unsigned int SGSoundSample::get_buffer (  )  [inline]

Get the OpenAL buffer-id of this source.

Returns:
OpenAL buffer-id

Definition at line 215 of file sample_openal.hxx.

void* SGSoundSample::get_data (  )  const [inline]

Return the data associated with this audio sample.

Returns:
A pointer to this sound data of this audio sample.

Definition at line 169 of file sample_openal.hxx.

int SGSoundSample::get_format (  )  [inline]

Returns the format of this audio sample.

Returns:
OpenAL format-id

Definition at line 282 of file sample_openal.hxx.

int SGSoundSample::get_frequency (  )  [inline]

Returns the frequency (in Herz) of this audio sample.

Returns:
Frequency

Definition at line 294 of file sample_openal.hxx.

float SGSoundSample::get_innerangle (  )  [inline]

Get the inner angle of the audio cone.

Returns:
Inner angle in degrees

Definition at line 376 of file sample_openal.hxx.

float SGSoundSample::get_max_dist (  )  [inline]

Get maximum distance (in meters) of this sound.

This is the distance where this sound is no longer audible.

Returns:
dist Maximum distance

Definition at line 438 of file sample_openal.hxx.

SGVec3f& SGSoundSample::get_orientation (  )  [inline]

Get the orientation vector of this sound.

This is in the same coordinate system as OpenGL; y=up, z=back, x=right

Returns:
Orientaton vector

Definition at line 370 of file sample_openal.hxx.

float SGSoundSample::get_outerangle (  )  [inline]

Get the outer angle of the audio cone.

Returns:
Outer angle in degrees

Definition at line 382 of file sample_openal.hxx.

float SGSoundSample::get_outergain (  )  [inline]

Get the remaining gain at the edge of the outer cone.

Returns:
Gain

Definition at line 388 of file sample_openal.hxx.

float SGSoundSample::get_pitch (  )  [inline]

Get the current pitch value of this audio sample.

Returns:
Pitch

Definition at line 242 of file sample_openal.hxx.

SGVec3d& SGSoundSample::get_position (  )  [inline]

Get the absolute position of this sound.

This is in the same coordinate system as OpenGL; y=up, z=back, x=right.

Returns:
Absolute position

Definition at line 330 of file sample_openal.hxx.

float SGSoundSample::get_reference_dist (  )  [inline]

Get reference distance ((in meters) of this sound.

This is the distance where the gain will be half.

Returns:
Reference distance

Definition at line 421 of file sample_openal.hxx.

std::string SGSoundSample::get_sample_name (  )  const [inline]

Get the reference name of this audio sample.

Returns:
Sample name

Definition at line 444 of file sample_openal.hxx.

size_t SGSoundSample::get_size (  )  const [inline]

Returns the size (in bytes) of this audio sample.

Returns:
Data size

Definition at line 306 of file sample_openal.hxx.

unsigned int SGSoundSample::get_source (  )  [inline]

Get the OpenAL source id of this source.

Returns:
OpenAL source-id

Definition at line 190 of file sample_openal.hxx.

SGVec3f& SGSoundSample::get_velocity (  )  [inline]

Get velocity vector (in meters per second) of this sound.

This is in the same coordinate system as OpenGL; y=up, z=back, x=right

Returns:
Velocity vector

Definition at line 404 of file sample_openal.hxx.

float SGSoundSample::get_volume (  )  [inline]

Get the final volume value of this audio sample.

Returns:
Volume

Definition at line 270 of file sample_openal.hxx.

bool SGSoundSample::has_changed (  )  [inline]

Test if this audio sample configuration has changed since the last call.

Calling this function will reset the flag so calling it a second time in a row will return false.

Returns:
Return true is the configuration has changed in the mean time.

Definition at line 99 of file sample_openal.hxx.

bool SGSoundSample::has_static_data_changed (  )  [inline]

Test if static dataa of audio sample configuration has changed.

Calling this function will reset the flag so calling it a second time in a row will return false.

Returns:
Return true is the static data has changed in the mean time.

Definition at line 109 of file sample_openal.hxx.

bool SGSoundSample::is_file (  )  const [inline]

Detect wheter this audio sample holds the information of a sound file.

Returns:
Return true if this audio sample is to be constructed from a file.

Definition at line 91 of file sample_openal.hxx.

bool SGSoundSample::is_looping (  )  [inline]

Check if this audio sample is set to be continuous looping.

Returns:
Return true if this audio sample is set to looping.

Definition at line 126 of file sample_openal.hxx.

bool SGSoundSample::is_playing (  )  [inline]

Test if a audio sample is scheduled for playing.

Returns:
true if this audio sample is playing, false otherwise.

Definition at line 151 of file sample_openal.hxx.

bool SGSoundSample::is_valid_buffer (  )  const [inline]

Test if the buffer-id of this audio sample may be passed to OpenAL.

Returns:
true if the buffer-id is valid

Definition at line 221 of file sample_openal.hxx.

bool SGSoundSample::is_valid_source (  )  const [inline]

Test if the source-id of this audio sample may be passed to OpenAL.

Returns:
true if the source-id is valid

Definition at line 196 of file sample_openal.hxx.

void SGSoundSample::play ( bool  loop  )  [inline]

Schedule this audio sample for playing.

Actual playing will only start at the next call op SoundGroup::update()

Parameters:
_loop Define whether this sound should be played in a loop.

Definition at line 118 of file sample_openal.hxx.

void SGSoundSample::play_looped (  )  [inline]

Schedule this audio sample to play looped.

See also:
play

Definition at line 145 of file sample_openal.hxx.

void SGSoundSample::play_once (  )  [inline]

Schedule this audio sample to play once.

See also:
play

Definition at line 139 of file sample_openal.hxx.

void SGSoundSample::set_audio_cone ( float  inner,
float  outer,
float  gain 
) [inline]

Define the audio cone parameters for directional audio.

Note: setting it to 2 degree will result in 1 degree to both sides.

Parameters:
inner Inner cone angle (0 - 360 degrees)
outer Outer cone angle (0 - 360 degrees)
gain Remaining gain at the edge of the outer cone (0.0 - 1.0)

Definition at line 360 of file sample_openal.hxx.

void SGSoundSample::set_buffer ( unsigned int  bid  )  [inline]

Set the OpenAL buffer-id of this source.

Parameters:
bid OpenAL buffer-id

Definition at line 207 of file sample_openal.hxx.

void SGSoundSample::set_data ( const unsigned char **  data  )  [inline]

Set the data associated with this audio sample.

Parameters:
data Pointer to a memory block containg this audio sample data. This pointer will be set to NULL after calling this function.

Definition at line 158 of file sample_openal.hxx.

void SGSoundSample::set_direction ( const SGVec3f dir  )  [inline]

Set direction of this sound relative to the orientation.

This is in the same coordinate system as OpenGL; y=up, z=back, x=right

Parameters:
dir Sound emission direction

Definition at line 349 of file sample_openal.hxx.

void SGSoundSample::set_format ( int  format  )  [inline]

Set the OpenAL format of this audio sample.

Parameters:
format OpenAL format-id

Definition at line 276 of file sample_openal.hxx.

void SGSoundSample::set_frequency ( int  freq  )  [inline]

Set the frequency (in Herz) of this audio sample.

Parameters:
freq Frequency

Definition at line 288 of file sample_openal.hxx.

void SGSoundSample::set_master_volume ( float  v  )  [inline]

Set the master volume of this sample.

Should be between 0.0 and 1.0. The final volume is calculated by multiplying the master and audio sample volume.

Parameters:
v Volume

Definition at line 250 of file sample_openal.hxx.

void SGSoundSample::set_max_dist ( float  dist  )  [inline]

Set maximum distance (in meters) of this sound.

This is the distance where this sound is no longer audible.

Parameters:
dist Maximum distance

Definition at line 429 of file sample_openal.hxx.

void SGSoundSample::set_orientation ( const SGQuatd ori  )  [inline]

Set the orientation of this sound.

Parameters:
ori Quaternation containing the orientation information

Definition at line 336 of file sample_openal.hxx.

void SGSoundSample::set_pitch ( float  p  )  [inline]

Set the playback pitch of this audio sample.

Should be between 0.0 and 2.0 for maximum compatibility.

Parameters:
p Pitch

Definition at line 233 of file sample_openal.hxx.

void SGSoundSample::set_position ( const SGVec3d pos  )  [inline]

Set the base position in Cartesian coordinates.

Parameters:
pos position in Cartesian coordinates

Definition at line 321 of file sample_openal.hxx.

void SGSoundSample::set_reference_dist ( float  dist  )  [inline]

Set reference distance (in meters) of this sound.

This is the distance where the gain will be half.

Parameters:
dist Reference distance

Definition at line 412 of file sample_openal.hxx.

void SGSoundSample::set_relative_position ( const SGVec3f pos  )  [inline]

Set the position of this sound relative to the base position.

This is in the same coordinate system as OpenGL; y=up, z=back, x=right.

Parameters:
pos Relative position of this sound

Definition at line 313 of file sample_openal.hxx.

void SGSoundSample::set_size ( size_t  size  )  [inline]

Sets the size (in bytes) of this audio sample.

Parameters:
size Data size

Definition at line 300 of file sample_openal.hxx.

void SGSoundSample::set_source ( unsigned int  sid  )  [inline]

Set the source id of this source.

Parameters:
sid OpenAL source-id

Definition at line 182 of file sample_openal.hxx.

void SGSoundSample::set_velocity ( const SGVec3f vel  )  [inline]

Set the velocity vector (in meters per second) of this sound.

This is in the local frame coordinate system; x=north, y=east, z=down

Parameters:
Velocity vector

Definition at line 395 of file sample_openal.hxx.

void SGSoundSample::set_volume ( float  v  )  [inline]

Set the volume of this audio sample.

Should be between 0.0 and 1.0. The final volume is calculated by multiplying the master and audio sample volume.

Parameters:
v Volume

Definition at line 261 of file sample_openal.hxx.


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

Generated on 23 Feb 2010 for SimGear by  doxygen 1.6.1