]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - sound.h
Rename RENDERPATH_GL20 to RENDERPATH_GL32.
[xonotic/darkplaces.git] / sound.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, 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"
25
26
27 // ====================================================================
28 // Constants
29 // ====================================================================
30
31 #define DEFAULT_SOUND_PACKET_VOLUME 255
32 #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
33
34 // Channel flags
35 // These channel flags can be used for sound() builtins, with SOUNDFLAG_* names
36 #define CHANNELFLAG_NONE        0
37 #define CHANNELFLAG_RELIABLE    (1 << 0) // send as reliable message (only used on server)
38 #define CHANNELFLAG_FORCELOOP   (1 << 1) // force looping even if the sound is not looped
39 #define CHANNELFLAG_LOCALSOUND  (1 << 2) // INTERNAL USE. Not settable by S_SetChannelFlag
40 #define CHANNELFLAG_PAUSED      (1 << 3) // pause status
41 #define CHANNELFLAG_FULLVOLUME  (1 << 4) // isn't affected by the general volume
42
43 // ====================================================================
44 // Types and variables
45 // ====================================================================
46
47 typedef struct sfx_s sfx_t;
48
49 extern cvar_t mastervolume;
50 extern cvar_t bgmvolume;
51 extern cvar_t volume;
52 extern cvar_t snd_initialized;
53 extern cvar_t snd_staticvolume;
54 extern cvar_t snd_mutewhenidle;
55
56
57 // ====================================================================
58 // Functions
59 // ====================================================================
60
61 void S_Init (void);
62 void S_Terminate (void);
63
64 void S_Startup (void);
65 void S_Shutdown (void);
66 void S_UnloadAllSounds_f (void);
67
68 void S_Update(const matrix4x4_t *listenermatrix);
69 void S_ExtraUpdate (void);
70
71 sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean levelsound);
72 float S_SoundLength(const char *name);
73 void S_ClearUsed (void);
74 void S_PurgeUnused (void);
75 qboolean S_IsSoundPrecached (const sfx_t *sfx);
76 sfx_t *S_FindName(const char *name);
77
78 // these define the "engine" channel namespace
79 #define CHAN_MIN_AUTO       -128
80 #define CHAN_MAX_AUTO          0
81 #define CHAN_MIN_SINGLE        1
82 #define CHAN_MAX_SINGLE      127
83 #define IS_CHAN_AUTO(n)        ((n) >= CHAN_MIN_AUTO && (n) <= CHAN_MAX_AUTO)
84 #define IS_CHAN_SINGLE(n)      ((n) >= CHAN_MIN_SINGLE && (n) <= CHAN_MAX_SINGLE)
85 #define IS_CHAN(n)             (IS_CHAN_AUTO(n) || IS_CHAN_SINGLE(n))
86
87 // engine channel == network channel
88 #define CHAN_ENGINE2NET(c)     (c)
89 #define CHAN_NET2ENGINE(c)     (c)
90
91 // engine view of channel encodes the auto flag into the channel number (see CHAN_ constants below)
92 // user view uses the flags bitmask for it
93 #define CHAN_USER2ENGINE(c)    (c)
94 #define CHAN_ENGINE2USER(c)    (c)
95 #define CHAN_ENGINE2CVAR(c)    (abs(c))
96
97 // S_StartSound returns the channel index, or -1 if an error occurred
98 int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
99 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);
100 qboolean S_LocalSound (const char *s);
101
102 void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
103 void S_StopSound (int entnum, int entchannel);
104 void S_StopAllSounds (void);
105 void S_PauseGameSounds (qboolean toggle);
106
107 void S_StopChannel (unsigned int channel_ind, qboolean lockmutex, qboolean freesfx);
108 qboolean S_SetChannelFlag (unsigned int ch_ind, unsigned int flag, qboolean value);
109 void S_SetChannelVolume (unsigned int ch_ind, float fvol);
110 void S_SetChannelSpeed (unsigned int ch_ind, float fspeed);
111 float S_GetChannelPosition (unsigned int ch_ind);
112 float S_GetEntChannelPosition(int entnum, int entchannel);
113
114 void S_BlockSound (void);
115 void S_UnblockSound (void);
116
117 int S_GetSoundRate (void);
118 int S_GetSoundChannels (void);
119
120 #endif