UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
s_mix.cpp File Reference

Main control for any streaming sound output device. More...

#include "../cl_shared.h"
#include "../cl_renderer.h"
#include "../cl_video.h"
#include "../battlescape/cl_camera.h"
#include "../battlescape/cl_localentity.h"
#include "../battlescape/cl_battlescape.h"
#include "s_mix.h"
#include "s_sample.h"
#include "s_main.h"

Go to the source code of this file.

Functions

static int S_AllocChannel (void)
 Searches a channel with no sample applied yet. More...
 
void S_FreeChannel (int c)
 Callback that is called when a channel finished playing. More...
 
void S_SpatializeChannel (const s_channel_t *ch)
 Set distance and stereo panning for the specified channel. More...
 
void S_PlaySample (const vec3_t origin, s_sample_t *sample, float atten, float relVolume)
 Validates the parms and queues the sound up. More...
 
void S_LoopSample (const vec3_t org, s_sample_t *sample, float relVolume, float attenuation)
 Adds a loop sample for e.g. ambient sounds. More...
 
void S_StartLocalSample (const char *name, float relVolume)
 Plays a sample without spatialization. More...
 

Detailed Description

Main control for any streaming sound output device.

Definition in file s_mix.cpp.

Function Documentation

static int S_AllocChannel ( void  )
static

Searches a channel with no sample applied yet.

Returns
-1 if no free channel was found, otherwise the index of the channel

Definition at line 41 of file s_mix.cpp.

References s_env_s::channels, i, MAX_CHANNELS, s_env, and s_channel_s::sample.

Referenced by S_LoopSample(), and S_PlaySample().

void S_FreeChannel ( int  c)

Callback that is called when a channel finished playing.

Parameters
cThe channel id

Definition at line 55 of file s_mix.cpp.

References s_env_s::channels, OBJZERO, and s_env.

Referenced by S_Init().

void S_LoopSample ( const vec3_t  org,
s_sample_t sample,
float  relVolume,
float  attenuation 
)
void S_PlaySample ( const vec3_t  origin,
s_sample_t sample,
float  atten,
float  relVolume 
)

Validates the parms and queues the sound up.

Parameters
[in]originif this is nullptr, the sound will be dynamically sourced from the entity
[in]sampleThe soundfile to play
[in]attenAttenuation of sound to be played (for example, fireAttenuation or impactAttenuation from fireDef_s).
[in]relVolumeMax mixer volume factor (0.0 - 1.0)
See also
S_StartLocalSample
S_SetVolume

Definition at line 96 of file s_mix.cpp.

References s_channel_s::atten, s_env_s::channels, s_sample_s::chunk, CL_Milliseconds(), Com_DPrintf(), DEBUG_SOUND, s_env_s::initialized, s_sample_s::lastPlayed, s_sample_s::name, s_channel_s::org, S_AllocChannel(), s_env, S_SpatializeChannel(), s_channel_s::sample, s_env_s::sampleRepeatRate, snd_volume, cvar_s::value, and VectorCopy.

Referenced by S_LoadAndPlaySample(), S_PlayStdSample(), and S_StartLocalSample().

void S_SpatializeChannel ( const s_channel_t ch)

Set distance and stereo panning for the specified channel.

Parameters
[in]chThe channel to perform the spatialization for.

Definition at line 64 of file s_mix.cpp.

References s_channel_s::atten, clientBattleScape_s::cam, camera_s::camorg, s_env_s::channels, cl, DotProduct, int(), s_channel_s::org, s_env_s::right, s_env, snd_distance_scale, todeg, cvar_s::value, VectorNormalize(), and VectorSubtract.

Referenced by S_Frame(), S_LoopSample(), and S_PlaySample().

void S_StartLocalSample ( const char *  name,
float  relVolume 
)

Plays a sample without spatialization.

Parameters
[in]nameThe sample name
[in]relVolumeMax mixer volume factor (0.0 - 1.0)
See also
S_PlaySample
S_LoadSample

Definition at line 184 of file s_mix.cpp.

References Com_Printf(), s_env_s::initialized, s_env, S_LoadSample(), S_PlaySample(), and SOUND_ATTN_NORM.

Referenced by CL_DoEndRound(), GAME_AddChatMessage(), GAME_GetImportData(), Irc_AppendToBuffer(), Irc_Client_CmdPrivmsg(), S_Play_f(), SEQ_ExecuteSound(), and UI_PlaySound().