Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

lib.res.sound
(lib.res.sound globals)

   in snd_mgr.h
   in ogghack.h
   in snd_mgr.cpp
   in ogghack.cpp
   in snd_mgr.cpp

(lib.res.sound globals)


Field Summary
 static uint active_streams
          See snd_mgr.cpp
 static int al_bufs_outstanding
          See snd_mgr.cpp
 static bool al_initialized
          ========================================================================= File : snd_mgr.
 static float al_listener_gain
          See snd_mgr.cpp
 static float[ 6 ] al_listener_orientation
          See snd_mgr.cpp
 static float[ 3 ] al_listener_pos
          See snd_mgr.cpp
 static uint al_src_allocated
          See snd_mgr.cpp
 static uint al_src_cap
          See snd_mgr.cpp
 static const uint AL_SRC_MAX
          See snd_mgr.cpp
 static uint al_src_used
          See snd_mgr.cpp
 static ALuint[ AL_SRC_MAX ] al_srcs
          See snd_mgr.cpp
 static ALCcontext* alc_ctx
          See snd_mgr.cpp
 static ALCdevice* alc_dev
          See snd_mgr.cpp
 static const char* alc_dev_name
          See snd_mgr.cpp
 static const char* devs
          See snd_mgr.cpp
 static Handles hsd_list
          See snd_mgr.cpp
 static void* io_buf_freelist
          See snd_mgr.cpp
 static void* io_bufs
          See snd_mgr.cpp
 static const uint MAX_IOS
          See snd_mgr.cpp
 static const uint MAX_STREAMS
          See snd_mgr.cpp
 static bool snd_disabled
          See snd_mgr.cpp
 static double snd_update_time
          See snd_mgr.cpp
 static const size_t STREAM_BUF_SIZE
          See snd_mgr.cpp
 static const size_t TOTAL_BUF_SIZE
          See snd_mgr.cpp
 static const int TOTAL_IOS
          See snd_mgr.cpp
 static VSrcs vsrcs
          See snd_mgr.cpp
 
