FS2_Open
Open source remastering of the Freespace 2 engine
sound.h File Reference

Go to the source code of this file.

Classes

struct  EnhancedSoundData
 
class  game_snd
 
struct  sound_env
 

Macros

#define SOUND_LIB_DIRECTSOUND   0
 
#define SOUND_LIB_RSX   1
 
#define GAME_SND_USE_DS3D   (1<<1)
 
#define GAME_SND_VOICE   (1<<2)
 
#define SND_PRIORITY_MUST_PLAY   0
 
#define SND_PRIORITY_SINGLE_INSTANCE   1
 
#define SND_PRIORITY_DOUBLE_INSTANCE   2
 
#define SND_PRIORITY_TRIPLE_INSTANCE   3
 
#define AAV_MUSIC   0
 
#define AAV_VOICE   1
 
#define AAV_EFFECTS   2
 

Typedefs

typedef struct sound_env sound_env
 

Enumerations

enum  EnhancedSoundPriority {
  SND_ENHANCED_PRIORITY_MUST_PLAY = 0, SND_ENHANCED_PRIORITY_HIGH = 1, SND_ENHANCED_PRIORITY_MEDIUM_HIGH = 2, SND_ENHANCED_PRIORITY_MEDIUM = 3,
  SND_ENHANCED_PRIORITY_MEDIUM_LOW = 4, SND_ENHANCED_PRIORITY_LOW = 5, SND_ENHANCED_PRIORITY_INVALID = 6
}
 

Functions

int snd_load (game_snd *gs, int allow_hardware_load=0)
 
int snd_unload (int sndnum)
 
void snd_unload_all ()
 
int snd_play (game_snd *gs, float pan=0.0f, float vol_scale=1.0f, int priority=SND_PRIORITY_SINGLE_INSTANCE, bool voice_message=false)
 
int snd_play_raw (int soundnum, float pan, float vol_scale=1.0f, int priority=SND_PRIORITY_MUST_PLAY)
 
int snd_play_3d (game_snd *gs, vec3d *source_pos, vec3d *listen_pos, float radius=0.0f, vec3d *vel=NULL, int looping=0, float vol_scale=1.0f, int priority=SND_PRIORITY_SINGLE_INSTANCE, vec3d *sound_fvec=NULL, float range_factor=1.0f, int force=0, bool is_ambient=false)
 
void snd_update_3d_pos (int soudnnum, game_snd *gs, vec3d *new_pos, float radius=0.0f, float range_factor=1.0f)
 
int snd_play_looping (game_snd *gs, float pan=0.0f, int start_loop=-1, int stop_loop=-1, float vol_scale=1.0f, int scriptingUpdateVolume=1)
 
void snd_stop (int snd_handle)
 
void snd_set_volume (int snd_handle, float volume)
 
void snd_set_pan (int snd_handle, float pan)
 
void snd_set_pitch (int snd_handle, int pitch)
 
int snd_get_pitch (int snd_handle)
 
void snd_stop_all ()
 
int snd_is_playing (int snd_handle)
 
void snd_chg_loop_status (int snd_handle, int loop)
 
int snd_get_duration (int snd_id)
 
const char * snd_get_filename (int snd_id)
 
int snd_get_3d_vol_and_pan (game_snd *gs, vec3d *pos, float *vol, float *pan, float radius=0.0f, float range_factor=1.0f)
 
int snd_init ()
 
void snd_close ()
 
int snd_is_inited ()
 
void snd_update_listener (vec3d *pos, vec3d *vel, matrix *orient)
 
void snd_use_lib (int lib_id)
 
int snd_num_playing ()
 
int snd_get_data (int handle, char *data)
 
int snd_size (int handle, int *size)
 
void snd_do_frame ()
 
void snd_adjust_audio_volume (int type, float percent, int time)
 
void snd_rewind (int snd_handle, game_snd *sg, float seconds)
 
void snd_ffwd (int snd_handle, game_snd *sg, float seconds)
 
void snd_set_pos (int snd_handle, game_snd *sg, float val, int as_pct)
 
void snd_get_format (int handle, int *bits_per_sample, int *frequency)
 
int snd_time_remaining (int handle)
 
int snd_get_samples_per_measure (char *filename, float num_measures)
 
int sound_env_set (sound_env *se)
 
