DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
sound.h
Go to the documentation of this file.
1/*
2Copyright (C) 1996-1997 Id Software, Inc.
3
4This program is free software; you can redistribute it and/or
5modify it under the terms of the GNU General Public License
6as published by the Free Software Foundation; either version 2
7of the License, or (at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19*/
20
21#ifndef SOUND_H
22#define SOUND_H
23
24#include "matrixlib.h"
25struct cmd_state_s;
26
27
28// ====================================================================
29// Constants
30// ====================================================================
31
32#define DEFAULT_SOUND_PACKET_VOLUME 255
33#define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
34
35// Channel flags
36// These channel flags can be used for sound() builtins, with SOUNDFLAG_* names
37#define CHANNELFLAG_NONE 0
38#define CHANNELFLAG_RELIABLE (1 << 0) // send as reliable message (only used on server)
39#define CHANNELFLAG_FORCELOOP (1 << 1) // force looping even if the sound is not looped
40#define CHANNELFLAG_LOCALSOUND (1 << 2) // INTERNAL USE. Not settable by S_SetChannelFlag
41#define CHANNELFLAG_PAUSED (1 << 3) // pause status
42#define CHANNELFLAG_FULLVOLUME (1 << 4) // isn't affected by the general volume
43
44// ====================================================================
45// Types and variables
46// ====================================================================
47
48typedef struct sfx_s sfx_t;
49
50extern cvar_t bgmvolume;
51extern cvar_t volume;
53
54
55// ====================================================================
56// Functions
57// ====================================================================
58
59void S_Init (void);
60void S_Terminate (void);
61
62void S_Startup (void);
63void S_Shutdown (void);
64void S_UnloadAllSounds_f(struct cmd_state_s *cmd);
65
66void S_Update(const matrix4x4_t *listenermatrix);
67
68sfx_t *S_PrecacheSound (const char *sample, qbool complain, qbool levelsound);
69float S_SoundLength(const char *name);
70void S_ClearUsed (void);
71void S_PurgeUnused (void);
72qbool S_IsSoundPrecached (const sfx_t *sfx);
73sfx_t *S_FindName(const char *name);
74
75// these define the "engine" channel namespace
76#define CHAN_MIN_AUTO -128
77#define CHAN_MAX_AUTO 0
78#define CHAN_MIN_SINGLE 1
79#define CHAN_MAX_SINGLE 127
80#define IS_CHAN_AUTO(n) ((n) >= CHAN_MIN_AUTO && (n) <= CHAN_MAX_AUTO)
81#define IS_CHAN_SINGLE(n) ((n) >= CHAN_MIN_SINGLE && (n) <= CHAN_MAX_SINGLE)
82#define IS_CHAN(n) (IS_CHAN_AUTO(n) || IS_CHAN_SINGLE(n))
83
84// engine channel == network channel
85#define CHAN_ENGINE2NET(c) (c)
86#define CHAN_NET2ENGINE(c) (c)
87
88// engine view of channel encodes the auto flag into the channel number (see CHAN_ constants below)
89// user view uses the flags bitmask for it
90#define CHAN_USER2ENGINE(c) (c)
91#define CHAN_ENGINE2USER(c) (c)
92#define CHAN_ENGINE2CVAR(c) (abs(c))
93
95int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
96int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags, float fspeed);
97qbool S_LocalSoundEx (const char *s, int chan, float fvol);
98qbool S_LocalSound (const char *s);
99
100void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
101void S_StopSound (int entnum, int entchannel);
102void S_StopAllSounds (void);
103void S_StopAllSounds_f(struct cmd_state_s *cmd);
104void S_PauseGameSounds (qbool toggle);
105
106void S_StopChannel (unsigned int channel_ind, qbool lockmutex, qbool freesfx);
107qbool S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qbool value);
108void S_SetChannelVolume (unsigned int ch_ind, float fvol);
109void S_SetChannelSpeed (unsigned int ch_ind, float fspeed);
110float S_GetChannelPosition (unsigned int ch_ind);
111float S_GetEntChannelPosition(int entnum, int entchannel);
112
113void S_BlockSound (void);
114void S_UnblockSound (void);
115
116int S_GetSoundRate (void);
117int S_GetSoundChannels (void);
118int S_GetSoundWidth (void);
119
120#endif
float flags
float entnum
vector origin
GLsizei const GLfloat * value
Definition glquake.h:740
const GLchar * name
Definition glquake.h:601
void cmd(string command,...)
vec_t vec3_t[3]
Definition qtypes.h:71
bool qbool
Definition qtypes.h:9
void S_Terminate(void)
Definition snd_main.c:842
void S_UnloadAllSounds_f(struct cmd_state_s *cmd)
void S_StaticSound(sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
Definition snd_main.c:1809
void S_SetChannelVolume(unsigned int ch_ind, float fvol)
Definition snd_main.c:1763
void S_StopAllSounds(void)
Definition snd_main.c:1710
int S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
S_StartSound returns the channel index, or -1 if an error occurred.
Definition snd_main.c:1643
qbool S_LocalSoundEx(const char *s, int chan, float fvol)
Definition snd_main.c:2217
cvar_t bgmvolume
Definition snd_main.c:165
void S_UnblockSound(void)
void S_ClearUsed(void)
Definition snd_main.c:996
void S_PurgeUnused(void)
Definition snd_main.c:1028
float S_GetChannelPosition(unsigned int ch_ind)
Definition snd_main.c:1773
void S_BlockSound(void)
void S_Startup(void)
Definition snd_main.c:476
void S_Update(const matrix4x4_t *listenermatrix)
Definition snd_main.c:2061
void S_StopChannel(unsigned int channel_ind, qbool lockmutex, qbool freesfx)
Definition snd_main.c:1648
int S_GetSoundRate(void)
Definition snd_main.c:377
void S_PauseGameSounds(qbool toggle)
Definition snd_main.c:1749
sfx_t * S_FindName(const char *name)
Definition snd_main.c:895
void S_StopAllSounds_f(struct cmd_state_s *cmd)
sfx_t * S_PrecacheSound(const char *sample, qbool complain, qbool levelsound)
Definition snd_main.c:1048
cvar_t snd_initialized
Definition snd_main.c:167
float S_SoundLength(const char *name)
Definition snd_main.c:1085
void S_Shutdown(void)
Definition snd_main.c:668
qbool S_SetChannelFlag(unsigned int ch_ind, unsigned int flag, qbool value)
Definition snd_main.c:1679
int S_GetSoundChannels(void)
Definition snd_main.c:382
float S_GetEntChannelPosition(int entnum, int entchannel)
Definition snd_main.c:1790
void S_Init(void)
Definition snd_main.c:706
qbool S_IsSoundPrecached(const sfx_t *sfx)
Definition snd_main.c:1105
void S_StopSound(int entnum, int entchannel)
Definition snd_main.c:1698
void S_SetChannelSpeed(unsigned int ch_ind, float fspeed)
Definition snd_main.c:1768
int S_StartSound_StartPosition_Flags(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags, float fspeed)
Definition snd_main.c:1571
int S_GetSoundWidth(void)
Definition snd_main.c:387
qbool S_LocalSound(const char *s)
Definition snd_main.c:2246
cvar_t volume
Definition snd_main.c:166
Definition cvar.h:66