Open source remastering of the Freespace 2 engine
sound.cpp File Reference
#include "cfile/cfile.h"
#include "cmdline/cmdline.h"
#include "debugconsole/console.h"
#include "gamesnd/eventmusic.h"
#include "gamesnd/gamesnd.h"
#include "globalincs/alphacolors.h"
#include "globalincs/pstypes.h"
#include "globalincs/vmallocator.h"
#include "osapi/osapi.h"
#include "render/3d.h"
#include "sound/acm.h"
#include "sound/audiostr.h"
#include "sound/ds.h"
#include "sound/ds3d.h"
#include "sound/dscap.h"
#include "sound/ogg/ogg.h"
#include "sound/sound.h"
#include <limits.h>

Go to the source code of this file.


struct  sound
struct  LoopingSoundInfo
struct  aav


#define SND_F_USED   (1<<0)
#define MIN_SOUND_VOLUME   0.05f


typedef struct sound sound


int ds_priority (int priority)
void snd_clear ()
int snd_init ()
void snd_spew_info ()
 DCF (show_sounds,"Toggles display of sound debug info")
void snd_spew_debug_info ()
int snd_load (game_snd *gs, int allow_hardware_load)
int snd_unload (int n)
void snd_unload_all ()
void snd_close (void)
int snd_play_raw (int soundnum, float pan, float vol_scale, int priority)
int snd_play (game_snd *gs, float pan, float vol_scale, int priority, bool is_voice_msg)
int snd_play_3d (game_snd *gs, vec3d *source_pos, vec3d *listen_pos, float radius, vec3d *source_vel, int looping, float vol_scale, int priority, vec3d *sound_fvec, float range_factor, int force, bool is_ambient)
void snd_update_3d_pos (int soundnum, game_snd *gs, vec3d *new_pos, float radius, float range_factor)
int snd_get_3d_vol_and_pan (game_snd *gs, vec3d *pos, float *vol, float *pan, float radius, float range_factor)
int snd_play_looping (game_snd *gs, float pan, int start_loop, int stop_loop, float vol_scale, int scriptingUpdateVolume)
void snd_stop (int sig)
void snd_stop_all ()
void snd_set_volume (int sig, float volume)
void snd_set_pan (int sig, float pan)
int snd_get_pitch (int sig)
void snd_set_pitch (int sig, int pitch)
int snd_is_playing (int sig)
int snd_is_inited ()
int snd_get_duration (int snd_id)
const char * snd_get_filename (int snd_id)
void snd_update_listener (vec3d *pos, vec3d *vel, matrix *orient)
void snd_rewind (int snd_handle, game_snd *gs, float seconds)
void snd_ffwd (int snd_handle, game_snd *gs, float seconds)
void snd_set_pos (int snd_handle, game_snd *gs, float val, int as_pct)
int snd_num_playing ()
void snd_stop_any_sound ()
int snd_get_data (int handle, char *data)
int snd_size (int handle, int *size)
void snd_get_format (int handle, int *bits_per_sample, int *frequency)
int snd_get_index (int sig)
int snd_time_remaining (int handle)
int sound_env_set (sound_env *se)
int sound_env_get (sound_env *se, int preset)
int sound_env_disable ()
int sound_env_supported ()
void adjust_volume_on_frame (float *volume_now, aav *data)
void snd_do_frame ()
int snd_get_samples_per_measure (char *filename, float num_measures)
void snd_adjust_audio_volume (int type, float percent, int time)
void snd_aav_init ()


const unsigned int SND_ENHANCED_MAX_LIMIT = 15
SCP_vector< soundSounds
int Sound_enabled = FALSE
int Snd_sram
float Master_sound_volume = 1.0f
float Master_voice_volume = 0.7f
unsigned int SND_ENV_DEFAULT = 0
SCP_list< LoopingSoundInfocurrentlyLoopingSoundInfos
float aav_voice_volume = 1.0f
float aav_music_volume = 1.0f
float aav_effect_volume = 1.0f
aav aav_data [3]
int Sound_spew = 0
uint nextSignature = 0

