UFO: Alien Invasion
Loading...
Searching...
No Matches
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"
Include dependency graph for s_mix.cpp:

Go to the source code of this file.

Functions

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

Detailed Description

Main control for any streaming sound output device.

Definition in file s_mix.cpp.

Function Documentation

◆ S_AllocChannel()

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 i, MAX_CHANNELS, and s_env.

Referenced by S_LoopSample(), and S_PlaySample().

◆ S_FreeChannel()

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 OBJZERO, and s_env.

Referenced by S_Init().

◆ S_LoopSample()

void S_LoopSample ( const vec3_t org,
s_sample_t * sample,
float relVolume,
float attenuation )

◆ S_PlaySample()

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_t::atten, s_sample_t::chunk, CL_Milliseconds(), Com_DPrintf(), DEBUG_SOUND, s_sample_t::lastPlayed, s_sample_t::name, s_channel_t::org, S_AllocChannel(), s_env, S_SpatializeChannel(), s_channel_t::sample, snd_volume, and VectorCopy.

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

◆ S_SpatializeChannel()

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_t::atten, cl, DotProduct, int(), s_channel_t::org, s_env, snd_distance_scale, todeg, VectorNormalize(), and VectorSubtract.

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

◆ S_StartLocalSample()

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(), name, 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(), UI_PlaySound(), and cgame_import_t::void().