34#define COMPARE_VERSION(major, minor, micro) \
35 (SDL_MIXER_MAJOR_VERSION > (major) || \
36 (SDL_MIXER_MAJOR_VERSION == (major) && SDL_MIXER_MINOR_VERSION > (minor)) || \
37 (SDL_MIXER_MAJOR_VERSION == (major) && SDL_MIXER_MINOR_VERSION == (minor) && \
38 SDL_MIXER_PATCHLEVEL >= (micro)))
61 if (!
s_env.initialized)
77 if (!
s_env.initialized)
107 if (
s_env.channels[j].sample == sample)
153 for (
char const*
const* extension = soundExtensions; *extension; ++extension) {
155 Com_sprintf(pattern,
sizeof(pattern),
"sound/**.%s", *extension);
157 char const*
const fileWithPath =
filename + strlen(
"sound/");
176 Com_Printf(
"\n------- sound initialization -------\n");
187 Cvar_Get(
"snd_music",
"PsymongN3", 0,
"Background music track");
201 Cmd_AddCommand(
"snd_play",
S_Play_f,
"Plays a sound fx file. Pass path relative to base/sound without file extension");
204 if (SDL_WasInit(SDL_INIT_AUDIO) == 0) {
205 if (SDL_Init(SDL_INIT_AUDIO) < 0) {
211 MIX_VERSION(&version)
212 Com_Printf(
"SDL_mixer version: %d.%d.%d\n", version.major, version.minor, version.patch);
220 if (Mix_QuerySpec(&
s_env.rate, &
s_env.format, &
s_env.numChannels) == 0) {
225 const int n = SDL_GetNumAudioDrivers();
227 Com_Printf(
"... no built-in audio drivers\n");
229 for (
int i = 0;
i < n; ++
i) {
230 Com_Printf(
"... available audio driver %s\n", SDL_GetAudioDriver(
i));
234 Com_Printf(
"... actual audio driver: %s\n", SDL_GetCurrentAudioDriver());
246#if COMPARE_VERSION(1, 2, 10)
247 if (!(Mix_Init(MIX_INIT_OGG) & MIX_INIT_OGG)) {
248 Com_Printf(
"... could not load ogg vorbis support - sound initialization failed\n");
249 Mix_AllocateChannels(0);
251 SDL_QuitSubSystem(SDL_INIT_AUDIO);
254 Com_Printf(
"... loaded ogg vorbis support\n");
258 s_env.initialized =
true;
270 if (!
s_env.initialized)
277 Mix_AllocateChannels(0);
283 if (SDL_WasInit(SDL_INIT_EVERYTHING) == SDL_INIT_AUDIO)
286 SDL_QuitSubSystem(SDL_INIT_AUDIO);
293#if COMPARE_VERSION(1, 2, 10)
297 s_env.initialized =
false;
347 s_env.sampleRepeatRate = sampleRepeatRate;
bool CL_OnBattlescape(void)
Check whether we are in a tactical mission as server or as client. But this only means that we are ab...
le_t * LE_GetNextInUse(le_t *lastLE)
Iterate through the entities that are in use.
Primary header for client.
const char * Cmd_Argv(int arg)
Returns a given argument.
void Cmd_AddParamCompleteFunction(const char *cmdName, int(*function)(const char *partial, const char **match))
void Cmd_RemoveCommand(const char *cmdName)
Removes a command from script interface.
void Cmd_Dummy_f(void)
Dummy binding if you don't want unknown commands forwarded to the server.
bool Cmd_GenericCompleteFunction(char const *candidate, char const *partial, char const **match)
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
void Com_Printf(const char *const fmt,...)
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
const char * FS_NextFileFromFileList(const char *files)
Returns the next file that is found in the virtual filesystem identified by the given file pattern.
#define Mem_DeletePool(pool)
#define Mem_CreatePool(name)
memPool_t * cl_soundSysPool
#define SAMPLE_TYPES
Supported sound file extensions.
#define MAX_CHANNELS
the sound environment
cvar_t * snd_distance_scale
s_sample_t * stdSoundPool[MAX_SOUNDIDS]
static void S_Play_f(void)
Plays sound fx files via console.
static cvar_t * snd_chunkbufsize
void S_LoadSamples(void)
Wrapper for S_PrecacheSamples to avoid exposing it via s_sample.h.
void S_Stop(void)
Stop all channels.
void S_PlayStdSample(const stdsound_t sId, const vec3_t origin, float attenuation, float volume)
plays one of the precached samples
static void S_Restart_f(void)
Restart the sound subsystem so it can pick up new parameters and flush all sounds.
static int S_CompleteSounds(const char *partial, const char **match)
void S_SetSampleRepeatRate(int sampleRepeatRate)
Controls the repeat rate for the same sample.
s_sample_t * S_LoadSample(const char *soundFile)
Loads and registers a sound file for later use.
bool S_LoadAndPlaySample(const char *s, const vec3_t origin, float attenuation, float volume)
does what the name implies in just one function to avoid exposing s_sample_t
int S_LoadSampleIdx(const char *soundFile)
Loads and registers a sound file for later use.
void S_StartLocalSample(const char *s, float volume)
Plays a sample without spatialization.
stdsound_t
These sounds are precached in S_LoadSamples.
#define SND_VOLUME_DEFAULT
void S_FreeChannel(int c)
Callback that is called when a channel finished playing.
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_PlaySample(const vec3_t origin, s_sample_t *sample, float atten, float relVolume)
Validates the parms and queues the sound up.
void S_SpatializeChannel(const s_channel_t *ch)
Set distance and stereo panning for the specified channel.
void S_MumbleUpdate(const vec3_t origin, const vec3_t forward, const vec3_t right, const vec3_t up)
void S_MumbleUnlink(void)
void S_PrecacheSamples(void)
s_sample_t * S_GetSample(const int soundIdx)
bool Q_strnull(const char *string)
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
#define VectorCopy(src, dest)