int sound_env_get (sound_env *se, int preset=-1)
 
int sound_env_disable ()
 
int sound_env_supported ()
 
void snd_aav_init ()
 

Variables

const unsigned int SND_ENHANCED_MAX_LIMIT
 
int Sound_enabled
 
float Master_sound_volume
 
float Master_voice_volume
 
int Snd_sram
 
int Snd_hram
 
float aav_voice_volume
 
float aav_music_volume
 
float aav_effect_volume
 
unsigned int SND_ENV_DEFAULT
 

Macro Definition Documentation

#define AAV_EFFECTS   2

Definition at line 67 of file sound.h.

#define AAV_MUSIC   0

Definition at line 65 of file sound.h.

#define AAV_VOICE   1

Definition at line 66 of file sound.h.

#define GAME_SND_USE_DS3D   (1<<1)

Definition at line 21 of file sound.h.

#define GAME_SND_VOICE   (1<<2)

Definition at line 22 of file sound.h.

#define SND_PRIORITY_DOUBLE_INSTANCE   2

Definition at line 28 of file sound.h.

#define SND_PRIORITY_MUST_PLAY   0

Definition at line 26 of file sound.h.

#define SND_PRIORITY_SINGLE_INSTANCE   1

Definition at line 27 of file sound.h.

#define SND_PRIORITY_TRIPLE_INSTANCE   3

Definition at line 29 of file sound.h.

#define SOUND_LIB_DIRECTSOUND   0

Definition at line 18 of file sound.h.

#define SOUND_LIB_RSX   1

Definition at line 19 of file sound.h.

Typedef Documentation

typedef struct sound_env sound_env

Enumeration Type Documentation

Enumerator
SND_ENHANCED_PRIORITY_MUST_PLAY 
SND_ENHANCED_PRIORITY_HIGH 
SND_ENHANCED_PRIORITY_MEDIUM_HIGH 
SND_ENHANCED_PRIORITY_MEDIUM 
SND_ENHANCED_PRIORITY_MEDIUM_LOW 
SND_ENHANCED_PRIORITY_LOW 
SND_ENHANCED_PRIORITY_INVALID 

Definition at line 32 of file sound.h.

Function Documentation

void snd_aav_init ( )

Definition at line 1535 of file sound.cpp.

void snd_adjust_audio_volume ( int  type,
float  percent,
int  time 
)

Definition at line 1465 of file sound.cpp.

void snd_chg_loop_status ( int  snd_handle,
int  loop 
)
void snd_close ( )

Definition at line 459 of file sound.cpp.

void snd_do_frame ( )

Definition at line 1411 of file sound.cpp.

void snd_ffwd ( int  snd_handle,
game_snd sg,
float  seconds 
)

Definition at line 1150 of file sound.cpp.

int snd_get_3d_vol_and_pan ( game_snd gs,
vec3d pos,
float vol,
float pan,
float  radius = 0.0f,
float  range_factor = 1.0f 
)

Definition at line 759 of file sound.cpp.

int snd_get_data ( int  handle,
char *  data 
)

Definition at line 1232 of file sound.cpp.

int snd_get_duration ( int  snd_id)

Definition at line 1082 of file sound.cpp.

const char* snd_get_filename ( int  snd_id)

Definition at line 1101 of file sound.cpp.

void snd_get_format ( int  handle,
int bits_per_sample,
int frequency 
)

Definition at line 1256 of file sound.cpp.

int snd_get_pitch ( int  snd_handle)

Definition at line 992 of file sound.cpp.

int snd_get_samples_per_measure ( char *  filename,
float  num_measures 
)

Definition at line 1428 of file sound.cpp.

int snd_init ( )

Definition at line 131 of file sound.cpp.

int snd_is_inited ( )

Definition at line 1073 of file sound.cpp.

int snd_is_playing ( int  snd_handle)

Definition at line 1047 of file sound.cpp.

int snd_load ( game_snd gs,
int  allow_hardware_load = 0 
)

Definition at line 281 of file sound.cpp.

int snd_num_playing ( )

Definition at line 1207 of file sound.cpp.

int snd_play ( game_snd gs,
float  pan = 0.0f,
float  vol_scale = 1.0f,
int  priority = SND_PRIORITY_SINGLE_INSTANCE,
bool  voice_message = false 
)

Definition at line 517 of file sound.cpp.

int snd_play_3d ( game_snd gs,
vec3d source_pos,
vec3d listen_pos,
float  radius = 0.0f,
vec3d vel = NULL,
int  looping = 0,
float  vol_scale = 1.0f,
int  priority = SND_PRIORITY_SINGLE_INSTANCE,
vec3d sound_fvec = NULL,
float  range_factor = 1.0f,
int  force = 0,
bool  is_ambient = false 
)

Definition at line 594 of file sound.cpp.

int snd_play_looping ( game_snd gs,
float  pan,
int  start_loop,
int  stop_loop,
float  vol_scale,
int  scriptingUpdateVolume 
)

Starts looping a game sound

Parameters
gsgame-level sound description
pan-1.0 (full left) to 1.0 (full right)
start_loopTODO remove this parameter
stop_loopTODO remove this parameter
vol_scalefactor to scale the static volume by (applied before attenuation)
scriptingUpdateVolumeif true the looping sound value is updated default is TRUE
Returns
-1 on error, else the handle for this playing sound

Definition at line 822 of file sound.cpp.

int snd_play_raw ( int  soundnum,
float  pan,
float  vol_scale = 1.0f,
int  priority = SND_PRIORITY_MUST_PLAY 
)

Definition at line 477 of file sound.cpp.

void snd_rewind ( int  snd_handle,
game_snd sg,
float  seconds 
)

Definition at line 1120 of file sound.cpp.

void snd_set_pan ( int  snd_handle,
float  pan 
)

Definition at line 964 of file sound.cpp.

void snd_set_pitch ( int  snd_handle,
int  pitch 
)

Definition at line 1021 of file sound.cpp.

void snd_set_pos ( int  snd_handle,
game_snd sg,
float  val,
int  as_pct 
)

Definition at line 1180 of file sound.cpp.

void snd_set_volume ( int  sig,
float  volume 
)

Set the volume of a currently playing sound

Parameters
sighandle to sound, what is returned from snd_play()
volumevolume of sound (range: 0.0 -> 1.0)

Definition at line 920 of file sound.cpp.

int snd_size ( int  handle,
int size 
)

Definition at line 1244 of file sound.cpp.

void snd_stop ( int  sig)

Stop a sound from playing.

Parameters
sighandle to sound, what is returned from snd_play()

Definition at line 875 of file sound.cpp.

void snd_stop_all ( )

Stop all playing sound channels (including looping sounds)

NOTE: This stops all sounds that are playing from Channels[] sound buffers. It doesn't stop every secondary sound buffer in existance.

Definition at line 905 of file sound.cpp.

int snd_time_remaining ( int  handle)

Definition at line 1291 of file sound.cpp.

int snd_unload ( int  sndnum)

Definition at line 415 of file sound.cpp.

void snd_unload_all ( )

Definition at line 447 of file sound.cpp.

void snd_update_3d_pos ( int  soudnnum,
game_snd gs,
vec3d new_pos,
float  radius = 0.0f,
float  range_factor = 1.0f 
)

Definition at line 693 of file sound.cpp.

void snd_update_listener ( vec3d pos,
vec3d vel,
matrix orient 
)

Definition at line 1113 of file sound.cpp.

void snd_use_lib ( int  lib_id)
int sound_env_disable ( )

Definition at line 1389 of file sound.cpp.

int sound_env_get ( sound_env se,
int  preset = -1 
)

Definition at line 1372 of file sound.cpp.

int sound_env_set ( sound_env se)

Definition at line 1357 of file sound.cpp.

int sound_env_supported ( )

Definition at line 1402 of file sound.cpp.

Variable Documentation

float aav_effect_volume

Definition at line 80 of file sound.cpp.

float aav_music_volume

Definition at line 79 of file sound.cpp.

float aav_voice_volume

Definition at line 78 of file sound.cpp.

float Master_sound_volume

Definition at line 53 of file sound.cpp.

float Master_voice_volume

Definition at line 54 of file sound.cpp.

const unsigned int SND_ENHANCED_MAX_LIMIT

Definition at line 35 of file sound.cpp.

unsigned int SND_ENV_DEFAULT

Definition at line 56 of file sound.cpp.

int Snd_hram
int Snd_sram

Definition at line 52 of file sound.cpp.

int Sound_enabled

Definition at line 51 of file sound.cpp.