Macro Definition Documentation

#define MIN_SOUND_VOLUME   0.05f

Definition at line 92 of file sound.cpp.

#define SND_F_USED   (1<<0)

Definition at line 37 of file sound.cpp.

Typedef Documentation

typedef struct sound sound

Function Documentation

void adjust_volume_on_frame ( float volume_now,
aav data 

Definition at line 1501 of file sound.cpp.

DCF ( show_sounds  ,
"Toggles display of sound debug info"   

Definition at line 202 of file sound.cpp.

int ds_priority ( int  priority)

Definition at line 97 of file sound.cpp.

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_clear ( )

Definition at line 114 of file sound.cpp.

void snd_close ( void  )

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 gs,
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,
float  range_factor 

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_index ( int  sig)

Definition at line 1268 of file sound.cpp.

int snd_get_pitch ( int  sig)

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  sig)

Definition at line 1047 of file sound.cpp.

int snd_load ( game_snd gs,
int  allow_hardware_load 

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,
float  vol_scale,
int  priority,
bool  is_voice_msg 

Definition at line 517 of file sound.cpp.

int snd_play_3d ( game_snd gs,
vec3d source_pos,
vec3d listen_pos,
float  radius,
vec3d source_vel,
int  looping,
float  vol_scale,
int  priority,
vec3d sound_fvec,
float  range_factor,
int  force,
bool  is_ambient 

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

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
-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,
int  priority 

Definition at line 477 of file sound.cpp.

void snd_rewind ( int  snd_handle,
game_snd gs,
float  seconds 

Definition at line 1120 of file sound.cpp.

void snd_set_pan ( int  sig,
float  pan 

Definition at line 964 of file sound.cpp.

void snd_set_pitch ( int  sig,
int  pitch 

Definition at line 1021 of file sound.cpp.

void snd_set_pos ( int  snd_handle,
game_snd gs,
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

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_spew_debug_info ( )

Definition at line 212 of file sound.cpp.

void snd_spew_info ( )

Definition at line 173 of file sound.cpp.

void snd_stop ( int  sig)

Stop a sound from playing.

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.

void snd_stop_any_sound ( )

Definition at line 1213 of file sound.cpp.

int snd_time_remaining ( int  handle)

Definition at line 1291 of file sound.cpp.

int snd_unload ( int  n)

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  soundnum,
game_snd gs,
vec3d new_pos,
float  radius,
float  range_factor 

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.

int sound_env_disable ( )

Definition at line 1389 of file sound.cpp.

int sound_env_get ( sound_env se,
int  preset 

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

aav aav_data[3]

Definition at line 89 of file sound.cpp.

float aav_effect_volume = 1.0f

Definition at line 80 of file sound.cpp.

float aav_music_volume = 1.0f

Definition at line 79 of file sound.cpp.

float aav_voice_volume = 1.0f

Definition at line 78 of file sound.cpp.

SCP_list<LoopingSoundInfo> currentlyLoopingSoundInfos

Definition at line 75 of file sound.cpp.

float Master_sound_volume = 1.0f

Definition at line 53 of file sound.cpp.

float Master_voice_volume = 0.7f

Definition at line 54 of file sound.cpp.

uint nextSignature = 0

Definition at line 1549 of file sound.cpp.

const unsigned int SND_ENHANCED_MAX_LIMIT = 15

Definition at line 35 of file sound.cpp.

unsigned int SND_ENV_DEFAULT = 0

Definition at line 56 of file sound.cpp.

int Snd_sram

Definition at line 52 of file sound.cpp.

int Sound_enabled = FALSE

Definition at line 51 of file sound.cpp.

int Sound_spew = 0

Definition at line 201 of file sound.cpp.

SCP_vector<sound> Sounds

Definition at line 49 of file sound.cpp.