Method Summary
 static ALuint al_buf_alloc( ALvoid* data, ALsizei size, ALenum al_fmt, ALsizei al_freq )
          allocate a new buffer, and fill it with the specified data.
 static void al_buf_free( ALuint al_buf )
          free the buffer and its contained sound data.
 static void al_buf_shutdown()
          make sure all buffers have been returned to us via al_buf_free.
 static void al_check( const char* caller = "(unknown)" )
          check if OpenAL indicates an error has occurred.
 static LibError al_init()
          master OpenAL init; makes sure all subsystems are ready for use.
 static float al_listener_dist_2( const float point[ 3] )
          get distance between listener and point.
 static void al_listener_latch()
          send the current listener properties to OpenAL.
 static void al_listener_set_pos( const float pos[ 3], const float dir[ 3], const float up[ 3] )
          set position of the listener (corresponds to camera in graphics).
 static LibError al_reinit()
          re-initialize OpenAL.
 static void al_shutdown()
          shut down all module subsystems.
 static ALuint al_src_alloc()
          try to allocate a source.
 static void al_src_free( ALuint al_src )
          mark a source as free and available for reuse.
 static void al_src_init()
          grab as many sources as possible up to the limit.
 static void al_src_shutdown()
          release all sources on freelist (currently stack).
 static LibError alc_init()
          Ready OpenAL for use by setting up a device and context.
 static void alc_shutdown()
          free the OpenAL context and device.
 static void calc_cur_pri( VSrc* vs )
          determine new priority of the VSrc based on distance to listener and static priority.
 int close_func( void* UNUSED( datasource ) )
          See ogghack.cpp
 static FadeRet fade( FadeInfo& fi, double cur_time, float& out_val )
          Carry out the requested fade operation.
 static float fade_factor_exponential( float t )
          See snd_mgr.cpp
 static float fade_factor_linear( float t )
          See snd_mgr.cpp
 static float fade_factor_s_curve( float t )
          See snd_mgr.cpp
 static bool fade_is_active( FadeInfo& fi )
          Is the fade operation currently active?
 static void grant( VSrc* vs )
          See snd_mgr.cpp
  H_TYPE_DEFINE( SndData )
          See snd_mgr.cpp
  H_TYPE_DEFINE( VSrc )
          See snd_mgr.cpp
 static void hsd_list_add( Handle hsd )
          Add hsd to the list.
 static void hsd_list_free_all()
          Free all sounds on list.
 static void* io_buf_alloc()
          Allocate a fixed-size IO buffer.
 static void io_buf_free( void* p )
          Free an IO buffer.
 static void io_buf_init()
          Allocate a memory pool for all IO buffers.
 static void io_buf_shutdown()
          Free memory pool holding all IO buffers.
 static bool is_greater( const VSrc* vs1, const VSrc* vs2 )
          sort list by decreasing 'priority' (most important first)
 static bool is_null( VSrc* vs )
          See snd_mgr.cpp
 bool is_playing( Handle hvs )
          length of vector squared (avoids costly sqrt)
 static void list_add( VSrc* vs )
          See snd_mgr.cpp
 static void list_foreach( void ( * cb )( VSrc* ), uint skip = 0, uint end_idx = 0 )
          call back for each VSrc entry in the list.
 static LibError list_free_all()
          See snd_mgr.cpp
 static void list_prune_removed()
          remove entries that were set to 0 by list_remove, so that code below can grant the first al_src_cap entries a soure.
 static void list_remove( VSrc* vs )
          scan list and remove the given VSrc (by setting it to 0; list will be pruned later (see rationale below). O(N)!
 static void list_sort()
          See snd_mgr.cpp
 static float magnitude_2( const float v[ 3] )
          See snd_mgr.cpp
 void* ogg_create()
          See ogghack.cpp
 void ogg_give_raw( void* _o, void* p, size_t size )
          See ogghack.cpp
 void ogg_open( void* _o, ALenum& fmt, ALsizei& freq )
          See ogghack.cpp
 size_t ogg_read( void* _o, void* buf, size_t max_size )
          See ogghack.cpp
 void ogg_release( void* _o )
          See ogghack.cpp
 size_t read_func( void* ptr, size_t elements, size_t el_size, void* datasource )
          See ogghack.cpp
 static void reclaim( VSrc* vs )
          thunk that allows calling via list_foreach (return types differ)
 int seek_func( void* UNUSED( datasource ), ogg_int64_t UNUSED( offset ), int UNUSED( whence ) )
          See ogghack.cpp
 static LibError snd_data_buf_free( Handle hsd, ALuint al_buf )
          Indicate the sound's buffer is no longer needed.
 static LibError snd_data_buf_get( Handle hsd, ALuint& al_buf )
          Get the sound's AL buffer (typically to play it)
 static LibError snd_data_free( Handle& hsd )
          Free the sound.
 static Handle snd_data_load( const char* fn, bool is_stream )
          open and return a handle to a sound file's data.
 const char* snd_dev_next()
          Get next device name.
 LibError snd_dev_prepare_enum()
          Prepare to enumerate all device names (this resets the list returned by snd_dev_next).
 LibError snd_dev_set( const char* alc_new_dev_name )
          tell OpenAL to use the specified device in future.
 LibError snd_disable( bool disabled )
          (temporarily) disable all sound output.
 LibError snd_fade( Handle hvs, float initial_gain, float final_gain, float length, FadeType type )
          Fade the sound source in or out over time.
 LibError snd_free( Handle& hvs )
          Free the sound; if it was playing, it will be stopped.
 static LibError snd_init()
          extra layer on top of al_init that allows 'disabling' sound.
 Handle snd_open( const char* snd_fn, bool is_stream )
          open and return a handle to a sound instance.
 LibError snd_play( Handle hvs, float static_pri )
          Request the sound be played.
 LibError snd_set_cone( Handle hvs, const float cone_inner, const float cone_outer, const float cone_gain )
          set sound cone information cone_inner and cone_outer should be in the range 0.0 - 360.0, cone_gain (which is the outer cone gain) should range from 0.0 - 1.0
 LibError snd_set_gain( Handle hvs, float gain )
          Change gain (amplitude modifier) of the sound source.
 LibError snd_set_loop( Handle hvs, bool loop )
          Enable/disable looping on the sound source.
 LibError snd_set_master_gain( float gain )
          set amplitude modifier, which is effectively applied to all sounds.
 LibError snd_set_max_voices( uint limit )
          set maximum number of voices to play simultaneously, to reduce mixing cost on low-end systems.
 LibError snd_set_pitch( Handle hvs, float pitch )
          Change pitch shift of the sound source.
 LibError snd_set_pos( Handle hvs, float x, float y, float z, bool relative )
          Change 3d position of the sound source.
 void snd_shutdown()
          free all resources and shut down the sound system.
 LibError snd_update( const float* pos, const float* dir, const float* up )
          perform housekeeping (e.g. streaming); call once a frame.
 static void SndData_dtor( SndData* sd )
          See snd_mgr.cpp
 static void SndData_init( SndData* sd, va_list args )
          See snd_mgr.cpp
 static LibError SndData_reload( SndData* sd, const char* fn, Handle hsd )
          See snd_mgr.cpp
 static LibError SndData_to_string( const SndData* sd, char* buf )
          See snd_mgr.cpp
 static LibError SndData_validate( const SndData* sd )
          See snd_mgr.cpp
 static LibError stream_buf_discard( Stream* s )
          Free the buffer that was last returned by stream_buf_get, and remove its IO slot from our queue.
 static LibError stream_buf_get( Stream* s, void*& data, size_t& size )
          Access the data most recently streamed in.
 static LibError stream_close( Stream* s )
          close a stream, which may currently be active.
 static LibError stream_issue( Stream* s )
          Begin reading the next segment (asynchronously).
 static LibError stream_open( Stream* s, const char* fn )
          open a stream and begin reading from disk.
 static LibError stream_validate( const Stream* s )
          Make sure the given Stream is valid/self-consistent.
 static LibError vm_update()
          update voice management, i.
 static int vsrc_deque_finished_bufs( VSrc* vs )
          Dequeue any of the VSrc's sound buffers that are finished playing.
 static void VSrc_dtor( VSrc* vs )
          See snd_mgr.cpp
 static void vsrc_free( VSrc* vs )
          See snd_mgr.cpp
 static LibError vsrc_grant( VSrc* vs )
          Try to give the VSrc an AL source so that it can (re)start playing.
 static void VSrc_init( VSrc* vs, va_list args )
          See snd_mgr.cpp
 static void vsrc_latch( VSrc* vs )
          Send the VSrc properties to OpenAL (when we actually have a source).
 static LibError vsrc_reclaim( VSrc* vs )
          stop playback, and reclaim the OpenAL source.
 static LibError VSrc_reload( VSrc* vs, const char* fn, Handle hvs )
          See snd_mgr.cpp
 static void vsrc_set_initial( VSrc* vs )
          one-time init of parameters we will not later change.
 static LibError VSrc_to_string( const VSrc* vs, char* buf )
          See snd_mgr.cpp
 static LibError vsrc_update( VSrc* vs )
          Update the VSrc - perform fade (if active), queue/unqueue buffers.
 static LibError VSrc_validate( const VSrc* vs )
          See snd_mgr.cpp
 
Symbol Summary
 #define AL_CHECK al_check(__func__)
          See snd_mgr.cpp
 #define INCLUDED_SND_MGR
          See snd_mgr.h
 #define OGG_HACK
          See snd_mgr.cpp
 #define WIN_LOADLIBRARY_HACK 0
          See snd_mgr.cpp
 

Field Detail

active_streams

 static uint active_streams;
See snd_mgr.cpp.

al_bufs_outstanding

 static int al_bufs_outstanding;
See snd_mgr.cpp.

al_initialized

 static bool al_initialized;
========================================================================= File : snd_mgr.cpp Project : 0 A.D. Description : OpenAL sound engine. handles sound I/O, buffer : suballocation and voice management/prioritization. =========================================================================
See snd_mgr.cpp.

al_listener_gain

 static float al_listener_gain;
See snd_mgr.cpp.

al_listener_orientation

 static float al_listener_orientation[ 6 ];
See snd_mgr.cpp.

al_listener_pos

 static float al_listener_pos[ 3 ];
See snd_mgr.cpp.

al_src_allocated

 static uint al_src_allocated;
See snd_mgr.cpp.

al_src_cap

 static uint al_src_cap;
See snd_mgr.cpp.

AL_SRC_MAX

 static const uint AL_SRC_MAX;
See snd_mgr.cpp.

al_src_used

 static uint al_src_used;
See snd_mgr.cpp.

al_srcs

 static ALuint al_srcs[ AL_SRC_MAX ];
See snd_mgr.cpp.

alc_ctx

 static ALCcontext* alc_ctx;
See snd_mgr.cpp.

alc_dev

 static ALCdevice* alc_dev;
See snd_mgr.cpp.

alc_dev_name

 static const char* alc_dev_name;
See snd_mgr.cpp.

devs

 static const char* devs;
See snd_mgr.cpp.

hsd_list

 static Handles hsd_list;
See snd_mgr.cpp.

io_buf_freelist

 static void* io_buf_freelist;
See snd_mgr.cpp.

io_bufs

 static void* io_bufs;
See snd_mgr.cpp.

MAX_IOS

 static const uint MAX_IOS;
See snd_mgr.cpp.

MAX_STREAMS

 static const uint MAX_STREAMS;
See snd_mgr.cpp.

snd_disabled

 static bool snd_disabled;
See snd_mgr.cpp.

snd_update_time

 static double snd_update_time;
See snd_mgr.cpp.

STREAM_BUF_SIZE

 static const size_t STREAM_BUF_SIZE;
See snd_mgr.cpp.

TOTAL_BUF_SIZE

 static const size_t TOTAL_BUF_SIZE;
See snd_mgr.cpp.

TOTAL_IOS

 static const int TOTAL_IOS;
See snd_mgr.cpp.

vsrcs

 static VSrcs vsrcs;
See snd_mgr.cpp.


Method Detail

al_buf_alloc

 static ALuint al_buf_alloc( ALvoid* data, ALsizei size, ALenum al_fmt, ALsizei al_freq );
allocate a new buffer, and fill it with the specified data.
Parameters:
data - raw sound data buffer
size - size of buffer in bytes
al_fmt - AL_FORMAT_ * describing the sound data
al_freq - sampling frequency (typically 22050 Hz)
Returns:
ALuint buffer name
See snd_mgr.cpp.

al_buf_free

 static void al_buf_free( ALuint al_buf );
free the buffer and its contained sound data.
Parameters:
al_buf - buffer name
See snd_mgr.cpp.

al_buf_shutdown

 static void al_buf_shutdown();
make sure all buffers have been returned to us via al_buf_free. called from al_shutdown.
See snd_mgr.cpp.

al_check

 static void al_check( const char* caller = "(unknown)" );
check if OpenAL indicates an error has occurred. it can only report one error at a time, so this is called before and after every OpenAL request.
Parameters:
caller - Name of calling function (typically passed via __func__)
See snd_mgr.cpp.

al_init

 static LibError al_init();
master OpenAL init; makes sure all subsystems are ready for use. called from each snd_open; no harm if called more than once.
Returns:
LibError
See snd_mgr.cpp.

al_listener_dist_2

 static float al_listener_dist_2( const float point[ 3] );
get distance between listener and point. this is used to determine sound priority.
Parameters:
point - position support vector
Returns:
float euclidean distance squared
See snd_mgr.cpp.

al_listener_latch

 static void al_listener_latch();
send the current listener properties to OpenAL. also called from al_init.
See snd_mgr.cpp.

al_listener_set_pos

 static void al_listener_set_pos( const float pos[ 3], const float dir[ 3], const float up[ 3] );
set position of the listener (corresponds to camera in graphics). coordinates are in world space; the system doesn't matter.
Parameters:
pos - position support vector
dir - view direction
up - up vector
See snd_mgr.cpp.

al_reinit

 static LibError al_reinit();
re-initialize OpenAL. currently only required for changing devices.
Returns:
LibError
See snd_mgr.cpp.

al_shutdown

 static void al_shutdown();
shut down all module subsystems.
See snd_mgr.cpp.

al_src_alloc

 static ALuint al_src_alloc();
try to allocate a source.
Returns:
ALuint source name, or 0 if none available
See snd_mgr.cpp.

al_src_free

 static void al_src_free( ALuint al_src );
mark a source as free and available for reuse.
Parameters:
al_src - source name
See snd_mgr.cpp.

al_src_init

 static void al_src_init();
grab as many sources as possible up to the limit. called from al_init.
See snd_mgr.cpp.

al_src_shutdown

 static void al_src_shutdown();
release all sources on freelist (currently stack). all sources must have been returned to us via al_src_free. called from al_shutdown.
See snd_mgr.cpp.

alc_init

 static LibError alc_init();
Ready OpenAL for use by setting up a device and context.
Returns:
LibError
See snd_mgr.cpp.

alc_shutdown

 static void alc_shutdown();
free the OpenAL context and device.
See snd_mgr.cpp.

calc_cur_pri

 static void calc_cur_pri( VSrc* vs );
determine new priority of the VSrc based on distance to listener and static priority. called via list_foreach.
Parameters:
VSrc -
See snd_mgr.cpp.

close_func

 int close_func( void* UNUSED( datasource ) );
See ogghack.cpp.

fade

 static FadeRet fade( FadeInfo& fi, double cur_time, float& out_val );
Carry out the requested fade operation. This is called for each active VSrc; if they have no fade operation active, nothing happens. Note: as an optimization, we could make a list of VSrc with fade active and only call this for those; not yet necessary, though.
Parameters:
fi - Describes the fade operation
cur_time - typically returned via get_time()
out_val - Output gain value, i.e. the current result of the fade.
Returns:
FadeRet
See snd_mgr.cpp.

fade_factor_exponential

 static float fade_factor_exponential( float t );
See snd_mgr.cpp.

fade_factor_linear

 static float fade_factor_linear( float t );
See snd_mgr.cpp.

fade_factor_s_curve

 static float fade_factor_s_curve( float t );
See snd_mgr.cpp.

fade_is_active

 static bool fade_is_active( FadeInfo& fi );
Is the fade operation currently active?
Parameters:
FadeInfo
Returns:
bool
See snd_mgr.cpp.

grant

 static void grant( VSrc* vs );
See snd_mgr.cpp.

H_TYPE_DEFINE

 H_TYPE_DEFINE( SndData );
See snd_mgr.cpp.

H_TYPE_DEFINE

 H_TYPE_DEFINE( VSrc );
See snd_mgr.cpp.

hsd_list_add

 static void hsd_list_add( Handle hsd );
Add hsd to the list. called from SndData_reload; will later be removed via hsd_list_free_all.
Parameters:
hsd - Handle to SndData
See snd_mgr.cpp.

hsd_list_free_all

 static void hsd_list_free_all();
Free all sounds on list. called by al_shutdown (at exit, or when reinitializing OpenAL).
See snd_mgr.cpp.

io_buf_alloc

 static void* io_buf_alloc();
Allocate a fixed-size IO buffer.
Returns:
void* buffer, or 0 (and warning) if not enough memory.
See snd_mgr.cpp.

io_buf_free

 static void io_buf_free( void* p );
Free an IO buffer.
Parameters:
void* - IO buffer
See snd_mgr.cpp.

io_buf_init

 static void io_buf_init();
Allocate a memory pool for all IO buffers. Called from first io_buf_alloc.
See snd_mgr.cpp.

io_buf_shutdown

 static void io_buf_shutdown();
Free memory pool holding all IO buffers. no-op if io_buf_alloc was never called. called by snd_shutdown.
See snd_mgr.cpp.

is_greater

 static bool is_greater( const VSrc* vs1, const VSrc* vs2 );
sort list by decreasing 'priority' (most important first)
See snd_mgr.cpp.

is_null

 static bool is_null( VSrc* vs );
See snd_mgr.cpp.

is_playing

 bool is_playing( Handle hvs );
length of vector squared (avoids costly sqrt)
See snd_mgr.cpp.

list_add

 static void list_add( VSrc* vs );
See snd_mgr.cpp.

list_foreach

 static void list_foreach( void ( * cb )( VSrc* ), uint skip = 0, uint end_idx = 0 );
call back for each VSrc entry in the list.
Parameters:
cb - Callback function
skip - number of entries to skip (default 0)
end_idx - if not the default value of 0, stop before that entry.
See snd_mgr.cpp.

list_free_all

 static LibError list_free_all();
See snd_mgr.cpp.

list_prune_removed

 static void list_prune_removed();
remove entries that were set to 0 by list_remove, so that code below can grant the first al_src_cap entries a soure.
See snd_mgr.cpp.

list_remove

 static void list_remove( VSrc* vs );
scan list and remove the given VSrc (by setting it to 0; list will be pruned later (see rationale below). O(N)!
Parameters:
vs - VSrc to remove.
See snd_mgr.cpp.

list_sort

 static void list_sort();
See snd_mgr.cpp.

magnitude_2

 static float magnitude_2( const float v[ 3] );
See snd_mgr.cpp.

ogg_create

 void* ogg_create();
See ogghack.cpp.

ogg_give_raw

 void ogg_give_raw( void* _o, void* p, size_t size );
See ogghack.cpp.

ogg_open

 void ogg_open( void* _o, ALenum& fmt, ALsizei& freq );
See ogghack.cpp.

ogg_read

 size_t ogg_read( void* _o, void* buf, size_t max_size );
See ogghack.cpp.

ogg_release

 void ogg_release( void* _o );
See ogghack.cpp.

read_func

 size_t read_func( void* ptr, size_t elements, size_t el_size, void* datasource );
See ogghack.cpp.

reclaim

 static void reclaim( VSrc* vs );
thunk that allows calling via list_foreach (return types differ)
See snd_mgr.cpp.

seek_func

 int seek_func( void* UNUSED( datasource ), ogg_int64_t UNUSED( offset ), int UNUSED( whence ) );
See ogghack.cpp.

snd_data_buf_free

 static LibError snd_data_buf_free( Handle hsd, ALuint al_buf );
Indicate the sound's buffer is no longer needed.
Parameters:
hsd - Handle to SndData.
al_buf - buffer name
Returns:
LibError
See snd_mgr.cpp.

snd_data_buf_get

 static LibError snd_data_buf_get( Handle hsd, ALuint& al_buf );
Get the sound's AL buffer (typically to play it)
Parameters:
hsd - Handle to SndData.
al_buf - buffer name.
Returns:
LibError, most commonly: INFO::OK = buffer has been returned; more are expected to be available. ERR::IO_EOF = buffer has been returned but is the last one (end of file reached) ERR::AGAIN = no buffer returned yet; still streaming in ATM. call back later.
See snd_mgr.cpp.

snd_data_free

 static LibError snd_data_free( Handle& hsd );
Free the sound.
Parameters:
hsd - Handle to SndData; set to 0 afterwards.
Returns:
LibError
See snd_mgr.cpp.

snd_data_load

 static Handle snd_data_load( const char* fn, bool is_stream );
open and return a handle to a sound file's data.
Parameters:
fn - VFS filename
is_stream - (default false) indicates whether this file should be streamed in (opening is faster, it won't be kept in memory, but only one instance can be open at a time; makes sense for large music files) or loaded immediately.
Returns:
Handle or LibError on failure
See snd_mgr.cpp.

snd_dev_next

 const char* snd_dev_next();
Get next device name. do not call unless snd_dev_prepare_enum succeeded! not thread-safe! (static data from snd_dev_prepare_enum is used)
Returns:
const char* device name, or 0 if all have been returned
See snd_mgr.cpp.

snd_dev_prepare_enum

 LibError snd_dev_prepare_enum();
Prepare to enumerate all device names (this resets the list returned by snd_dev_next). may be called each time the device list is needed.
Returns:
LibError; always successful unless the requisite device enumeration extension isn't available. in the latter case, a "cannot enum device" message should be presented to the user, and snd_dev_set need not be called; OpenAL will use its default device.
See snd_mgr.cpp.

snd_dev_set

 LibError snd_dev_set( const char* alc_new_dev_name );
tell OpenAL to use the specified device in future.
Parameters:
alc_new_dev_name - Device name.
Returns:
LibError name = 0 reverts to OpenAL's default choice, which will also be used if this routine is never called. the device name is typically taken from a config file at init-time; the snd_dev * enumeration routines below are used to present a list of choices to the user in the options screen. if OpenAL hasn't yet been initialized (i.e. no sounds have been opened), this just stores the device name for use when init does occur. note: we can't check now if it's invalid (if so, init will fail). otherwise, we shut OpenAL down (thereby stopping all sounds) and re-initialize with the new device. that's fairly time-consuming, so preferably call this routine before sounds are loaded.
See snd_mgr.cpp.

snd_disable

 LibError snd_disable( bool disabled );
(temporarily) disable all sound output. because it causes future snd_open calls to immediately abort before they demand-initialize OpenAL, startup is sped up considerably (500..1000ms). therefore, this must be called before the first snd_open to have any effect; otherwise, the cat will already be out of the bag and we debug_warn of it. rationale: this is a quick'n dirty way of speeding up startup during development without having to change the game's sound code. can later be called to reactivate sound; all settings ever changed will be applied and subsequent sound load / play requests will work.
Parameters:
bool - disabled
Returns:
LibError
See snd_mgr.cpp.

snd_fade

 LibError snd_fade( Handle hvs, float initial_gain, float final_gain, float length, FadeType type );
Fade the sound source in or out over time. Its gain starts at immediately and is moved toward over seconds. may be called at any time; fails with invalid handle return if the sound has already been closed (e.g. it never played). note that this function doesn't busy-wait until the fade is complete; any number of fades may be active at a time (allows cross-fading). each snd_update calculates a new gain value for all pending fades. it is safe to start another fade on the same sound source while one is currently in progress; the old one is dropped.
Parameters:
hvs - Handle to VSrc
initial_gain - gain. if < 0 (an otherwise illegal value), the sound's current gain is used as the start value (useful for fading out).
final_gain - gain. if 0, the sound is freed when the fade completes or is aborted, thus allowing fire-and-forget fadeouts. no cases are foreseen where this is undesirable, and it is easier to implement than an extra set-free-after-fade-flag function.
length - duration of fade [s]
type - determines the fade curve: linear, exponential or S-curve. for guidance on which to use, see http://www.transom.org/tools/editing_mixing/200309.stupidfadetricks.html you can also pass FT_ABORT to stop fading (if in progress) and set gain to the final_gain parameter passed here.
Returns:
LibError
See snd_mgr.cpp.

snd_free

 LibError snd_free( Handle& hvs );
Free the sound; if it was playing, it will be stopped. Note: sounds are closed automatically when done playing; this is provided for completeness only.
Parameters:
hvs - Handle to VSrc. will be set to 0 afterwards.
Returns:
LibError
See snd_mgr.cpp.

snd_init

 static LibError snd_init();
extra layer on top of al_init that allows 'disabling' sound. called from each snd_open.
Returns:
LibError from al_init, or ERR::AGAIN if sound disabled
See snd_mgr.cpp.

snd_open

 Handle snd_open( const char* snd_fn, bool is_stream );
open and return a handle to a sound instance.
Parameters:
snd_fn - VFS filename. if a text file (extension ".txt"), it is assumed to be a definition file containing the sound file name and its gain (0.0 .. 1.0). otherwise, it is taken to be the sound file name and gain is set to the default of 1.0 (no attenuation).
is_stream - (default false) indicates whether this file should be streamed in (opening is faster, it won't be kept in memory, but only one instance can be open at a time; makes sense for large music files) or loaded immediately.
Returns:
Handle or LibError on failure
See snd_mgr.cpp.

snd_play

 LibError snd_play( Handle hvs, float static_pri );
Request the sound be played. Once done playing, the sound is automatically closed (allows fire-and-forget play code). if no hardware voice is available, this sound may not be played at all, or in the case of looped sounds, start later.
Parameters:
hvs - Handle to VSrc
static_pri - (min 0 .. max 1, default 0) indicates which sounds are considered more important; this is attenuated by distance to the listener (see snd_update).
Returns:
LibError
See snd_mgr.cpp.

snd_set_cone

 LibError snd_set_cone( Handle hvs, const float cone_inner, const float cone_outer, const float cone_gain );
set sound cone information cone_inner and cone_outer should be in the range 0.0 - 360.0, cone_gain (which is the outer cone gain) should range from 0.0 - 1.0
Parameters:
cone_inner - inner angle of sound cone
cone_outer - outer angle of sound cone
cone_gain - outer cone gain
Returns:
LibError
See snd_mgr.cpp.

snd_set_gain

 LibError snd_set_gain( Handle hvs, float gain );
Change gain (amplitude modifier) of the sound source. should not be called during a fade (see note in implementation); fails with invalid handle return if the sound has already been closed (e.g. it never played).
Parameters:
hvs - Handle to VSrc
gain - modifier; must be non-negative; 1 -> unattenuated, 0.5 -> -6 dB, 0 -> silence.
Returns:
LibError
See snd_mgr.cpp.

snd_set_loop

 LibError snd_set_loop( Handle hvs, bool loop );
Enable/disable looping on the sound source. used to implement variable-length sounds (e.g. while building). may be called at any time; fails with invalid handle return if the sound has already been closed (e.g. it never played). notes: - looping sounds are not discarded if they cannot be played for lack of a hardware voice at the moment play was requested. - once looping is again disabled and the sound has reached its end, the sound instance is freed automatically (as if never looped).
Parameters:
hvs - Handle to VSrc
bool - loop
Returns:
LibError
See snd_mgr.cpp.

snd_set_master_gain

 LibError snd_set_master_gain( float gain );
set amplitude modifier, which is effectively applied to all sounds. in layman's terms, this is the global "volume".
Parameters:
gain - Modifier: must be non-negative; 1 -> unattenuated, 0.5 -> -6 dB, 0 -> silence.
Returns:
LibError
See snd_mgr.cpp.

snd_set_max_voices

 LibError snd_set_max_voices( uint limit );
set maximum number of voices to play simultaneously, to reduce mixing cost on low-end systems. this limit may be ignored if e.g. there's a stricter implementation- defined ceiling anyway.
Parameters:
limit - max. number of sources
Returns:
LibError
See snd_mgr.cpp.

snd_set_pitch

 LibError snd_set_pitch( Handle hvs, float pitch );
Change pitch shift of the sound source. may be called at any time; fails with invalid handle return if the sound has already been closed (e.g. it never played).
Parameters:
hvs - Handle to VSrc
pitch - shift: 1.0 means no change; each doubling/halving equals a pitch shift of +/-12 semitones (one octave). zero is invalid.
Returns:
LibError
See snd_mgr.cpp.

snd_set_pos

 LibError snd_set_pos( Handle hvs, float x, float y, float z, bool relative );
Change 3d position of the sound source. May be called at any time; fails with invalid handle return if the sound has already been closed (e.g. it never played).
Parameters:
hvs - Handle to VSrc
x,y,z - coordinates (interpretation: see below)
relative - if true, (x,y,z) is treated as relative to the listener; otherwise, it is the position in world coordinates (default).
Returns:
LibError
See snd_mgr.cpp.

snd_shutdown

 void snd_shutdown();
free all resources and shut down the sound system. call before h_mgr_shutdown.
See snd_mgr.cpp.

snd_update

 LibError snd_update( const float* pos, const float* dir, const float* up );
perform housekeeping (e.g. streaming); call once a frame.
Parameters:
pos - position support vector. if NULL, all parameters are ignored and listener position unchanged; this is useful in case the world isn't initialized yet.
dir - view direction
up - up vector
Returns:
LibError
See snd_mgr.cpp.

SndData_dtor

 static void SndData_dtor( SndData* sd );
See snd_mgr.cpp.

SndData_init

 static void SndData_init( SndData* sd, va_list args );
See snd_mgr.cpp.

SndData_reload

 static LibError SndData_reload( SndData* sd, const char* fn, Handle hsd );
See snd_mgr.cpp.

SndData_to_string

 static LibError SndData_to_string( const SndData* sd, char* buf );
See snd_mgr.cpp.

SndData_validate

 static LibError SndData_validate( const SndData* sd );
See snd_mgr.cpp.

stream_buf_discard

 static LibError stream_buf_discard( Stream* s );
Free the buffer that was last returned by stream_buf_get, and remove its IO slot from our queue. Must be called exactly once after every successful stream_buf_get; call before calling any other stream_ * functions!
Parameters:
Stream
Returns:
LibError
See snd_mgr.cpp.

stream_buf_get

 static LibError stream_buf_get( Stream* s, void*& data, size_t& size );
Access the data most recently streamed in.
Parameters:
Stream
data - pointer to buffer
size - [bytes]
Returns:
LibError; if the first pending IO hasn't completed, ERR::AGAIN (not an error).
See snd_mgr.cpp.

stream_close

 static LibError stream_close( Stream* s );
close a stream, which may currently be active.
Parameters:
Stream
Returns:
LibError - the first error that occurred while waiting for IOs / closing file.
See snd_mgr.cpp.

stream_issue

 static LibError stream_issue( Stream* s );
Begin reading the next segment (asynchronously). Called from SndData_reload and snd_data_buf_get.
Parameters:
Stream
Returns:
LibError
See snd_mgr.cpp.

stream_open

 static LibError stream_open( Stream* s, const char* fn );
open a stream and begin reading from disk.
Parameters:
Stream
fn - VFS filename.
Returns:
LibError
See snd_mgr.cpp.

stream_validate

 static LibError stream_validate( const Stream* s );
Make sure the given Stream is valid/self-consistent.
Parameters:
const - Stream
Returns:
LibError
See snd_mgr.cpp.

vm_update

 static LibError vm_update();
update voice management, i.e. recalculate priority and assign AL sources. no-op if OpenAL not yet initialized.
Returns:
LibError
See snd_mgr.cpp.

vsrc_deque_finished_bufs

 static int vsrc_deque_finished_bufs( VSrc* vs );
Dequeue any of the VSrc's sound buffers that are finished playing.
Parameters:
VSrc
Returns:
int number of entries that were removed.
See snd_mgr.cpp.

VSrc_dtor

 static void VSrc_dtor( VSrc* vs );
See snd_mgr.cpp.

vsrc_free

 static void vsrc_free( VSrc* vs );
See snd_mgr.cpp.

vsrc_grant

 static LibError vsrc_grant( VSrc* vs );
Try to give the VSrc an AL source so that it can (re)start playing. called by snd_play and voice management.
Parameters:
VSrc
Returns:
LibError (ERR::FAIL if no AL source is available)
See snd_mgr.cpp.

VSrc_init

 static void VSrc_init( VSrc* vs, va_list args );
See snd_mgr.cpp.

vsrc_latch

 static void vsrc_latch( VSrc* vs );
Send the VSrc properties to OpenAL (when we actually have a source). called by snd_set * and vsrc_grant.
Parameters:
VSrc -
See snd_mgr.cpp.

vsrc_reclaim

 static LibError vsrc_reclaim( VSrc* vs );
stop playback, and reclaim the OpenAL source. called when closing the VSrc, or when voice management decides this VSrc must yield to others of higher priority.
Parameters:
VSrc
Returns:
LibError
See snd_mgr.cpp.

VSrc_reload

 static LibError VSrc_reload( VSrc* vs, const char* fn, Handle hvs );
See snd_mgr.cpp.

vsrc_set_initial

 static void vsrc_set_initial( VSrc* vs );
one-time init of parameters we will not later change. this separate from vsrc_latch as a tiny optimization.
Parameters:
VSrc -
See snd_mgr.cpp.

VSrc_to_string

 static LibError VSrc_to_string( const VSrc* vs, char* buf );
See snd_mgr.cpp.

vsrc_update

 static LibError vsrc_update( VSrc* vs );
Update the VSrc - perform fade (if active), queue/unqueue buffers. Called once a frame.
Parameters:
VSrc
Returns:
LibError
See snd_mgr.cpp.

VSrc_validate

 static LibError VSrc_validate( const VSrc* vs );
See snd_mgr.cpp.


Symbol Detail

AL_CHECK

 #define AL_CHECK al_check(__func__)
See snd_mgr.cpp.

INCLUDED_SND_MGR

 #define INCLUDED_SND_MGR 
See snd_mgr.h.

OGG_HACK

 #define OGG_HACK 
See snd_mgr.cpp.

WIN_LOADLIBRARY_HACK

 #define WIN_LOADLIBRARY_HACK 0
See snd_mgr.cpp.

 Overview   Project   Class   Tree   Deprecated   Index 
0 A.D.
Generated on September 04, 2007 at 18:13
CppDoc v2.4.0
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD